Modules | Enumerations
Tsops

Functions which handle the IR-beacon sensors. More...

Modules

 Advanced informations
 

Enumerations

enum  eTsop
 clusters the states of the beacon sensors More...
 
enum  eTsopGet
 clusters select values for reading the beacon measurements More...
 

Request Funktions

void tsops_request (eRequestType request)
 Requests new data from the tsop sensors. More...
 
uint8_t tsops_received (void)
 Indicates if new data for the data block sTsop was received. More...
 
uint8_t tsops_changed (void)
 Indicates if new data changed the data block sTsop. More...
 

Access Funktions

eTsop tsops_get (eTsopGet select)
 Returns the last stored value of the selected tsop sensor. More...
 

Detailed Description

Functions which handle the IR-beacon sensors.

example

/*******************************************************************************
* examples/tsop.c *
* =============== *
* *
* Version: 1.0.5 *
* Date : 09.11.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>************************************
char testTsop_convert(uint8_t tsop_state);
void testTsop(void);
int main(void);
//*********************************[testTsop_convert]***************************
char testTsop_convert(enum eTsop tsop_state) {
switch (tsop_state) {
case kTsopNone : return '-'; break;
case kTsopGreen : return 'G'; break;
case kTsopNeutral: return 'N'; break;
case kTsopRed : return 'R'; break;
case kTsopError : return '!'; break;
default : return '?'; break;
}
}
//*********************************[testTsop]***********************************
void testTsop(void) {
enum eTsop value;
enum eTsop old_left = kTsopNone;
enum eTsop old_middle = kTsopNone;
enum eTsop old_right = kTsopNone;
lcdclr();
lcdstr_p(PSTR("TSOP" ));
lcdxy(0,1);
lcdstr_p(PSTR("L: -; M: -; R: -"));
while (1) {
if (value != old_left) {
old_left = value;
lcdxy( 3,1);
lcdout(testTsop_convert(value));
}
if (value != old_middle) {
old_middle = value;
lcdxy( 9,1);
lcdout(testTsop_convert(value));
}
if (value != old_right) {
old_right = value;
lcdxy(15,1);
lcdout(testTsop_convert(value));
}
mdelay(100);
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testTsop();
return (0);
}

Enumeration Type Documentation

◆ eTsop

enum eTsop

clusters the states of the beacon sensors

See also
tsops_get()
Enumerator
kTsopNone 

constant (0): no signal

kTsopGreen 

constant (1): green signal

kTsopNeutral 

constant (2): neutral signal

kTsopRed 

constant (3): red signal

kTsopError 

constant (0xFF): invalid signal

◆ eTsopGet

enum eTsopGet

clusters select values for reading the beacon measurements

See also
tsops_get()
Enumerator
kTsopGetLeft 

constants (1): left ir-beacon sensor

kTsopGetMiddle 

constants (2): middle ir-beacon sensor

kTsopGetRight 

constants (3): right ir-beacon sensor

Function Documentation

◆ tsops_changed()

uint8_t tsops_changed ( void  )

Indicates if new data changed the data block sTsop.

Because of noise the variables will probably be changed every time new data is received.

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
tsops_received(), tsops_request() and tsops_get()

◆ tsops_get()

eTsop tsops_get ( eTsopGet  select)

Returns the last stored value of the selected tsop sensor.

This function relies on the internal data block sTsop - for new data use tsops_request().

Parameters
selectvalue of the selected tsop sensor - see also eTsopGet
Returns
value representing the state of the selected tsop sensor - see also eTsop
See also
tsops_request(), tsops_received() and tsops_changed()
Examples
tsop.c.

◆ tsops_received()

uint8_t tsops_received ( void  )

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

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
tsops_changed(), tsops_request() and tsops_get()

◆ tsops_request()

void tsops_request ( eRequestType  request)

Requests new data from the tsop sensors.

For details on the request schema see The general request.

Involved data blocks are:
sTsop

See also
tsops_get(), tsops_received() and tsops_changed()
Examples
tsop.c.
tsops_get
eTsop tsops_get(eTsopGet select)
Returns the last stored value of the selected tsop sensor.
kTsopError
@ kTsopError
constant (0xFF): invalid signal
Definition: tsops.h:37
kTsopNeutral
@ kTsopNeutral
constant (2): neutral signal
Definition: tsops.h:33
kTsopGetRight
@ kTsopGetRight
constants (3): right ir-beacon sensor
Definition: tsops.h:134
tsops_request
void tsops_request(eRequestType request)
Requests new data from the tsop sensors.
eTsop
eTsop
clusters the states of the beacon sensors
Definition: tsops.h:28
kTsopGreen
@ kTsopGreen
constant (1): green signal
Definition: tsops.h:31
kTsopGetLeft
@ kTsopGetLeft
constants (1): left ir-beacon sensor
Definition: tsops.h:130
kRequestContinuous
@ kRequestContinuous
constant (3): request continuous updates
Definition: update.h:37
kTsopRed
@ kTsopRed
constant (3): red signal
Definition: tsops.h:35
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.
kTsopGetMiddle
@ kTsopGetMiddle
constants (2): middle ir-beacon sensor
Definition: tsops.h:132
kTsopNone
@ kTsopNone
constant (0): no signal
Definition: tsops.h:29
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.