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

Embed: (wiki syntax)

« Back to documentation index

Bertl Class Reference

name: Bertl.h
version: 3.0
author:PE HTL BULME
email: pe@bulme.at
WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/wiki/Homepage
description: Definition and documentation portion of the class Bertl The Robot. More...

#include <ur_Bertl.h>

Inherits ur_Bertl.

Inherited by Robot.

Public Member Functions

int Move (int move=MOVE)
 Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()
int MoveBackwards (int move=MOVE)
 Robot moves as much back as the constant DISTANCE; if one of the buttons fire --> Error()
void TurnRight ()
 Robot turns Right as much as the constant ANGLE.
void TurnLeftStep (int step=STEPTIME)
 Robot turns left for a short time defined in STEPTIME.
void TurnRightStep (int step=STEPTIME)
 Robot turns Right for a short time defined in STEPTIME.
uint8_t GetLineValues ()
 in the lower 4 bit are the values of the line sensor
uint8_t GetLineValues5 ()
 Bertl15: lower 5 bit are the values of the line sensor.
void RGBLed (bool red, bool green, bool blue)
 RGB Led with red, green and blue component of the Color.
void Move ()
 Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()
void TurnLeft ()
 Robot turns left as much as the constant ANGLE.
void PutBeeper ()
 if Robot has any Beepers in his bag he can put one or more Beeper; if not --> Error(()
void PickBeeper ()
 if Robot stands on a black item he can pick one or more Beeper (max.
void TurnOff ()
 turnes the robot off
bool WaitUntilButtonPressed ()
 wait until any button is pressed at the robot
bool FrontIsClear ()
 returns a boolean value true if front is free; if not false
bool NextToABeeper ()
 returns a boolean value true if the robot is on a black place or line; if not --> false
bool IsButtonPressed (const int btn)
 returns true if Button btn is pressed, else false
int ReturnButtonPressed ()
 returns the int value of button pressed
int AnyBeeperInBag ()
 returns an int value (if > 0 equal true) how many beepers in bag; if zero --> false
void NibbleLeds (int value)
 methode for the 4 (half byte) yellow LEDs at the back left side; ie.
void TurnLedOn (int16_t led)
 turns the specified one or more LEDs ON; description and name in const.h, such as LED_FL1 = 0x01; front LED white
void TurnLedOff (int16_t led)
 turns the specified one or more LEDs OFF; description and name in const.h, such as LED_FL1 = 0x01; front LED white
void BlueLedsOFF ()
 OFF all blue LEDs which are on the same Port 1_28.
void BlueLedsON ()
 ON all blue LEDs which are on the same Port 1_28.

Protected Member Functions

void increment ()
 protected methodes for internal purposes only
bool backIsClear ()
 don't now for what
bool frontButtonPressed ()
 TRUE if a a button on the front of Robot is pressed else FALSE.
int bottomIsBlack ()
 check line sensor; returns BCD value
void error ()
 Error: stops the robot and all LEDs are blinking.

Protected Attributes

int beepersInBag
 how many beepers does the robot have in his bag;
you can show it with: karel.NibbleLeds(karel.AnyBeeperInBag())
char cmd [3]
 I2C command.
int16_t btns
 which button is pressed
InterruptIn _interrupt
 interrupted used
volatile int _count
 values of motor sensor
int16_t leds
 save led status

Detailed Description

name: Bertl.h
version: 3.0
author:PE HTL BULME
email: pe@bulme.at
WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/wiki/Homepage
description: Definition and documentation portion of the class Bertl The Robot.

//

Example motor sensor test:

#include "mbed.h"
#include "ur_Bertl.h"
#include "const.h"
 
int main()
{
    ur_Bertl karel(LEFTSENSOR);  // RIGHTSENSOR

    while(true) {
        karel.NibbleLeds(karel.Read());
    }
}

Example follow a line:

#include "mbed.h"
#include "ur_Bertl.h"
#include "const.h"

int main()
{
    Bertl karel;
    
    while(karel.WaitUntilButtonPressed())
    {
        karel.NibbleLeds(karel.GetLineValues());
        switch(karel.GetLineValues())
        {
        case 0x00:
            karel.TurnLeftStep(50);
            break;
        case 0x03: case 0x01: case 0x07:
            karel.TurnLeftStep(20);
            break;
        case 0x0E: case 0x0A: case 0x08:
            karel.TurnRightStep(20);
            break;
        default:
            karel.Move(20);
            break;
        }
        if(!karel.FrontIsClear())
            karel.TurnLeftStep(1000);
    }
}

Definition at line 239 of file ur_Bertl.h.


Member Function Documentation

int AnyBeeperInBag (  ) [inherited]

returns an int value (if > 0 equal true) how many beepers in bag; if zero --> false

Definition at line 256 of file ur_Bertl.cpp.

bool backIsClear (  ) [protected, inherited]

don't now for what

Definition at line 312 of file ur_Bertl.cpp.

void BlueLedsOFF (  ) [inherited]

OFF all blue LEDs which are on the same Port 1_28.

Definition at line 137 of file ur_Bertl.cpp.

void BlueLedsON (  ) [inherited]

ON all blue LEDs which are on the same Port 1_28.

Definition at line 132 of file ur_Bertl.cpp.

int bottomIsBlack (  ) [protected, inherited]

check line sensor; returns BCD value

Definition at line 304 of file ur_Bertl.cpp.

void error (  ) [protected, inherited]

Error: stops the robot and all LEDs are blinking.

Definition at line 359 of file ur_Bertl.cpp.

bool frontButtonPressed (  ) [protected, inherited]

TRUE if a a button on the front of Robot is pressed else FALSE.

Definition at line 334 of file ur_Bertl.cpp.

bool FrontIsClear (  ) [inherited]

returns a boolean value true if front is free; if not false

Definition at line 191 of file ur_Bertl.cpp.

uint8_t GetLineValues (  )

in the lower 4 bit are the values of the line sensor

Definition at line 514 of file ur_Bertl.cpp.

uint8_t GetLineValues5 (  )

Bertl15: lower 5 bit are the values of the line sensor.

Definition at line 522 of file ur_Bertl.cpp.

void increment (  ) [protected, inherited]

protected methodes for internal purposes only

ISR to increment sensor values of motor

Definition at line 381 of file ur_Bertl.cpp.

bool IsButtonPressed ( const int  btn ) [inherited]

returns true if Button btn is pressed, else false

Definition at line 264 of file ur_Bertl.cpp.

int Move ( int  move = MOVE )

Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()

Definition at line 414 of file ur_Bertl.cpp.

void Move (  ) [inherited]

Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()

Definition at line 50 of file ur_Bertl.cpp.

int MoveBackwards ( int  move = MOVE )

Robot moves as much back as the constant DISTANCE; if one of the buttons fire --> Error()

Definition at line 392 of file ur_Bertl.cpp.

bool NextToABeeper (  ) [inherited]

returns a boolean value true if the robot is on a black place or line; if not --> false

Definition at line 248 of file ur_Bertl.cpp.

void NibbleLeds ( int  value ) [inherited]

methode for the 4 (half byte) yellow LEDs at the back left side; ie.

you can show how many beeper a robot has in his bag with: karel.NibbleLeds(karel.AnyBeeperInBag())

Definition at line 184 of file ur_Bertl.cpp.

void PickBeeper (  ) [inherited]

if Robot stands on a black item he can pick one or more Beeper (max.

15 --> Error()); if not --> Error()

Definition at line 84 of file ur_Bertl.cpp.

void PutBeeper (  ) [inherited]

if Robot has any Beepers in his bag he can put one or more Beeper; if not --> Error(()

Definition at line 75 of file ur_Bertl.cpp.

int ReturnButtonPressed (  ) [inherited]

returns the int value of button pressed

Definition at line 286 of file ur_Bertl.cpp.

void RGBLed ( bool  red,
bool  green,
bool  blue 
)

RGB Led with red, green and blue component of the Color.

Reimplemented from ur_Bertl.

Definition at line 530 of file ur_Bertl.cpp.

void TurnLedOff ( int16_t  led ) [inherited]

turns the specified one or more LEDs OFF; description and name in const.h, such as LED_FL1 = 0x01; front LED white

Definition at line 167 of file ur_Bertl.cpp.

void TurnLedOn ( int16_t  led ) [inherited]

turns the specified one or more LEDs ON; description and name in const.h, such as LED_FL1 = 0x01; front LED white

Definition at line 149 of file ur_Bertl.cpp.

void TurnLeft (  ) [inherited]

Robot turns left as much as the constant ANGLE.

Definition at line 95 of file ur_Bertl.cpp.

void TurnLeftStep ( int  step = STEPTIME )

Robot turns left for a short time defined in STEPTIME.

Definition at line 490 of file ur_Bertl.cpp.

void TurnOff (  ) [inherited]

turnes the robot off

Definition at line 118 of file ur_Bertl.cpp.

void TurnRight (  )

Robot turns Right as much as the constant ANGLE.

Definition at line 440 of file ur_Bertl.cpp.

void TurnRightStep ( int  step = STEPTIME )

Robot turns Right for a short time defined in STEPTIME.

Definition at line 465 of file ur_Bertl.cpp.

bool WaitUntilButtonPressed (  ) [inherited]

wait until any button is pressed at the robot

Definition at line 225 of file ur_Bertl.cpp.


Field Documentation

volatile int _count [protected, inherited]

values of motor sensor

Definition at line 135 of file ur_Bertl.h.

InterruptIn _interrupt [protected, inherited]

interrupted used

Definition at line 134 of file ur_Bertl.h.

int beepersInBag [protected, inherited]

how many beepers does the robot have in his bag;
you can show it with: karel.NibbleLeds(karel.AnyBeeperInBag())

Definition at line 131 of file ur_Bertl.h.

int16_t btns [protected, inherited]

which button is pressed

Definition at line 133 of file ur_Bertl.h.

char cmd[3] [protected, inherited]

I2C command.

Definition at line 132 of file ur_Bertl.h.

int16_t leds [protected, inherited]

save led status

Definition at line 136 of file ur_Bertl.h.