Riad_ Bajraktarevic
/
Bajraktarevic_13_01_20
main
main.cpp@1:5fdd61b15b35, 2020-01-13 (annotated)
- Committer:
- riad
- Date:
- Mon Jan 13 17:32:34 2020 +0000
- Revision:
- 1:5fdd61b15b35
- Parent:
- 0:b44f9a2ebea2
- Child:
- 2:4eacbe2fa323
modifyBit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
riad | 0:b44f9a2ebea2 | 1 | #include "mbed.h" |
riad | 0:b44f9a2ebea2 | 2 | #define BUTTON1 p14 |
riad | 0:b44f9a2ebea2 | 3 | //#define BUTTON! A1 |
riad | 0:b44f9a2ebea2 | 4 | |
riad | 0:b44f9a2ebea2 | 5 | int modifyBit(int x, unsigned char position, bool State); |
riad | 0:b44f9a2ebea2 | 6 | int lauflicht(bool richtung, int time, int &anz); |
riad | 0:b44f9a2ebea2 | 7 | void nibbleLeds(int value); |
riad | 0:b44f9a2ebea2 | 8 | void printb(uint8_t x); |
riad | 0:b44f9a2ebea2 | 9 | |
riad | 0:b44f9a2ebea2 | 10 | |
riad | 0:b44f9a2ebea2 | 11 | BusOut myleds(LED1,LED2,LED3,LED4); |
riad | 0:b44f9a2ebea2 | 12 | DigitalIn button(BUTTON1); |
riad | 0:b44f9a2ebea2 | 13 | |
riad | 0:b44f9a2ebea2 | 14 | const int INIT = 0x03; |
riad | 0:b44f9a2ebea2 | 15 | |
riad | 0:b44f9a2ebea2 | 16 | int main () |
riad | 0:b44f9a2ebea2 | 17 | { |
riad | 0:b44f9a2ebea2 | 18 | int anzahl, anz; |
riad | 0:b44f9a2ebea2 | 19 | uint8_t value = INIT; |
riad | 0:b44f9a2ebea2 | 20 | |
riad | 0:b44f9a2ebea2 | 21 | |
riad | 0:b44f9a2ebea2 | 22 | |
riad | 0:b44f9a2ebea2 | 23 | |
riad | 1:5fdd61b15b35 | 24 | } |
riad | 1:5fdd61b15b35 | 25 | |
riad | 1:5fdd61b15b35 | 26 | |
riad | 1:5fdd61b15b35 | 27 | int modifyBit (int x, uint8_t position, bool State) |
riad | 1:5fdd61b15b35 | 28 | { |
riad | 1:5fdd61b15b35 | 29 | int mask = 1 << position; |
riad | 1:5fdd61b15b35 | 30 | int state = int(State); |
riad | 1:5fdd61b15b35 | 31 | return (x & ~mask) | ((state << position) & mask); |
riad | 1:5fdd61b15b35 | 32 | } |