sharp.c
/*******************************************************************************
* examples/sharp.c *
* ================ *
* *
* Version: 1.0.6 *
* Date : 15.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>************************************
void testSharp(void);
int main(void);
//*********************************[testSharp]**********************************
void testSharp(void) {
int16_t value;
uint8_t countdown = 0;
uint8_t flag_convert = 0xFF;
lcdclr();
lcdstr_p(PSTR("Sharp" ));
lcdxy(0,1);
lcdstr_p(PSTR(" #### #### ####"));
while (1) {
mdelay(100);
lcdxy(13,0);
lcdstr_p(PSTR( " mm"));
flag_convert = 0xFF;
countdown = 0;
} else if (buttons_get(kButtonRight)) {
mdelay(100);
lcdxy(13,0);
lcdstr_p(PSTR( "adc"));
flag_convert = 0x00;
countdown = 0;
}
if (countdown) {
countdown--;
} else {
countdown = 5;
if (flag_convert) {value = sharps_toMm(value);}
lcdxy( 1,1); int16tostr(lcdout,value,4);
if (flag_convert) {value = sharps_toMm(value);}
lcdxy( 6,1); int16tostr(lcdout,value,4);
if (flag_convert) {value = sharps_toMm(value);}
lcdxy(11,1); int16tostr(lcdout,value,4);
}
mdelay(100);
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testSharp();
return (0);
}
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
kSharpGetRight
@ kSharpGetRight
constants (3): right ir-distance sensor
Definition: sharps.h:88
kLedOn
@ kLedOn
constant (0xFF): turn leds on
Definition: leds.h:63
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.
int16tostr
void int16tostr(void *out, int16_t number, uint8_t digits)
Converts an integer to a string and passes it to an output function.
sharps_get
uint16_t sharps_get(eSharpGet select)
Returns the last stored value of the selected sharp sensor.
kRequestContinuous
@ kRequestContinuous
constant (3): request continuous updates
Definition: update.h:37
kLedMiddle
@ kLedMiddle
bit mask (0x08): middle led
Definition: leds.h:44
kLedOff
@ kLedOff
constant (0x00): turn leds off
Definition: leds.h:61
kSharpGetLeft
@ kSharpGetLeft
constants (1): left ir-distance sensor
Definition: sharps.h:84
lcdclr
void lcdclr(void)
Clears the display.
sharps_toMm
int16_t sharps_toMm(uint16_t adc)
Converts an adc value of a sharp sensor into millimeters.
lcdxy
void lcdxy(uint8_t x, uint8_t y)
Moves the cursor to a postion on the display.
sharps_request
void sharps_request(eRequestType request)
Requests new data from the sharp sensors.
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.
kSharpGetMiddle
@ kSharpGetMiddle
constants (2): middle ir-distance sensor
Definition: sharps.h:86