Modules | Enumerations
Bumpers

Functions which handle the bumper sensors. More...

Modules

 Advanced informations
 

Enumerations

enum  eBumperMask
 clusters bit masks for reading the bumpers More...
 

Request Funktions

void bumpers_request (eRequestType request)
 Requests new data from the bumpers. More...
 
uint8_t bumpers_received (void)
 Indicates if new data for the data block sMD_Bumper was received. More...
 
uint8_t bumpers_changed (void)
 Indicates if new data changed the data block sMD_Bumper. More...
 

Access Funktions

eBumperMask bumpers_get (eBumperMask bitmask)
 Returns the last stored value of the masked bumpers. More...
 

Detailed Description

Functions which handle the bumper sensors.

example

/*******************************************************************************
* examples/bumper.c *
* ================= *
* *
* Version: 1.0.6 *
* Date : 06.12.17 *
* Author : Peter Weissig *
* *
* If you are changing this file, you may also consider to update *
* demos/diagnosticTool/diagnosticTool.c *
*******************************************************************************/
//*********************************<Included files>*****************************
#include <tucbot/tucbot.h>
//*********************************<Methods>************************************
void testBumper(void);
int main(void);
//*********************************[testBumper]*********************************
void testBumper(void) {
uint8_t bumpers;
lcdclr();
lcdstr_p(PSTR("Bumper" ));
lcdxy(0,1);
lcdstr_p(PSTR("F: # # B: # # "));
while (1) {
if (bumpers_changed()) {
bumpers = bumpers_get(kBumperAll);
lcdxy( 3,1);
if (bumpers & kBumperFrontLeft ) {lcdout('L'); }
else {lcdout(' ');}
lcdxy( 5,1);
if (bumpers & kBumperFrontRight) {lcdout('R'); }
else {lcdout(' ');}
lcdxy(11,1);
if (bumpers & kBumperBackLeft ) {lcdout('L'); }
else {lcdout(' ');}
lcdxy(13,1);
if (bumpers & kBumperBackRight ) {lcdout('R'); }
else {lcdout(' ');}
}
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testBumper();
return (0);
}

Enumeration Type Documentation

◆ eBumperMask

clusters bit masks for reading the bumpers

This enum is used for masking the bumpers in bumpers_get() and for storing that functions' result as a bitfield.

Enumerator
kBumperNone 

bit mask (0x00): no bumper

kBumperFrontLeft 

bit mask (0x01): the front left bumper

kBumperFrontRight 

bit mask (0x02): the front right bumper

kBumperBackLeft 

bit mask (0x04): the back left bumper

kBumperBackRight 

bit mask (0x08): the back right bumper

kBumperAll 

bit mask (0x0F): all bumpers

Function Documentation

◆ bumpers_changed()

uint8_t bumpers_changed ( void  )

Indicates if new data changed the data block sMD_Bumper.

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
bumpers_received(), bumpers_request() and bumpers_get()
Examples
bumper.c.

◆ bumpers_get()

eBumperMask bumpers_get ( eBumperMask  bitmask)

Returns the last stored value of the masked bumpers.

This function relies on the internal data block sMD_Bumper - for new data use bumpers_request().

Parameters
bitmaskbit mask of the selected bumpers - see also eBumperMask
The parameter is used to only return the state of the masked bumpers. All other states(bits) are set to 0.
Returns
bitfield of the pushed bumpers - see also eBumperMask
If a bumper is pushed its related bit will be 1, otherwise 0.
If only one bumper is selected the return value can be interpreted as a boolean expression.
See also
bumpers_request(), bumpers_received() and bumpers_changed()
Examples
bumper.c, and encoderComplex.c.

◆ bumpers_received()

uint8_t bumpers_received ( void  )

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

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
bumpers_changed(), bumpers_request() and bumpers_get()

◆ bumpers_request()

void bumpers_request ( eRequestType  request)

Requests new data from the bumpers.

For details on the request schema see The general request.

Involved data blocks are:
sMD_Bumper

Parameters
requestSee also eRequestType
See also
bumpers_get(), bumpers_received() and bumpers_changed()
Examples
bumper.c, and encoderComplex.c.
kBumperBackLeft
@ kBumperBackLeft
bit mask (0x04): the back left bumper
Definition: bumpers.h:36
kBumperFrontRight
@ kBumperFrontRight
bit mask (0x02): the front right bumper
Definition: bumpers.h:34
kRequestContinuous
@ kRequestContinuous
constant (3): request continuous updates
Definition: update.h:37
kBumperAll
@ kBumperAll
bit mask (0x0F): all bumpers
Definition: bumpers.h:40
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.
bumpers_request
void bumpers_request(eRequestType request)
Requests new data from the bumpers.
bumpers_changed
uint8_t bumpers_changed(void)
Indicates if new data changed the data block sMD_Bumper.
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.
kBumperBackRight
@ kBumperBackRight
bit mask (0x08): the back right bumper
Definition: bumpers.h:38
init_tucbot
void init_tucbot(uint8_t enable_interrupts)
Initiates the TUC-Bot.
bumpers_get
eBumperMask bumpers_get(eBumperMask bitmask)
Returns the last stored value of the masked bumpers.
kBumperFrontLeft
@ kBumperFrontLeft
bit mask (0x01): the front left bumper
Definition: bumpers.h:32