Functions | |
| void | BackLED (_Bool left, _Bool right) |
| control the BackLEDs | |
| int | Battery (void) |
| read the battery power state | |
| void | EncoderInit (void) |
| initialise and starts odometry mesurement | |
| void | EncoderReset (void) |
| set odometry tick count to zero | |
| void | EncoderStart (void) |
| start counting odometry ticks | |
| void | EncoderStop (void) |
| stop counting odometry sensor ticks | |
| void | FrontLED (_Bool status) |
| control the FrontLED | |
| unsigned long | Gettime (void) |
| return time since system start in ms | |
| void | Init (void) |
| initialise the hardware | |
| void | LineData (unsigned int *data) |
| read out the phototransistors on the bottom | |
| void | MotorSpeed (unsigned char left_speed, unsigned char right_speed) |
| set motor speed | |
| void | MotorState (unsigned char left, unsigned char right) |
| set motor state | |
| void | mSleep (unsigned int ms) |
| sleep function (ms) | |
| void | OdometryData (unsigned int *data) |
| reads out the odometry phototransistors | |
| unsigned char | PollSwitch (void) |
| read the switches | |
| void | Rotate (int angle, unsigned char speed) |
| turn the robot using the odometry sensors | |
| void | SerRead (unsigned char *data, unsigned char length, unsigned int timeout) |
| recieve characters over the serial interface | |
| void | SerWrite (char *data, unsigned char length) |
| send characters over the serial interface | |
| void | Sleep (unsigned char time36kHz) |
| sleep function (36Khz) | |
| void | StartSwitch (void) |
| send interrupt on switch press | |
| void | StatusLED (unsigned char color) |
| control the StatusLED | |
| void | StopSwitch (void) |
| stop sending switch interrupt | |
| void | Travel (int distance, unsigned char speed) |
| move the robot forward/ backward | |
Variables | |
| unsigned char | encoder [2] |
| odometry sensors tick count | |
| volatile _Bool | sw_pressed |
| any switch pressed? | |
| void BackLED | ( | _Bool | left, | |
| _Bool | right | |||
| ) |
control the BackLEDs
values: ON, OFF
| left | leftLED status | |
| right | rightLED status |
| int Battery | ( | void | ) |
read the battery power state
| void EncoderInit | ( | void | ) |
| void EncoderReset | ( | void | ) |
set odometry tick count to zero
| void EncoderStart | ( | void | ) |
start counting odometry ticks
| void EncoderStop | ( | void | ) |
stop counting odometry sensor ticks
| void FrontLED | ( | _Bool | status | ) | [inline] |
control the FrontLED
| status | values: ON, OFF |
| unsigned long Gettime | ( | void | ) |
return time since system start in ms
| void Init | ( | void | ) |
initialise the hardware
initialise ports, ADC, PWM
this function must be called by every program at first
| void LineData | ( | unsigned int * | data | ) |
read out the phototransistors on the bottom
| data | pointer to the data destination. access: data[LEFT], data[RIGHT]. range 0..1023 |
| void MotorSpeed | ( | unsigned char | left_speed, | |
| unsigned char | right_speed | |||
| ) | [inline] |
set motor speed
value range: 0..255
| left_speed | left motor | |
| right_speed | right motor |
| void MotorState | ( | unsigned char | left, | |
| unsigned char | right | |||
| ) | [inline] |
set motor state
values: FWD, RWD, BREAK, FREE
| left | left motor | |
| right | right motor |
| void mSleep | ( | unsigned int | ms | ) |
sleep function (ms)
| ms | time in ms |
| void OdometryData | ( | unsigned int * | data | ) |
reads out the odometry phototransistors
| data | pointer to an array. access: data[LEFT], data[RIGHT] |
| unsigned char PollSwitch | ( | void | ) |
read the switches
| void Rotate | ( | int | angle, | |
| unsigned char | speed | |||
| ) |
turn the robot using the odometry sensors
| angle | degrees to turn. positive = turn right, negative = turn left. range: -360..360 | |
| speed | motor speed. range: 0..255 |
| void SerRead | ( | unsigned char * | data, | |
| unsigned char | length, | |||
| unsigned int | timeout | |||
| ) |
recieve characters over the serial interface
| data | pointer to the destination array | |
| length | character count | |
| timeout | 0 = blocking mode |
| void SerWrite | ( | char * | data, | |
| unsigned char | length | |||
| ) |
send characters over the serial interface
| data | string-pointer | |
| length | character count |
| void Sleep | ( | unsigned char | time36kHz | ) |
sleep function (36Khz)
| time36kHz | time in 1/36k (sec) |
| void StartSwitch | ( | void | ) |
send interrupt on switch press
binds switch press to external Interrupt 1
catch it with ISR(INT1_vect)
see avr-libc documentation for details
| void StatusLED | ( | unsigned char | color | ) | [inline] |
control the StatusLED
| color | values: OFF, GREEN, RED, YELLOW |
| void StopSwitch | ( | void | ) |
| void Travel | ( | int | distance, | |
| unsigned char | speed | |||
| ) |
move the robot forward/ backward
| distance | travalling distance in cm. positive = forward, negative = backward | |
| speed | motor speed. range: 0..255 |
| unsigned char encoder[2] |
odometry sensors tick count
access: encoder[LEFT], encoder[RIGHT]
range: 0..255
| volatile _Bool sw_pressed |
any switch pressed?
is being set to TRUE by interrupt if a switch is pressed
remember to set it to false again, since it is not reset automatically
1.4.7