Page 1 sur 1

ndless os config

Message non luPosté: 29 Mai 2020, 12:41
de parisse
Is there any way to access to the nspire OS configuration? For example, language, unit angle, ...

Re: ndless os config

Message non luPosté: 29 Mai 2020, 17:21
de Adriweb
The problem can (should?) be put the other way around, especially in your case where it's via a lua module.
What I mean is, TI already provides all these APIs to get (and set, in some cases) settings/config of a document, from Nspire Lua.

So, it would be easy to just call your own C function of your module that "receives" the lua value corresponding to what you want.

For instance you can look at math.getEvalSettings() (Returns a table of tables with the document settings that are currently being used by math.eval. These settings are equivalent to the current document settings unless a call has been made to setEvalSettings). Cf the page https://wiki.inspired-lua.org/math.setEvalSettings that has more info too.
For the language, there is locale.name()

Re: ndless os config

Message non luPosté: 29 Mai 2020, 19:02
de parisse
Adrien, the "new" KhiCAS UI (ported from the Numworks UI) does not use lua anymore : the idea is to have the same codebase for several calculator brands (with a few ifdef of course), at least for the Numworks and the TI.
That's why it would be nice to get the language from a C call, otherwise I will have to ask the user English or French when he run KhiCAS for the first time, or set it to French and leave the user press ctrl s and select English (current behavior).

Re: ndless os config

Message non luPosté: 29 Mai 2020, 19:16
de Adriweb
OK, if not from a Lua module anymore (I thought for graphics etc. you just "drew on screen" with a backup buffer etc.), then the Lua stuff doesn't apply of course :P
And it's more complicated now. The ndless sdk would have to impement that in an os-specific way, which isn't done right now afaik. No syscalls for it I think.
I'll let Vogtinator know about this topic.

Edit: getLangInfo() and getMode() from Basic would work -> https://www.manualslib.com/manual/37632 ... =48#manual ... if that's callable from ndless ?

Re: ndless os config

Message non luPosté: 29 Mai 2020, 20:12
de Vogtinator
You could parse /phoenix/syst/settings/current.zip yourself, that's where the settings are stored (AFAICT).
It might be enough to use some undocumented syscalls to poke the calc engine, though I don't know how well that works and it might break in the future when the OS changes ABI.

Code: Tout sélectionner
#include <os.h>
#include <syscall.h>
...

        char16_t input_w[] = u"nsolve(x-42=0,x)";
        void *math_expr = nullptr;
        int str_offset = 0;

        int error = TI_MS_evaluateExpr_ACBER(NULL, NULL, (const uint16_t*)input_w, &math_expr, &str_offset);
        if(error)
                return 0;

        char16_t *output_w;
        error = TI_MS_MathExprToStr(math_expr, NULL, (uint16_t**)&output_w);
        syscall<e_free, void>(math_expr); // Should be TI_MS_DeleteMathExpr

        if(error)
                return 0;

        // Do something with output_w, it's u"42." here

        syscall<e_free, void>(output_w);

Re: ndless os config

Message non luPosté: 30 Mai 2020, 06:53
de parisse
Thanks, it just works!

Re: ndless os config

Message non luPosté: 30 Mai 2020, 07:41
de parisse
Is there any way to set the RTC? I tried
Code: Tout sélectionner
   unsigned NSPIRE_RTC_ADDR=0x90090000;
   * (volatile unsigned *) NSPIRE_RTC_ADDR = (h*60+m)*60;

but it does not work.

Re: ndless os config

Message non luPosté: 30 Mai 2020, 09:30
de Vogtinator
You have to write to 0x90090008, see https://hackspire.org/index.php?title=M ... _.28RTC.29

Re: ndless os config

Message non luPosté: 30 Mai 2020, 11:10
de parisse
Indeed!