[tuxdroid-svn] r323 - firmware/tuxcore/trunk
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-05-25 17:02:33
|
Author: jaguarondi Date: 2007-05-25 19:02:03 +0200 (Fri, 25 May 2007) New Revision: 323 Modified: firmware/tuxcore/trunk/main.c Log: - ADD: sleep function in tuxcore, no power savings yet but the status are stopped. Modified: firmware/tuxcore/trunk/main.c =================================================================== --- firmware/tuxcore/trunk/main.c 2007-05-19 11:26:40 UTC (rev 322) +++ firmware/tuxcore/trunk/main.c 2007-05-25 17:02:03 UTC (rev 323) @@ -43,6 +43,7 @@ void ioInit(void); void timer2Init(void); void updateStatus(void); +void sleep(void); /* * External variables @@ -217,7 +218,7 @@ /* * Communication: updating status, receiving and sending commands */ - if (updateStatusFlag) /* do all stuff that needs to be updated before status are sent */ + if (updateStatusFlag && !cond_flags.sleep) /* do all stuff that needs to be updated before status are sent; we don't send status when entering sleep mode */ { updateStatusFlag = 0; updateStatus(); /* add sensors states to the status queue */ @@ -236,6 +237,10 @@ standalone_behavior(); /* standalone behavior manager */ + /* Entering sleep mode */ + if (cond_flags.sleep) + sleep(); + /* * Test and debug functions */ @@ -380,3 +385,18 @@ statusFifoFlag = 0; } + +/* + * Sleep functions + */ + +void sleep(void) +{ + turnLeftLedOff(); + while(SW_HD_PIN & SW_HD_MK) /* exit sleep if head is pushed */ + { + /* XXX Enter sleep mode here, either wakeup regularly to check the head button or better configure an interrupt on the head button to wake-up the CPU */ + } + turnLeftLedOn(); + cond_flags.sleep = 0; +} |