Omnimaga
Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Vogtinator on October 28, 2014, 06:48:08 am
-
Yeah, it's been quite a while since the first release and I haven't posted here as it wasn't very stable at all, but now all bugs I could find are gone.
It's a port of micropython (http://micropython.org/), specifically for microcontrollers and due to the working integration of newlib and a "real" nio_use_stdio with the help of libsyscalls it could be ported quite easily. I added a small set of 2d functions to test the performance with mandelbrot and now it seems to be quite useful, and it's actually used by students already!
You can use a text editor to write .py.tns files and execute them directly (due to the file association) or use micropython in interactive mode.
It's using a heavily modified version of nspire-io for line history and I also changed the input method to be more PC-like (hold shift for upper case, for example). tab inserts 4 spaces for easier intendation.
(http://img.ourl.ca/micropython-1.png)
(http://img.ourl.ca/micropython_mandel1.png)
More in-depth information on ti-planet: http://tiplanet.org/forum/viewtopic.php?f=43&t=15140 and http://tiplanet.org/forum/viewtopic.php?f=43&t=15309
-
Wow, that is pretty awesome!
Python is a pretty powerful language after all :)
-
Is there documentation for the nsp module? (Also, how do you exit an infinate loop?)
-
Is there documentation for the nsp module?
here (https://github.com/Vogtinator/micropython/blob/nspire/nspire/texture.c#L18)
(Also, how do you exit an infinate loop?)
You can't, it runs single-threaded. It should be possible however to register an IRQ handler for the On-button.
-
Wow, this is cool! Will it work for grayscale models?
-
Wow, this is cool! Will it work for grayscale models?
Yes, on all models! Mandelbrot doesn't look that pretty, though :)
All python programs are entirely platform independant, the nsp module handles everything.
(There may be some keys missing, I didn't look at the clickpad and touchpad keys)
-
Pretty cool stuff! :D
-
Is there documentation for the nsp module?
here (https://github.com/Vogtinator/micropython/blob/nspire/nspire/texture.c#L18)
I wouldn't exactly call that documentation...
-
Is there documentation for the nsp module?
here (https://github.com/Vogtinator/micropython/blob/nspire/nspire/texture.c#L18)
I wouldn't exactly call that documentation...
I would. Is something crucial missing? Functions like setPx should be fairly simple to use.
-
isn't that only for nsp.texture?
-
Yes, there isn't anything else in nsp yet (except for nsp.readRTC(), but that's not really useful and not documented anywhere).
-
Ah, I see. and are you going to make the on button be ctrl-c? Other wise an infinite loop requires a reset, correct?
-
Ah, I see. and are you going to make the on button be ctrl-c? Other wise an infinite loop requires a reset, correct?
Exactly. Shouldn't be hard to do, it has a dedicated IRQ (power management).
-
This is really promising. I am curious how fast this will run compared to Lua and C? It would definitively be a great alternative for those who prefer Python and I know that at one point or another, Omnimaga always had its share of Python users.
Glad this is still being updated, by the way. I wish you good luck on this. :)
-
This is really promising. I am curious how fast this will run compared to Lua and C?
There are some graphs on ti-planet, although it changed a bit. There are three modes in micropython:
-Bytecode-Interpreter: A bit slower than Lua
-Native (generates ARM code): A lot faster than lua (dependant on code)
-Viper (generates optimized ARM code): Almost like native, although variables must have types assigned to them
It would definitively be a great alternative for those who prefer Python and I know that at one point or another, Omnimaga always had its share of Python users.
Glad this is still being updated, by the way. I wish you good luck on this. :)
Yeah, with a lot of other stuff to do work will be slow, but present :)
-
I assume that native and viper will not require Micropython to run and that Bytecode-interpreter is mainly for quick testing, right?
-
I assume that native and viper will not require Micropython to run and that Bytecode-interpreter is mainly for quick testing, right?
Nope, all of them are done at runtime, so you will always need micropython as it containes the needed runtime functions (print, for instance).
Compiling doesn't take long though.
There's a post by Damien on kickstarter:
https://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollers/posts/664832
-
Aaah I see now. Thanks for the info. MY main concern about needing the main program to run something is when the software takes like 40% of the calculator memory but that is only really an issue with the regular 83+ and older Nspire models I think and sometimes the file size or dependency is necessary.
-
On my Nspire CX CAS it take about 5 seconds for python to start, it didn't happen before...
-
Do you have more files than before? I noticed that when I have a lot of files on my calculator, the documents menu takes much longer to open and starting stuff takes longer too.
-
awesome.
Then. the most important question for game programmers:
Does It Have All Keys Repeat?
if so, I might make some programs using this (and learn python)
Also, how hard is it to make an on-calc editor/compiler?
-
Also, how hard is it to make an on-calc editor/compiler?
Vogtinator is already working on that: http://www.omnimaga.org/ti-nspire-projects/pywrite-python-script-editor/
-
Aah good. I see that that's only a script editor though (which is already awesome). I reckon that a compiler wouldn't be too hard, either.
If everything goes on-calc, I could see this become a kind of Axe.
(We'd still need some way to create graphics, though :P)
-
Well, there's already some kind of "JIT" available, btw.
(See the examples)
(Edit : It's native code emission, IIRC - look at "@micropython.native")
-
Do you have more files than before? I noticed that when I have a lot of files on my calculator, the documents menu takes much longer to open and starting stuff takes longer too.
I'm talking about when I launch micropython, the screen is black for about 5 seconds before opening the prompt.
-
On my Nspire CX CAS it take about 5 seconds for python to start, it didn't happen before...
Yeah, I know that happens sometimes. I'm not sure why and where this happens, but it's not really a big issue.
Aah good. I see that that's only a script editor though (which is already awesome). I reckon that a compiler wouldn't be too hard, either.
If everything goes on-calc, I could see this become a kind of Axe.
Compiling isn't possible, but that shouldn't be an issue as micropython translates fast enough.
(We'd still need some way to create graphics, though )
ConvertImg? (http://github.com/Vogtinator/ConvertImg)
Do you have more files than before? I noticed that when I have a lot of files on my calculator, the documents menu takes much longer to open and starting stuff takes longer too.
It's not even fragmentation, it's just that the NAND is really f*cking slow and the filesystem as well. I would understand if it was writing being slow, as it has to be reliable, even if you pull the battery or reset during saving.
awesome.
Then. the most important question for game programmers:
Does It Have All Keys Repeat?
if so, I might make some programs using this (and learn python)
Apart from a gets like "input()" function there isn't any input handling right now. I'm not sure how to do that, probably "isKeyPressed".
-
It's not even fragmentation, it's just that the NAND is really f*cking slow and the filesystem as well. I would understand if it was writing being slow, as it has to be reliable, even if you pull the battery or reset during saving.
Thankfully, at least it's nowhere as brutal as back when we were stuck with MirageOS 1.1 on Z80 calcs before 1.2 came out. When you had 150+ programs, it took 40 minutes to open the program list. O.O
-
Aah good. I see that that's only a script editor though (which is already awesome). I reckon that a compiler wouldn't be too hard, either.
If everything goes on-calc, I could see this become a kind of Axe.
(We'd still need some way to create graphics, though :P )
Python is an interpreted language, there is no compiler for it.
-
Python is an interpreted language, there is no compiler for it.
There are JIT (Just-in-Time) compilers out there for Python (Micro Python has a JIT too IIRC). Also you can compile a python script to python bytecode to improve loading time.
-
Not to mention in the case of Micropython, I think Vogtinator mentionned that there's a compiled mode or two. It really depends of the language and platform I guess.
-
which is ... what I've written above: http://www.omnimaga.org/ti-nspire-projects/micropython-python-for-nspire-calculators/msg395678/#msg395678
-
I know, I was just mentionning since he seemed to have missed your post or found it unclear.
-
Are you going to submit a pull request to the main micropython repo?
-
Maybe, depends on the progress and integration I make. They integrated several new features (including modules!) in micropython which aren't usable on the nspire yet, but I'm working on it.
-
I hope you do, it would result in much more publicity for the nspire port.
-
Hi,
have some questions about micropython (just trying to ask vogtinator, but it seems he is busy now):
-use nspire cx cas
-os 4.4.0.532
-nspire 4.4 installed
-micropython 146 started and terminated as told (also tried 134)
-get no .py.tns file started (also such with i=1 and print(i) as 2 lines Content)
-nassembler also doesnt start, gives the 'file format not supported' error
-how to enter the ' sign? Didnt find it. Also the graphic at TI planet shows several special keys but not this sign
-can't use pyWrite. It starts, I can write my 2 lines (i=1, print(i)), can save it with adding .py.tns. Can see them by open function in pyWrite, also
can load, edit and save again. But RUN doesnt do anything
-starting such a saved .py.tns file also doesn't work, same file error
-is there a list of the micropython commands? Trying several commands from tutorials giving mostly File Error
Hope to find some help.
thanks
klaus
-
Hi,
have some questions about micropython (just trying to ask vogtinator, but it seems he is busy now):
-use nspire cx cas
-os 4.4.0.532
-nspire 4.4 installed
-micropython 146 started and terminated as told (also tried 134)
-get no .py.tns file started (also such with i=1 and print(i) as 2 lines Content)
Check your ndless.cfg.tns.
-nassembler also doesnt start, gives the 'file format not supported' error
Hm, no idea.
-how to enter the ' sign? Didnt find it. Also the graphic at TI planet shows several special keys but not this sign
Indeed, it's not available on CX...
-can't use pyWrite. It starts, I can write my 2 lines (i=1, print(i)), can save it with adding .py.tns. Can see them by open function in pyWrite, also
can load, edit and save again. But RUN doesnt do anything
You need to configure the path to micropython.
-starting such a saved .py.tns file also doesn't work, same file error
-is there a list of the micropython commands? Trying several commands from tutorials giving mostly File Error
It's a basic subset of python.
Hope to find some help.
thanks
klaus
-
Hi,
have some questions about micropython (just trying to ask vogtinator, but it seems he is busy now):
-use nspire cx cas
-os 4.4.0.532
-nspire 4.4 installed
-micropython 146 started and terminated as told (also tried 134)
-get no .py.tns file started (also such with i=1 and print(i) as 2 lines Content)
Check your ndless.cfg.tns.
ext.nes=nespire
ext.gb=gbc4nspire
ext.gbc=gbc4nspire
ext.gba=gpsp_launcher
ext.nvid=nPlayer
ext.cvid=nPlayer
ext.bmp=mviewer_cx
ext.png=mviewer_cx
ext.jpg=mviewer_cx
ext.wad=ndoom
Should I add
ext.py=micropython ?
-how to enter the ' sign? Didnt find it. Also the graphic at TI planet shows several special keys but not this sign
Indeed, it's not available on CX...
-can't use pyWrite. It starts, I can write my 2 lines (i=1, print(i)), can save it with adding .py.tns. Can see them by open function in pyWrite, also
can load, edit and save again. But RUN doesnt do anything
You need to configure the path to micropython.
-starting such a saved .py.tns file also doesn't work, same file error
-is there a list of the micropython commands? Trying several commands from tutorials giving mostly File Error
It's a basic subset of python.
Now I found the error, a simple mistake I made: for testing both micropythen versions (134/146) I added this numbers to their names. So the .py files and nassembler couldn't find it. Just had to rename one and now everthing works:-)
Thanks for your help!
thanks
klaus
Edit (Eeems): Fixed quotes
-
I'm not too familiar with how µPy works in the background (or much C at all), but I ran into an issue with lambdas and default arguments (https://github.com/micropython/micropython/issues/1628), and found that somebody had already fixed it (https://github.com/micropython/micropython/commit/2c838942574a4970c922d1550f04e4b7b4d865a6). Could this be added to µPy for nspire?
I'd like to see further development and bug fixing on this project, but, as I mentioned before, I'm not currently able to help directly, although I'm working on learning C. :3
Also, basic key events and a time module would be great, perhaps even clearing the screen?
-
I don't know if this is just my calculator but with micropython 1.3.1 I can't exit the program and can only leave if I remove my calculator's batteries but when I use micropython 1.3.4 and does micropython on the ti nspire have any library built-in or library that you can download because I have a lot of programs that I have written that need libraries that I can't call on also in micropython 1.3.4 none of the shifted characters like shift and period is colon and I can't get a square or curly brackets with ctrl and shift