Author Topic: micropython - Python for Nspire calculators  (Read 53048 times)

0 Members and 1 Guest are viewing this topic.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
micropython - Python for Nspire calculators
« 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, 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.




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
« Last Edit: October 28, 2014, 07:15:54 am by Vogtinator »

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: micropython - Python for Nspire calculators
« Reply #1 on: October 28, 2014, 08:19:13 am »
Wow, that is pretty awesome!
Python is a pretty powerful language after all :)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Ivoah

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +3/-0
    • View Profile
    • Codinghobbit
Re: micropython - Python for Nspire calculators
« Reply #2 on: October 28, 2014, 08:52:03 am »
Is there documentation for the nsp module? (Also, how do you exit an infinate loop?)
http://codinghobbit.no-ip.org
My Calcs:
TI-86 (now broken) $2
TI SR-56 - $0
TI-Nspire CX CAS - $152
TI-84+ Silver Edition - $56
TI-84+ Silver Edition - $0
TI-85 - $0
TI-73 Explorer VS - $10
ViewScreen - $3

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: micropython - Python for Nspire calculators
« Reply #3 on: October 28, 2014, 12:57:47 pm »
Quote
Is there documentation for the nsp module?
here

Quote
(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.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: micropython - Python for Nspire calculators
« Reply #4 on: October 28, 2014, 01:28:17 pm »
Wow, this is cool! Will it work for grayscale models?

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: micropython - Python for Nspire calculators
« Reply #5 on: October 28, 2014, 01:34:12 pm »
Quote
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)
« Last Edit: October 28, 2014, 01:39:25 pm by Vogtinator »

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: micropython - Python for Nspire calculators
« Reply #6 on: October 28, 2014, 03:37:44 pm »
Pretty cool stuff! :D

Offline Ivoah

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +3/-0
    • View Profile
    • Codinghobbit
Re: micropython - Python for Nspire calculators
« Reply #7 on: October 28, 2014, 03:41:27 pm »
Quote
Is there documentation for the nsp module?
here


I wouldn't exactly call that documentation...
http://codinghobbit.no-ip.org
My Calcs:
TI-86 (now broken) $2
TI SR-56 - $0
TI-Nspire CX CAS - $152
TI-84+ Silver Edition - $56
TI-84+ Silver Edition - $0
TI-85 - $0
TI-73 Explorer VS - $10
ViewScreen - $3

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: micropython - Python for Nspire calculators
« Reply #8 on: October 28, 2014, 03:54:18 pm »
Quote
Is there documentation for the nsp module?
here


I wouldn't exactly call that documentation...
I would. Is something crucial missing? Functions like setPx should be fairly simple to use.

Offline Ivoah

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +3/-0
    • View Profile
    • Codinghobbit
Re: micropython - Python for Nspire calculators
« Reply #9 on: October 28, 2014, 03:55:56 pm »
isn't that only for nsp.texture?
http://codinghobbit.no-ip.org
My Calcs:
TI-86 (now broken) $2
TI SR-56 - $0
TI-Nspire CX CAS - $152
TI-84+ Silver Edition - $56
TI-84+ Silver Edition - $0
TI-85 - $0
TI-73 Explorer VS - $10
ViewScreen - $3

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: micropython - Python for Nspire calculators
« Reply #10 on: October 28, 2014, 03:57:13 pm »
Yes, there isn't anything else in nsp yet (except for nsp.readRTC(), but that's not really useful and not documented anywhere).

Offline Ivoah

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +3/-0
    • View Profile
    • Codinghobbit
Re: micropython - Python for Nspire calculators
« Reply #11 on: October 28, 2014, 04:02:51 pm »
Ah, I see. and are you going to make the on button be ctrl-c? Other wise an infinite loop requires a reset, correct?
http://codinghobbit.no-ip.org
My Calcs:
TI-86 (now broken) $2
TI SR-56 - $0
TI-Nspire CX CAS - $152
TI-84+ Silver Edition - $56
TI-84+ Silver Edition - $0
TI-85 - $0
TI-73 Explorer VS - $10
ViewScreen - $3

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: micropython - Python for Nspire calculators
« Reply #12 on: October 28, 2014, 04:16:01 pm »
Quote
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).

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: micropython - Python for Nspire calculators
« Reply #13 on: October 28, 2014, 04:48:48 pm »
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. :)

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: micropython - Python for Nspire calculators
« Reply #14 on: October 28, 2014, 05:02:29 pm »
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

Quote
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 :)