![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Schulaufgabe Funktionen 21.12.2015
main.cpp@0:eb6611fa99f5, 2015-12-21 (annotated)
- Committer:
- Dominik_2000
- Date:
- Mon Dec 21 14:31:33 2015 +0000
- Revision:
- 0:eb6611fa99f5
made new functions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Dominik_2000 | 0:eb6611fa99f5 | 1 | #include "mbed.h" |
Dominik_2000 | 0:eb6611fa99f5 | 2 | #include "const.h" |
Dominik_2000 | 0:eb6611fa99f5 | 3 | #include "Robot.h" |
Dominik_2000 | 0:eb6611fa99f5 | 4 | |
Dominik_2000 | 0:eb6611fa99f5 | 5 | Robot bertl; |
Dominik_2000 | 0:eb6611fa99f5 | 6 | |
Dominik_2000 | 0:eb6611fa99f5 | 7 | void Bewegen() |
Dominik_2000 | 0:eb6611fa99f5 | 8 | { |
Dominik_2000 | 0:eb6611fa99f5 | 9 | bertl.Move(); |
Dominik_2000 | 0:eb6611fa99f5 | 10 | } |
Dominik_2000 | 0:eb6611fa99f5 | 11 | |
Dominik_2000 | 0:eb6611fa99f5 | 12 | void LinksDrehen() |
Dominik_2000 | 0:eb6611fa99f5 | 13 | { |
Dominik_2000 | 0:eb6611fa99f5 | 14 | bertl.TurnLeft(); |
Dominik_2000 | 0:eb6611fa99f5 | 15 | } |
Dominik_2000 | 0:eb6611fa99f5 | 16 | |
Dominik_2000 | 0:eb6611fa99f5 | 17 | void RoteViererLeds(int value) |
Dominik_2000 | 0:eb6611fa99f5 | 18 | { |
Dominik_2000 | 0:eb6611fa99f5 | 19 | bertl.NibbleLeds(value); |
Dominik_2000 | 0:eb6611fa99f5 | 20 | } |
Dominik_2000 | 0:eb6611fa99f5 | 21 | |
Dominik_2000 | 0:eb6611fa99f5 | 22 | void LedEinschalten(int16_t led) |
Dominik_2000 | 0:eb6611fa99f5 | 23 | { |
Dominik_2000 | 0:eb6611fa99f5 | 24 | bertl.TurnLedOn(led); |
Dominik_2000 | 0:eb6611fa99f5 | 25 | } |
Dominik_2000 | 0:eb6611fa99f5 | 26 | |
Dominik_2000 | 0:eb6611fa99f5 | 27 | void LedAusschalten(int16_t led) |
Dominik_2000 | 0:eb6611fa99f5 | 28 | { |
Dominik_2000 | 0:eb6611fa99f5 | 29 | bertl.TurnLedOff(led); |
Dominik_2000 | 0:eb6611fa99f5 | 30 | } |
Dominik_2000 | 0:eb6611fa99f5 | 31 | |
Dominik_2000 | 0:eb6611fa99f5 | 32 | void RotGruenBlauLed(bool red, bool green, bool blue) |
Dominik_2000 | 0:eb6611fa99f5 | 33 | { |
Dominik_2000 | 0:eb6611fa99f5 | 34 | bertl.RGBLed(red, green, blue); |
Dominik_2000 | 0:eb6611fa99f5 | 35 | } |
Dominik_2000 | 0:eb6611fa99f5 | 36 | |
Dominik_2000 | 0:eb6611fa99f5 | 37 | void BlaueLedsAusschalten() |
Dominik_2000 | 0:eb6611fa99f5 | 38 | { |
Dominik_2000 | 0:eb6611fa99f5 | 39 | bertl.BlueLedsOFF(); |
Dominik_2000 | 0:eb6611fa99f5 | 40 | } |
Dominik_2000 | 0:eb6611fa99f5 | 41 | |
Dominik_2000 | 0:eb6611fa99f5 | 42 | void BlaueLedsEinschalten() |
Dominik_2000 | 0:eb6611fa99f5 | 43 | { |
Dominik_2000 | 0:eb6611fa99f5 | 44 | bertl.BlueLedsON(); |
Dominik_2000 | 0:eb6611fa99f5 | 45 | } |
Dominik_2000 | 0:eb6611fa99f5 | 46 | |
Dominik_2000 | 0:eb6611fa99f5 | 47 | bool WartBisKnopfGedrueckt() |
Dominik_2000 | 0:eb6611fa99f5 | 48 | { |
Dominik_2000 | 0:eb6611fa99f5 | 49 | return bertl.WaitUntilButtonPressed(); |
Dominik_2000 | 0:eb6611fa99f5 | 50 | } |
Dominik_2000 | 0:eb6611fa99f5 | 51 | |
Dominik_2000 | 0:eb6611fa99f5 | 52 | bool IstVorneFrei() |
Dominik_2000 | 0:eb6611fa99f5 | 53 | { |
Dominik_2000 | 0:eb6611fa99f5 | 54 | return bertl.FrontIsClear(); |
Dominik_2000 | 0:eb6611fa99f5 | 55 | } |
Dominik_2000 | 0:eb6611fa99f5 | 56 | |
Dominik_2000 | 0:eb6611fa99f5 | 57 | bool NebenEinemPipser() |
Dominik_2000 | 0:eb6611fa99f5 | 58 | { |
Dominik_2000 | 0:eb6611fa99f5 | 59 | return bertl.NextToABeeper(); |
Dominik_2000 | 0:eb6611fa99f5 | 60 | } |
Dominik_2000 | 0:eb6611fa99f5 | 61 | |
Dominik_2000 | 0:eb6611fa99f5 | 62 | bool IstKnopfGedrueckt(const int btn) |
Dominik_2000 | 0:eb6611fa99f5 | 63 | { |
Dominik_2000 | 0:eb6611fa99f5 | 64 | return bertl.IsButtonPressed(btn); |
Dominik_2000 | 0:eb6611fa99f5 | 65 | } |
Dominik_2000 | 0:eb6611fa99f5 | 66 | |
Dominik_2000 | 0:eb6611fa99f5 | 67 | int GebeGedruektenKnopfZuruek() |
Dominik_2000 | 0:eb6611fa99f5 | 68 | { |
Dominik_2000 | 0:eb6611fa99f5 | 69 | return bertl.ReturnButtonPressed(); |
Dominik_2000 | 0:eb6611fa99f5 | 70 | } |
Dominik_2000 | 0:eb6611fa99f5 | 71 | |
Dominik_2000 | 0:eb6611fa99f5 | 72 | int main() |
Dominik_2000 | 0:eb6611fa99f5 | 73 | { |
Dominik_2000 | 0:eb6611fa99f5 | 74 | Bewegen(); |
Dominik_2000 | 0:eb6611fa99f5 | 75 | LinksDrehen(); |
Dominik_2000 | 0:eb6611fa99f5 | 76 | RoteViererLeds(4); |
Dominik_2000 | 0:eb6611fa99f5 | 77 | LedEinschalten(LED_FR1); |
Dominik_2000 | 0:eb6611fa99f5 | 78 | LedAusschalten(LED_FR1); |
Dominik_2000 | 0:eb6611fa99f5 | 79 | RotGruenBlauLed(1, 1, 1); |
Dominik_2000 | 0:eb6611fa99f5 | 80 | BlaueLedsAusschalten(); |
Dominik_2000 | 0:eb6611fa99f5 | 81 | BlaueLedsEinschalten(); |
Dominik_2000 | 0:eb6611fa99f5 | 82 | WartBisKnopfGedrueckt(); |
Dominik_2000 | 0:eb6611fa99f5 | 83 | IstVorneFrei(); |
Dominik_2000 | 0:eb6611fa99f5 | 84 | NebenEinemPipser(); |
Dominik_2000 | 0:eb6611fa99f5 | 85 | NebenEinemPipser(); |
Dominik_2000 | 0:eb6611fa99f5 | 86 | IstKnopfGedrueckt(BTN_BM); |
Dominik_2000 | 0:eb6611fa99f5 | 87 | GebeGedruektenKnopfZuruek(); |
Dominik_2000 | 0:eb6611fa99f5 | 88 | } |