Author Topic: Ndless Program Puts Nspire into Load  (Read 3289 times)

0 Members and 1 Guest are viewing this topic.

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
Ndless Program Puts Nspire into Load
« on: August 21, 2011, 12:04:13 pm »
My program uses a
Code: [Select]
while (!isKeyPressed(KEY_NSPIRE_ESC)) so it only exits when escape is pressed. This loops causes an annoying clock to appear, indicating heavy processor load, and also wastes battery. I have tried sleep(), but with numbers even as high as 500 milliseconds, the clock still ends up appearing, albeit taking more time to do so. Also, with numbers higher than 100 or so, a noticeable input lag appears. What is the proper way to fix this?

Are you wondering who Sammy is? My avatar is Sammy.
   

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Ndless Program Puts Nspire into Load
« Reply #1 on: August 21, 2011, 12:49:01 pm »
The clock shows when an OS interrupt is running. I know "TCT_Local_Control_Interrupts(0);" enables interrupts, but idk what value will disable them.

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
Re: Ndless Program Puts Nspire into Load
« Reply #2 on: August 21, 2011, 01:47:04 pm »
Thanks so much! I always thought that clock was from the Nspire loading something, so I guess I was wrong! Anyways, the problem was I basically just put in TCT_Local_Control_Interrupts(0) because the Hello demo had it, without seeing why it was needed, so I removed that code and now it works!

Edit: Added another comma.
« Last Edit: August 21, 2011, 01:50:56 pm by sammyMaX »

Are you wondering who Sammy is? My avatar is Sammy.
   

Offline shrear

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 193
  • Rating: +17/-0
    • View Profile
Re: Ndless Program Puts Nspire into Load
« Reply #3 on: August 21, 2011, 02:09:41 pm »
to save battery you could try idle()
it slows the processor down until an interrupt ( a pressed key par example ) happens

Offline sammyMaX

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 204
  • Rating: +9/-0
    • View Profile
Re: Ndless Program Puts Nspire into Load
« Reply #4 on: August 21, 2011, 03:38:29 pm »
Thanks, I will try that. It is probably better than sleep(), which can sometimes cause lag.

Are you wondering who Sammy is? My avatar is Sammy.