Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: sammyMaX on August 21, 2011, 12:04:13 pm

Title: Ndless Program Puts Nspire into Load
Post by: sammyMaX 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?
Title: Re: Ndless Program Puts Nspire into Load
Post by: fb39ca4 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.
Title: Re: Ndless Program Puts Nspire into Load
Post by: sammyMaX 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.
Title: Re: Ndless Program Puts Nspire into Load
Post by: shrear 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
Title: Re: Ndless Program Puts Nspire into Load
Post by: sammyMaX on August 21, 2011, 03:38:29 pm
Thanks, I will try that. It is probably better than sleep(), which can sometimes cause lag.