mode.c
/*******************************************************************************
* examples/mode.c *
* =============== *
* *
* Version: 1.0.4 *
* Date : 01.11.17 *
* Author : Peter Weissig *
* *
* The mode can only be set to pupils mode 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 testMode(void);
int main(void);
//*********************************[testMode]***********************************
void testMode(void) {
lcdclr();
lcdstr_p(PSTR("Mode" ));
lcdxy(0,1);
lcdstr_p(PSTR("####### <c> <u> "));
while (1) {
mdelay(100);
if (mode_get() == kModePupil) {
} else {
}
mdelay(400);
} else if (buttons_get(kButtonRight)) {
mdelay(100);
}
if (mode_received()) {
lcdxy(0,1);
switch (mode_get()) {
case kModePupil : lcdstr_p(PSTR("Pupil " )); break;
case kModeStudent: lcdstr_p(PSTR("Student" )); break;
default : lcdstr_p(PSTR("#######" )); break;
}
}
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testMode();
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
kModeStudent
@ kModeStudent
constant (1): robot is in student mode
Definition: mode.h:31
kLedOn
@ kLedOn
constant (0xFF): turn leds on
Definition: leds.h:63
kLedRight
@ kLedRight
bit mask (0x04): right led
Definition: leds.h:46
kModePupil
@ kModePupil
constant (0): robot is in pupil mode
Definition: mode.h:29
kButtonRight
@ kButtonRight
bit mask (0x10): right button
Definition: buttons.h:37
mode_get
eMode mode_get(void)
Returns the last stored mode of the TUC-Bot.
buttons_request
void buttons_request(eRequestType request)
Requests new data from the buttons.
kRequestContinuous
@ kRequestContinuous
constant (3): request continuous updates
Definition: update.h:37
mode_request
void mode_request(eRequestType request)
Requests new data from the mode of the TUC-Bot.
kLedMiddle
@ kLedMiddle
bit mask (0x08): middle led
Definition: leds.h:44
kLedOff
@ kLedOff
constant (0x00): turn leds off
Definition: leds.h:61
lcdclr
void lcdclr(void)
Clears the display.
lcdxy
void lcdxy(uint8_t x, uint8_t y)
Moves the cursor to a postion on the display.
kRequestSingle
@ kRequestSingle
constant (1): request a single update
Definition: update.h:33
mode_set
void mode_set(eMode mode)
Sets the mode of the TUC-Bot.
mode_received
uint8_t mode_received(void)
Indicates if new data for the data block sMD_Mode was received.
lcdstr_p
void lcdstr_p(const char *send_data)
Writes a string located in the flash 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.