Robin Handy
/
test1
main lauflicht test
Revision 6:41d274ed6967, committed 2020-01-13
- Comitter:
- rob117
- Date:
- Mon Jan 13 17:54:02 2020 +0000
- Parent:
- 5:c2a8fd8dede5
- Commit message:
- letzte funktion
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r c2a8fd8dede5 -r 41d274ed6967 main.cpp --- a/main.cpp Mon Jan 13 17:43:04 2020 +0000 +++ b/main.cpp Mon Jan 13 17:54:02 2020 +0000 @@ -5,6 +5,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); @@ -24,6 +25,9 @@ nibbleLeds(value); printb(value); + value = modifyBit(value, 2, 1); + printb(myleds); + printb(modifyBit(INIT, 3, 1)); wait(0.1); @@ -67,4 +71,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); + + + } \ No newline at end of file