Mario Barisic
/
test_program
test program
main.cpp@2:3875bc678188, 2020-01-13 (annotated)
- Committer:
- shogu
- Date:
- Mon Jan 13 17:35:38 2020 +0000
- Revision:
- 2:3875bc678188
- Parent:
- 1:899bf4117ea9
- Child:
- 3:ff2ce4f4c5cf
mit_printb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shogu | 0:dfb1326f7f80 | 1 | #include "mbed.h" |
shogu | 0:dfb1326f7f80 | 2 | #define BUTTON1 p14 // M3: push joystick pin |
shogu | 0:dfb1326f7f80 | 3 | // #define BUTTON1 A1 //NUCLEO: Taster A1 |
shogu | 0:dfb1326f7f80 | 4 | |
shogu | 1:899bf4117ea9 | 5 | void nibbleLeds(int value); |
shogu | 2:3875bc678188 | 6 | void printb(uint8_t x); |
shogu | 0:dfb1326f7f80 | 7 | |
shogu | 0:dfb1326f7f80 | 8 | BusOut myleds(LED1, LED2, LED3, LED4); |
shogu | 0:dfb1326f7f80 | 9 | DigitalIn button(BUTTON1); |
shogu | 0:dfb1326f7f80 | 10 | |
shogu | 0:dfb1326f7f80 | 11 | const int INIT = 0x03; |
shogu | 0:dfb1326f7f80 | 12 | |
shogu | 0:dfb1326f7f80 | 13 | int main() { |
shogu | 1:899bf4117ea9 | 14 | int anzahl, anz; |
shogu | 1:899bf4117ea9 | 15 | uint8_t value = INIT; |
shogu | 1:899bf4117ea9 | 16 | |
shogu | 1:899bf4117ea9 | 17 | nibbleLeds(value); |
shogu | 2:3875bc678188 | 18 | printb(value); |
shogu | 1:899bf4117ea9 | 19 | wait(0.1); |
shogu | 0:dfb1326f7f80 | 20 | } |
shogu | 1:899bf4117ea9 | 21 | |
shogu | 1:899bf4117ea9 | 22 | |
shogu | 2:3875bc678188 | 23 | void printb(uint8_t x) { |
shogu | 2:3875bc678188 | 24 | for(int i=sizeof(x)<<3; i; i--) |
shogu | 2:3875bc678188 | 25 | putchar('0'+((x<<(i-1))&1)); |
shogu | 2:3875bc678188 | 26 | } |
shogu | 2:3875bc678188 | 27 | |
shogu | 1:899bf4117ea9 | 28 | void nibbleLeds(int value) { |
shogu | 1:899bf4117ea9 | 29 | myleds = value%16; |
shogu | 1:899bf4117ea9 | 30 | } |