--- embedtools/src/pceng_run.c 2011/10/24 13:41:48 1.1.2.6 +++ embedtools/src/pceng_run.c 2011/10/24 20:24:16 1.1.2.7 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: pceng_run.c,v 1.1.2.6 2011/10/24 13:41:48 misho Exp $ + * $Id: pceng_run.c,v 1.1.2.7 2011/10/24 20:24:16 misho Exp $ * ************************************************************************* The ELWIX and AITNET software is distributed under the following @@ -142,7 +142,7 @@ LED(u_char ledno, u_char state) } outl(led_base[type - 1][ledno], n); - return 0; + return (int) state; } static int @@ -194,7 +194,7 @@ Run() if ((ret = gpioRead(i)) == -1) return 126; else - states |= (1 << i); + states |= ret ? (1 << i) : 0; /* state machine */ while (!Kill) { @@ -210,7 +210,7 @@ Run() return 127; if (ret != ((states >> i) & 0x1)) { - if (!i) { + if (!i) { /* button */ t = 0; do { t++; @@ -218,7 +218,7 @@ Run() if (gpioRead(i) != ret) break; } while (!Kill); - } else { + } else { /* leds */ t = ret; if (ret) states |= (1 << i); @@ -228,6 +228,8 @@ Run() RunCmd(i, t); } + + usleep(slice); } }