Main
Revision 4:f3985b5c3549, committed 2020-01-13
- Comitter:
- muminhadzic
- Date:
- Mon Jan 13 17:51:16 2020 +0000
- Parent:
- 3:aaaaf9f23f46
- Commit message:
- modifyBit
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jan 13 17:48:03 2020 +0000
+++ b/main.cpp Mon Jan 13 17:51:16 2020 +0000
@@ -3,7 +3,7 @@
//#define BUTTON1 A1
int lauflicht(bool richtung,int time, int &anz);
-//int modifyBit(int x, unsigned char position, bool State);
+int modifyBit(int x, unsigned char position, bool State);
void nibbleLeds(int value);
void printb(uint8_t x);
@@ -21,8 +21,12 @@
printf("anzahl=%d\n",anzahl);
nibbleLeds(value);
+printb(value);
+value= modifyBit (value,2,1);
+printb(myleds);
+printb(modifyBit (INIT,3,1));
wait(0.1);
-printb(value);
+
}
//**************************************************************
@@ -64,4 +68,12 @@
return anz;
+ }
+ int modifyBit(int x, unsigned char position, bool State) {
+
+ int mask=1<< position;
+ int state = int(State);
+ return(x & ~mask) | ((state<<position)& mask);
+
+
}
\ No newline at end of file