Mao jesephin
/
LaufTest
test
main.cpp@1:842be995801a, 2020-01-13 (annotated)
- Committer:
- jesephin
- Date:
- Mon Jan 13 17:38:41 2020 +0000
- Revision:
- 1:842be995801a
- Parent:
- 0:13c06c8c9762
- Child:
- 2:fbffbc249ee9
if
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jesephin | 0:13c06c8c9762 | 1 | #include "mbed.h" |
jesephin | 0:13c06c8c9762 | 2 | //#define BUTTON1 p14 //M3:push joystick pin |
jesephin | 0:13c06c8c9762 | 3 | //#define BUTTON1 A1 //NuCLEO: Taster A1 |
jesephin | 0:13c06c8c9762 | 4 | |
jesephin | 0:13c06c8c9762 | 5 | |
jesephin | 0:13c06c8c9762 | 6 | int modifyBit(int x,unsigned char position,bool State); |
jesephin | 0:13c06c8c9762 | 7 | int lauflicht(bool richtung,int time,int &anz); |
jesephin | 0:13c06c8c9762 | 8 | void nibbbledLeds(int value); |
jesephin | 0:13c06c8c9762 | 9 | void printb(uint8_t x); |
jesephin | 0:13c06c8c9762 | 10 | |
jesephin | 0:13c06c8c9762 | 11 | BusOut myleds(LED1,LED2,LED3,LED4); |
jesephin | 0:13c06c8c9762 | 12 | DigitalIn button(Button); |
jesephin | 0:13c06c8c9762 | 13 | |
jesephin | 0:13c06c8c9762 | 14 | const int INIT=ox03; |
jesephin | 0:13c06c8c9762 | 15 | |
jesephin | 0:13c06c8c9762 | 16 | int main() { |
jesephin | 0:13c06c8c9762 | 17 | int anzahl,anz; |
jesephin | 0:13c06c8c9762 | 18 | unit8_t value=INIT; |
jesephin | 0:13c06c8c9762 | 19 | |
jesephin | 0:13c06c8c9762 | 20 | anzahl=lauflicht(true,400,anz=0); |
jesephin | 0:13c06c8c9762 | 21 | printf("anzahl=%d\n",anzahl); |
jesephin | 0:13c06c8c9762 | 22 | |
jesephin | 0:13c06c8c9762 | 23 | nibbleLeds(value); |
jesephin | 0:13c06c8c9762 | 24 | printb(value); |
jesephin | 0:13c06c8c9762 | 25 | value=modifyBit(value,2,1); |
jesephin | 0:13c06c8c9762 | 26 | printb(myleds); |
jesephin | 0:13c06c8c9762 | 27 | printb(modifyBit(INIT,3,1)); |
jesephin | 0:13c06c8c9762 | 28 | wait(0.1); |
jesephin | 0:13c06c8c9762 | 29 | |
jesephin | 0:13c06c8c9762 | 30 | } |
jesephin | 0:13c06c8c9762 | 31 | |
jesephin | 0:13c06c8c9762 | 32 | int modifyBit(intx,unit8_t position,bool State) |
jesephin | 0:13c06c8c9762 | 33 | { |
jesephin | 0:13c06c8c9762 | 34 | int mask = 1 << position; |
jesephin | 0:13c06c8c9762 | 35 | int state = int(State); |
jesephin | 0:13c06c8c9762 | 36 | return(x&~mask)|((state<<position)&mask); |
jesephin | 0:13c06c8c9762 | 37 | } |
jesephin | 0:13c06c8c9762 | 38 | |
jesephin | 0:13c06c8c9762 | 39 | int lauflicht(bool richtung,int time,int&anz) |
jesephin | 1:842be995801a | 40 | { |
jesephin | 1:842be995801a | 41 | int i; |
jesephin | 1:842be995801a | 42 | unit8_t lauf=0x01; |
jesephin | 1:842be995801a | 43 | if(!richtung) |
jesephin | 1:842be995801a | 44 | lauf=0x08; |
jesephin | 1:842be995801a | 45 | |
jesephin | 1:842be995801a | 46 | while |
jesephin | 1:842be995801a | 47 | } |
jesephin | 0:13c06c8c9762 | 48 | } |