#include "cpu_insn.h"
#endif
+/* If there was no operation on the NXT within SLEEP_TIME
+ * after starting the system, turn the NXT into sleep (shut down)
+ * to avoid battery discharge.
+ */
+#define SLEEP_TIME (1000*60*10) /* 10min */
+
SINT main(void)
{
U32 st;
init_OS_flag(); /* this should be called before device init */
nxt_device_init();
+ ecrobot_init_nxtstate();
show_splash_screen();
show_main_screen();
display_status_bar(1); /* clear status bar */
else
{
flash_req_cnt = 0;
- if (ecrobot_get_button_state() == RUN_PRESSED)
+ if ((ecrobot_get_button_state() == EXIT_PRESSED) || (systick_get_ms() > SLEEP_TIME))
+ {
+ /* shut down the NXT */
+ ecrobot_device_terminate();
+ display_clear(1);
+ systick_wait_ms(10);
+ nxt_lcd_power_down(); /* reset LCD hardware */
+ systick_wait_ms(10);
+ while(1)
+ {
+ nxt_avr_power_down();
+ }
+ }
+ else if (ecrobot_get_button_state() == RUN_PRESSED)
{
nxt_motor_set_count(NXT_PORT_A, 0);
nxt_motor_set_count(NXT_PORT_B, 0);
#endif
/* never reached here */
}
- else if (ecrobot_get_button_state() == EXIT_PRESSED)
- {
- /* shut down the NXT */
- ecrobot_device_terminate();
- display_clear(1);
- systick_wait_ms(10);
- nxt_lcd_power_down(); /* reset LCD hardware */
- systick_wait_ms(10);
- while(1)
- {
- nxt_avr_power_down();
- }
- }
}
}
}