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