Robert Buch / Mbed 2 deprecated compile

Dependencies:   mbed

Files at this revision

API Documentation at this revision

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;