driveAngle.pupil.c
/*******************************************************************************
* examples/driveAngle.pupil.c *
* =========================== *
* *
* Version: 1.0.5 *
* Date : 10.11.17 *
* Author : Peter Weissig *
* *
* The mode of TUCBot can only be changed if the programm is compiled with the *
* pupils version of the TUC-Bot library! *
* *
* If you are changing this file, you may also consider to update *
* demos/diagnosticTool/diagnosticTool.c *
*******************************************************************************/
//*********************************<Included files>*****************************
#include <tucbot/tucbot.h>
//*********************************<Methods>************************************
void testDriveAngle_pupil(void);
int main(void);
//*********************************[testDriveAngle_pupil]***********************
void testDriveAngle_pupil(void) {
uint8_t menu_pos = 0;
uint8_t flag_redraw_menu = 0xFF;
lcdclr();
lcdstr_p(PSTR("Drive-Angle " ));
while (1) {
// redraw menu
if (flag_redraw_menu) {
flag_redraw_menu = 0x00;
lcdxy(0,1);
switch (menu_pos) {
case 0:
lcdstr_p(PSTR("a= 30" "\xDF" " v= 10" "\xDF" "/s"));
break;
case 1:
lcdstr_p(PSTR("a= 90" "\xDF" " v= 30" "\xDF" "/s"));
break;
default:
lcdstr_p(PSTR("a= 360" "\xDF" " v= 90" "\xDF" "/s"));
menu_pos = 2;
break;
}
}
// check if buttons were pushed
// middle button --> increase menu
mdelay(100);
menu_pos++;
if (menu_pos > 2) {menu_pos = 0;}
flag_redraw_menu = 0xFF;
mdelay(400);
} else {
// right button --> start driving
mdelay(100);
lcdxy(0,1); lcdstr_p(PSTR("a:##### v:#####"));
mdelay(800);
switch (menu_pos) {
case 0 : drive_angle( 30,10); break;
case 1 : drive_angle( 90,30); break;
default: drive_angle(360,90); break;
}
while (1) {
// wait until driving is done
break;
}
}
lcdxy(11,1);
}
lcdxy(2,1);
}
mdelay(100);
}
flag_redraw_menu = 0xFF;
}
}
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testDriveAngle_pupil();
return (0);
}
leds_set
void leds_set(eLedMask bitmask, uint8_t bool)
Sets the selected leds on or off.
buttons_get
eButtonMask buttons_get(eButtonMask bitmask)
Returns the last stored value of the selected buttons.
kButtonMiddle
@ kButtonMiddle
bit mask (0x08): middle button
Definition: buttons.h:35
drive_angle
void drive_angle(int16_t angle, int16_t speed)
Lets the robot turn for an angle.
kDriveCommandDone
@ kDriveCommandDone
constant (0): no driving
Definition: drive.h:43
kLedOn
@ kLedOn
constant (0xFF): turn leds on
Definition: leds.h:63
kLedRight
@ kLedRight
bit mask (0x04): right led
Definition: leds.h:46
kDriveSelectState
@ kDriveSelectState
Definition: drive.h:120
kModePupil
@ kModePupil
constant (0): robot is in pupil mode
Definition: mode.h:29
drive_received
eDriveSelectMask drive_received(eDriveSelectMask bitmask)
Indicates if new data for the selected data blocks were received.
kDriveGetSpeedAngle
@ kDriveGetSpeedAngle
constant ( 4): current angular speed in degrees/s
Definition: drive.h:197
kButtonRight
@ kButtonRight
bit mask (0x10): right button
Definition: buttons.h:37
drive_request
void drive_request(eDriveSelectMask bitmask, eRequestType request)
Requests new data from the drive module.
buttons_request
void buttons_request(eRequestType request)
Requests new data from the buttons.
int16tostr
void int16tostr(void *out, int16_t number, uint8_t digits)
Converts an integer to a string and passes it to an output function.
drive_changed
eDriveSelectMask drive_changed(eDriveSelectMask bitmask)
Indicates if new data changed the selected data blocks.
drive_get
int16_t drive_get(eDriveGet select)
Returns the last stored version of the selected value.
kDriveSelectPosition
@ kDriveSelectPosition
Definition: drive.h:123
kLedLeft
@ kLedLeft
bit mask (0x10): left led
Definition: leds.h:42
kRequestContinuous
@ kRequestContinuous
constant (3): request continuous updates
Definition: update.h:37
kLedMiddle
@ kLedMiddle
bit mask (0x08): middle led
Definition: leds.h:44
kLedOff
@ kLedOff
constant (0x00): turn leds off
Definition: leds.h:61
kDriveSelectSpeed
@ kDriveSelectSpeed
Definition: drive.h:126
lcdclr
void lcdclr(void)
Clears the display.
kDriveGetCommand
@ kDriveGetCommand
Definition: drive.h:199
lcdxy
void lcdxy(uint8_t x, uint8_t y)
Moves the cursor to a postion on the display.
mode_set
void mode_set(eMode mode)
Sets the mode of the TUC-Bot.
kDriveSelectAll
@ kDriveSelectAll
Definition: drive.h:129
lcdstr_p
void lcdstr_p(const char *send_data)
Writes a string located in the flash to the display.
lcdout
void lcdout(uint8_t data)
Writes one byte to the display.
init_tucbot
void init_tucbot(uint8_t enable_interrupts)
Initiates the TUC-Bot.
mdelay
void mdelay(uint16_t mseconds)
Waits for the given time in milliseconds.
kDriveGetError
@ kDriveGetError
Definition: drive.h:202
kDriveGetPositionAngle
@ kDriveGetPositionAngle
constant ( 2): turned angle in degrees
Definition: drive.h:193