Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 5:d0e564605224, committed 2020-01-13
- Comitter:
- robertbuc
- Date:
- Mon Jan 13 17:44:49 2020 +0000
- Parent:
- 4:179695a6d7fd
- Commit message:
- nibble,printb,lauflicht,modifybit _ fertig
Changed in this revision
| test.cpp | Show annotated file Show diff for this revision Revisions of this file | 
--- a/test.cpp	Mon Jan 13 17:39:15 2020 +0000
+++ b/test.cpp	Mon Jan 13 17:44:49 2020 +0000
@@ -11,6 +11,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);
@@ -27,9 +28,20 @@
     
     nibbleLeds(value);
     printb(value);
+    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;
@@ -64,7 +76,6 @@
     return anz;
 }
         
-        
 
 void printb(uint8_t x)
 {
@@ -73,6 +84,7 @@
     printf("\n");
 }    
 
+
 void nibbleLeds(int value)
 {
     myleds=value%16;