![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
funktionen
main.cpp@3:57ccaba4a24d, 2020-01-13 (annotated)
- Committer:
- sandrodjuric
- Date:
- Mon Jan 13 17:12:22 2020 +0000
- Revision:
- 3:57ccaba4a24d
- Parent:
- 2:5b052d18a113
- Child:
- 4:25e070866cf0
modifybit funk definieren
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sandrodjuric | 0:8c6f1d850a3c | 1 | #include "mbed.h" |
sandrodjuric | 0:8c6f1d850a3c | 2 | |
sandrodjuric | 2:5b052d18a113 | 3 | #define BUTTON1 p14 |
sandrodjuric | 2:5b052d18a113 | 4 | |
sandrodjuric | 1:2beb3ea0c40f | 5 | int modifyBit(int x, unsigned char position, bool State); |
sandrodjuric | 1:2beb3ea0c40f | 6 | int lauflicht(bool richtung, int time, int &anz); |
sandrodjuric | 1:2beb3ea0c40f | 7 | void nibbleLeds(int value); |
sandrodjuric | 2:5b052d18a113 | 8 | void printb(uint8_t x); |
sandrodjuric | 2:5b052d18a113 | 9 | |
sandrodjuric | 2:5b052d18a113 | 10 | BusOut myleds(LED1,LED2,LED3,LED4); |
sandrodjuric | 2:5b052d18a113 | 11 | DigitalIn button(BUTTON1); |
sandrodjuric | 2:5b052d18a113 | 12 | |
sandrodjuric | 2:5b052d18a113 | 13 | const int INIT = 0x03; |
sandrodjuric | 3:57ccaba4a24d | 14 | |
sandrodjuric | 3:57ccaba4a24d | 15 | int main(){ |
sandrodjuric | 3:57ccaba4a24d | 16 | int anzahl,anz; |
sandrodjuric | 3:57ccaba4a24d | 17 | uint8_t value = INIT; |
sandrodjuric | 3:57ccaba4a24d | 18 | } |
sandrodjuric | 3:57ccaba4a24d | 19 | |
sandrodjuric | 3:57ccaba4a24d | 20 | int modifyBit(int x, unsigned char position, bool State) |
sandrodjuric | 3:57ccaba4a24d | 21 | { |
sandrodjuric | 3:57ccaba4a24d | 22 | int mask = 1 << position; |
sandrodjuric | 3:57ccaba4a24d | 23 | int state = int(State); |
sandrodjuric | 3:57ccaba4a24d | 24 | return (x & ~mask)|((state << position) & mask); |
sandrodjuric | 3:57ccaba4a24d | 25 | } |