Modules | Enumerations | Functions

Functions which handle the buttons. More...

Modules

 Advanced informations
 

Enumerations

enum  eButtonMask
 clusters bit masks for reading the buttons More...
 

Functions

eButtonMask buttons_wait (eButtonMask bitmask)
 Returns the last pushed and released button. More...
 

Request Funktions

void buttons_request (eRequestType request)
 Requests new data from the buttons. More...
 
uint8_t buttons_received (void)
 Indicates if new data for the data block sButton was received. More...
 
uint8_t buttons_changed (void)
 Indicates if new data changed the data block sButton. More...
 

Access Funktions

eButtonMask buttons_get (eButtonMask bitmask)
 Returns the last stored value of the selected buttons. More...
 

Detailed Description

Functions which handle the buttons.

example

/*******************************************************************************
* examples/button.c *
* ================= *
* *
* Version: 1.0.3 *
* Date : 01.11.17 *
* Author : Peter Weissig *
*******************************************************************************/
//*********************************<Included files>*****************************
#include <tucbot/tucbot.h>
//*********************************[testButton]*********************************
void testButton(void) {
while (1) {
mdelay(50);
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testButton();
return (0);
}

Enumeration Type Documentation

◆ eButtonMask

clusters bit masks for reading the buttons

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

See also
buttons_wait()
Enumerator
kButtonNone 

bit mask (0x00): no buttons

kButtonLeft 

bit mask (0x04): left button

kButtonMiddle 

bit mask (0x08): middle button

kButtonRight 

bit mask (0x10): right button

kButtonAll 

bit mask (0x1C): all buttons

Function Documentation

◆ buttons_changed()

uint8_t buttons_changed ( void  )

Indicates if new data changed the data block sButton.

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
buttons_received(), buttons_request() and buttons_get()

◆ buttons_get()

eButtonMask buttons_get ( eButtonMask  bitmask)

Returns the last stored value of the selected buttons.

This function relies on the internal data block sButton - for new data use buttons_request().

Parameters
bitmaskbit mask of the selected buttons - see also eButtonMask
The parameter is used to only return the state of the selected buttons. All other states(bits) are set to 0.
Returns
bitfield of the pushed buttons - see also eButtonMask
If a button is pushed its related bit will be 1, otherwise 0.
If only one button is selected the return value can be interpreted as a boolean expression.
See also
buttons_request(), buttons_received() and buttons_changed()
Examples
beeper.c, button.c, cyclic.c, driveAdjust.pupil.c, driveAngle.pupil.c, driveArc.pupil.c, driveDist.pupil.c, encoderComplex.c, encoderSimple.c, imu.c, lausTracker.c, lineComplex.c, mode.c, motorComplex.c, motorSimple.c, packedCom.c, remoteControl.c, servo.c, sharp.c, twi.c, and uart.c.

◆ buttons_received()

uint8_t buttons_received ( void  )

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

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
buttons_changed(), buttons_request() and buttons_get()

◆ buttons_request()

void buttons_request ( eRequestType  request)

◆ buttons_wait()

eButtonMask buttons_wait ( eButtonMask  bitmask)

Returns the last pushed and released button.

This function will return if exactly one button was pushed and released.

This function relies on the internal data block sButton - but it will automatically request the variable itself.

Parameters
bitmaskbit mask of the selected buttons - see also eButtonMask
The parameter is used to select which buttons are monitored. If no button is selected the function will return kButtonNone immediately.
Returns
value of the last pushed and released button - see also eButtonMask
This is not a bit mask - only one value can be returned.
See also
buttons_request(), buttons_received() and buttons_changed()
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
kLedRight
@ kLedRight
bit mask (0x04): right led
Definition: leds.h:46
kButtonRight
@ kButtonRight
bit mask (0x10): right button
Definition: buttons.h:37
buttons_request
void buttons_request(eRequestType request)
Requests new data from the buttons.
kButtonLeft
@ kButtonLeft
bit mask (0x04): left button
Definition: buttons.h:33
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
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.