Dominic Harg
/
TINF_Test_1301
Testprogramm lauflicht
Revision 4:a0cc5eebc75e, committed 2020-01-13
- Comitter:
- haunsi
- Date:
- Mon Jan 13 17:44:48 2020 +0000
- Parent:
- 3:e46730634660
- Commit message:
- funktion modifyBit
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e46730634660 -r a0cc5eebc75e main.cpp --- a/main.cpp Mon Jan 13 17:38:50 2020 +0000 +++ b/main.cpp Mon Jan 13 17:44:48 2020 +0000 @@ -4,6 +4,7 @@ void nibbleLeds(int value); void printb(uint8_t x); int lauflicht(bool richtung, int time, int &anz); +int modifyBit(int x, unsigned char position, bool State); BusOut myleds(LED1, LED2, LED3, LED4); DigitalIn button(BUTTON1); @@ -19,9 +20,19 @@ nibbleLeds(value); printb(value); + value = modifyBit(value, 2, 1); + printb(myleds); + printb(modifyBit(INIT, 3, 1)); wait(0.1); } +int modifyBit(int x, uint8_t position, bool State) +{ + int mask = 1 << position; + int state = int(State); + return (x & ~mask) | ((State << position) & mask); +} + int lauflicht(bool richtung, int time, int &anz) { int i;