X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=buttons.c;h=8ddd7ee2c94ff06fe10bc8e0bb51cc9ca51bee84;hb=cf3abde4b8055ab1d26116b1f9af47951d1a0395;hp=e97f8bf0e9ee9eaf5fe354803e4ddb1f28cead5c;hpb=7852f013105442dfe0ff800f32151e94f98a554a;p=rgblamp.git diff --git a/buttons.c b/buttons.c index e97f8bf..8ddd7ee 100644 --- a/buttons.c +++ b/buttons.c @@ -7,12 +7,24 @@ #include #include "buttons.h" +#include "timer.h" void buttons_sleep() { + /* If the rocker is on, sleep until it is placed in the off position */ + IOCBN4 = 0; IOCBP4 = 1; + IOCBN5 = 0; IOCBP5 = 1; + while ((buttons_read() & (IN_ROCKERA | IN_ROCKERB))) { + IOCIE = 1; + SLEEP(); + IOCIE = 0; + timer_mwait(50); /* debounce */ + } + + /* Now that the rocker is off, sleep until it is turned on */ + IOCBN4 = 1; IOCBP4 = 0; IOCBF4 = 0; + IOCBN5 = 1; IOCBP5 = 0; IOCBF5 = 0; if ((buttons_read() & (IN_ROCKERA | IN_ROCKERB)) == 0) { - IOCBF4 = 0; - IOCBF5 = 0; IOCIE = 1; SLEEP(); IOCIE = 0;