Prototype
Dependencies: mbed ButtonEventDemo
Diff: Lauflicht.cpp
- Revision:
- 17:080847c64d0b
- Parent:
- 16:acf89f757b1b
--- a/Lauflicht.cpp Mon Jan 13 17:58:06 2020 +0000 +++ b/Lauflicht.cpp Mon Jan 13 18:12:09 2020 +0000 @@ -16,9 +16,13 @@ uint8_t value=INIT; int anzahl, anz; + anzahl=lauflicht(0,400,anz=0); + printf("anzahl= %d\n", anzahl); nibbleLeds(value); printb(value); + value=modifyBit(value,2,1); printb(myleds); + printb(modifyBit(INIT,3,1)); lauflicht(0,400,anz=0); wait(0.1); } @@ -54,6 +58,12 @@ return anz; } +int modifyBit(int x, uint8_t position, bool State){ + int mask=1<<position; + int state =int(State); + return (x&~mask)|((state<<position)&mask); +} + void printb(uint8_t x){ for(int i=sizeof(x)<<3; i; i--){ putchar('0'+((x>>(i-1))&1));