Leds work simultanously. Version 3.1

Dependencies:   HCSR

Dependents:   bertl_led bertl_led bertl_led bertl_led ... more

Fork of Bertl by Bertl_Team_PE

BULME HTL Graz-Gösting

FSST - Hardwarenahe Programmierung

Created by Prof.Dr. Franz Pucher

Inhalt

Inhalt

Start mit folgendem Code in main.cpp eines neuen Projektes mbed_blinky:

#include "mbed.h"
#include "const.h"
#include "Robot.h"

Robot bertl;
    
int main()
{
    bertl.NibbleLeds(0x0F);
    wait(1);
    bertl.NibbleLeds(0x00);
    
    while(1)
    {
        if(bertl.IsButtonPressed(BTN_BL))
        {
            bertl.TurnLedOn(LED_BL1);
        }
        if(bertl.IsButtonPressed(BTN_BR))
        {
            bertl.TurnLedOff(LED_BL1);
        }
    }
}
Committer:
fpucher
Date:
Fri Feb 19 15:28:42 2016 +0000
Revision:
18:e9bb4513ae3a
Parent:
8:07e55b300ff1
Version 3.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bulmecisco 8:07e55b300ff1 1 /***********************************
bulmecisco 8:07e55b300ff1 2 name: Robot.cpp Version: 1.0
bulmecisco 8:07e55b300ff1 3 author: PE HTL BULME
bulmecisco 8:07e55b300ff1 4 email: pe@bulme.at
bulmecisco 8:07e55b300ff1 5 WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/
bulmecisco 8:07e55b300ff1 6 description:
bulmecisco 8:07e55b300ff1 7 Implementation Robot for objectivRobot
bulmecisco 8:07e55b300ff1 8
bulmecisco 8:07e55b300ff1 9 The following lines have to be added or changed to the *.kpp file:
bulmecisco 8:07e55b300ff1 10
bulmecisco 8:07e55b300ff1 11 #include "Robot.h"
bulmecisco 8:07e55b300ff1 12 #include "mbed.h"
bulmecisco 8:07e55b300ff1 13 #include "const.h"
bulmecisco 8:07e55b300ff1 14
bulmecisco 8:07e55b300ff1 15 class Bertl : public Robot // public
bulmecisco 8:07e55b300ff1 16 {
bulmecisco 8:07e55b300ff1 17 public:
bulmecisco 8:07e55b300ff1 18 Bertl(int x, int y, int d, int b){}; // dumy constrctor with same name as the class name
bulmecisco 8:07e55b300ff1 19
bulmecisco 8:07e55b300ff1 20 rest as in KPP-file:
bulmecisco 8:07e55b300ff1 21 see in objectBertl/projects/L1_Ex1.KPP
bulmecisco 8:07e55b300ff1 22
bulmecisco 8:07e55b300ff1 23 ***********************************/
bulmecisco 8:07e55b300ff1 24 #include "mbed.h"
bulmecisco 8:07e55b300ff1 25 #include "Robot.h"
bulmecisco 8:07e55b300ff1 26 #include "ur_Bertl.h"
bulmecisco 8:07e55b300ff1 27
bulmecisco 8:07e55b300ff1 28 //Robot::Robot(int x, int y, char[] dir, int beeper) : ur_Robot(){}
bulmecisco 8:07e55b300ff1 29
bulmecisco 8:07e55b300ff1 30 void Robot :: move() // Definieren
bulmecisco 8:07e55b300ff1 31 {
bulmecisco 8:07e55b300ff1 32 Move();
bulmecisco 8:07e55b300ff1 33 }
bulmecisco 8:07e55b300ff1 34
bulmecisco 8:07e55b300ff1 35 void Robot :: turnLeft()
bulmecisco 8:07e55b300ff1 36 {
bulmecisco 8:07e55b300ff1 37 TurnLeft();
bulmecisco 8:07e55b300ff1 38 }
bulmecisco 8:07e55b300ff1 39
bulmecisco 8:07e55b300ff1 40 void Robot :: pickBeeper()
bulmecisco 8:07e55b300ff1 41 {
bulmecisco 8:07e55b300ff1 42 PickBeeper();
bulmecisco 8:07e55b300ff1 43 }
bulmecisco 8:07e55b300ff1 44
bulmecisco 8:07e55b300ff1 45 void Robot :: putBeeper()
bulmecisco 8:07e55b300ff1 46 {
bulmecisco 8:07e55b300ff1 47 PutBeeper();
bulmecisco 8:07e55b300ff1 48 }
bulmecisco 8:07e55b300ff1 49
bulmecisco 8:07e55b300ff1 50 bool Robot :: frontIsClear()
bulmecisco 8:07e55b300ff1 51 {
bulmecisco 8:07e55b300ff1 52 return FrontIsClear();
bulmecisco 8:07e55b300ff1 53 }
bulmecisco 8:07e55b300ff1 54
bulmecisco 8:07e55b300ff1 55 bool Robot :: nextToABeeper() //is there one or more beepers in the same corner?
bulmecisco 8:07e55b300ff1 56 {
bulmecisco 8:07e55b300ff1 57 return NextToABeeper();
bulmecisco 8:07e55b300ff1 58 }
bulmecisco 8:07e55b300ff1 59 bool Robot :: nextToARobot() //is there another robot in the corner?
bulmecisco 8:07e55b300ff1 60 {
bulmecisco 8:07e55b300ff1 61 return false;
bulmecisco 8:07e55b300ff1 62 }
bulmecisco 8:07e55b300ff1 63 bool Robot :: facingNorth() //is the robot facing North?
bulmecisco 8:07e55b300ff1 64 {
bulmecisco 8:07e55b300ff1 65 return true;
bulmecisco 8:07e55b300ff1 66 }
bulmecisco 8:07e55b300ff1 67 bool Robot :: facingSouth() // is the robot facing South?
bulmecisco 8:07e55b300ff1 68 {
bulmecisco 8:07e55b300ff1 69 return true;
bulmecisco 8:07e55b300ff1 70 }
bulmecisco 8:07e55b300ff1 71 bool Robot :: facingEast() // is the robot facing East?
bulmecisco 8:07e55b300ff1 72 {
bulmecisco 8:07e55b300ff1 73 return true;
bulmecisco 8:07e55b300ff1 74 }
bulmecisco 8:07e55b300ff1 75 bool Robot :: facingWest() // is the robot facing West?
bulmecisco 8:07e55b300ff1 76 {
bulmecisco 8:07e55b300ff1 77 return true;
bulmecisco 8:07e55b300ff1 78 }
bulmecisco 8:07e55b300ff1 79 bool Robot :: anyBeepersInBeeperBag() //are there any beepers in the bag?
bulmecisco 8:07e55b300ff1 80 {
bulmecisco 8:07e55b300ff1 81 return AnyBeeperInBag();
bulmecisco 8:07e55b300ff1 82 }