Modules | Enumerations

Functions which handle the library mode. More...

Modules

 Advanced informations
 

Enumerations

enum  eMode
 clusters the states of the mode More...
 

Request Funktions

void mode_request (eRequestType request)
 Requests new data from the mode of the TUC-Bot. More...
 
uint8_t mode_received (void)
 Indicates if new data for the data block sMD_Mode was received. More...
 
uint8_t mode_changed (void)
 Indicates if new data changed the data block sMD_Mode. More...
 
uint8_t mode_transmitted (void)
 Indicates if the data block sMD_Mode was transmitted. More...
 

Access Funktions

eMode mode_get (void)
 Returns the last stored mode of the TUC-Bot. More...
 
void mode_set (eMode mode)
 Sets the mode of the TUC-Bot. More...
 

Detailed Description

Functions which handle the library mode.

The mode can only be set to pupils mode if the programm is compiled with the pupils version of the TUC-Bot library!

See also mode_set().

example

/*******************************************************************************
* 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);
}

Enumeration Type Documentation

◆ eMode

enum eMode

clusters the states of the mode

See also
mode_get() and mode_set()
Enumerator
kModePupil 

constant (0): robot is in pupil mode

kModeStudent 

constant (1): robot is in student mode

Function Documentation

◆ mode_changed()

uint8_t mode_changed ( void  )

Indicates if new data changed the data block sMD_Mode.

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
mode_received(), mode_request() and mode_get()

◆ mode_get()

eMode mode_get ( void  )

Returns the last stored mode of the TUC-Bot.

This function relies on the internal data block sMD_Mode - for new data use mode_request().

Returns
value representing the current mode - see also eMode
See also
mode_request() and mode_set()
Examples
mode.c.

◆ mode_received()

uint8_t mode_received ( void  )

Indicates if new data for the data block sMD_Mode was received.

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
mode_changed(), mode_request() and mode_get()
Examples
mode.c.

◆ mode_request()

void mode_request ( eRequestType  request)

Requests new data from the mode of the TUC-Bot.

For details on the request schema see The general request.

Involved data blocks are:
sMD_Mode

Parameters
requestSee also eRequestType
See also
mode_get()
Examples
mode.c.

◆ mode_set()

void mode_set ( eMode  mode)

Sets the mode of the TUC-Bot.

This function changes the internal data block sMD_Mode.

Parameters
modevalue representing the current mode - see also eMode
See also
mode_transmitted() and mode_get()
Examples
driveAdjust.pupil.c, driveAngle.pupil.c, driveArc.pupil.c, driveDist.pupil.c, encoderComplex.c, mode.c, motorComplex.c, motorSimple.c, and remoteControl.c.

◆ mode_transmitted()

uint8_t mode_transmitted ( void  )

Indicates if the data block sMD_Mode was transmitted.

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
mode_set()
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.