lausTracker.c
/*******************************************************************************
* examples/lausTracker.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>
#include <tucbot_additionals/packedCom.h>
#include <tucbot_additionals/lausTracker.h>
//*********************************<Methods>************************************
void testLausTracker(void);
int main(void);
//*********************************[testLausTracker]****************************
void testLausTracker(void) {
uint8_t menu_pos = 0;
uint8_t flag_redraw_menu = 0xFF;
uint8_t value_count = 0;
uint8_t temp;
lcdclr();
lcdstr_p(PSTR("lausTracker ###"));
while (1) {
// redraw menu
if (flag_redraw_menu) {
flag_redraw_menu = 0x00;
lcdxy(0,1);
if (menu_pos == 0) {
lcdstr_p(PSTR("self @(#,#,#)" ));
} else {
lcdstr_p(PSTR("rival @(#,#) " ));
}
mdelay(400);
}
// check if buttons were pushed
// middle button --> toggle menu
mdelay(100);
if (menu_pos == 0) {
menu_pos = 1;
} else {
menu_pos = 0;
}
flag_redraw_menu = 0xFF;
}
// update display (general)
if (temp != value_count) {
value_count = temp;
lcdxy(13,0); uint16tostr(lcdout,temp,3);
}
// update display depending on menu position
if (menu_pos == 0) {
lcdxy( 8,1);
lcdxy(10,1);
lcdxy(12,1);
lcdout('E');
break;
lcdout('S');
break;
lcdout('W');
break;
lcdout('N');
break;
}
}
} else {
lcdxy( 8,1);
lcdxy(10,1);
}
}
mdelay(100);
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testLausTracker();
return (0);
}
leds_set
void leds_set(eLedMask bitmask, uint8_t bool)
Sets the selected leds on or off.
kLausTrackerGetSelfX
@ kLausTrackerGetSelfX
constant (1): x-coordinate of one self's robot (0...7)
Definition: lausTracker.h:161
buttons_get
eButtonMask buttons_get(eButtonMask bitmask)
Returns the last stored value of the selected buttons.
kLausTrackerGetRivalY
@ kLausTrackerGetRivalY
constant (5): y-coordinate of opponent's robot (0...7)
Definition: lausTracker.h:170
kButtonMiddle
@ kButtonMiddle
bit mask (0x08): middle button
Definition: buttons.h:35
kLausTrackerGetSelfY
@ kLausTrackerGetSelfY
constant (2): y-coordinate of one self's robot (0...7)
Definition: lausTracker.h:163
kLausTrackerOrientationEast
@ kLausTrackerOrientationEast
constant (2): heading east (positive x-direction)
Definition: lausTracker.h:33
kLedOn
@ kLedOn
constant (0xFF): turn leds on
Definition: leds.h:63
kLausTrackerSelectSelf
@ kLausTrackerSelectSelf
Definition: lausTracker.h:145
lausTracker_get
uint8_t lausTracker_get(eLausTrackerGet select)
Returns the last stored version of the selected value.
kLausTrackerOrientationNorth
@ kLausTrackerOrientationNorth
constant (1): heading north (positive y-direction)
Definition: lausTracker.h:31
buttons_request
void buttons_request(eRequestType request)
Requests new data from the buttons.
lausTracker_request
void lausTracker_request(eLausTrackerSelectMask bitmask, eRequestType request)
Requests new data from the Laus-Tracker.
kLausTrackerOrientationWest
@ kLausTrackerOrientationWest
constant (3): heading west (negative x-direction)
Definition: lausTracker.h:35
kLausTrackerOrientationSouth
@ kLausTrackerOrientationSouth
constant (0): heading south (negative y-direction)
Definition: lausTracker.h:29
kRequestContinuous
@ kRequestContinuous
constant (3): request continuous updates
Definition: update.h:37
kLausTrackerGetRivalX
@ kLausTrackerGetRivalX
constant (4): x-coordinate of opponent's robot (0...7)
Definition: lausTracker.h:168
kLedMiddle
@ kLedMiddle
bit mask (0x08): middle led
Definition: leds.h:44
kLedOff
@ kLedOff
constant (0x00): turn leds off
Definition: leds.h:61
uint16tostr
void uint16tostr(void *out, uint16_t number, uint8_t digits)
Converts an unsigned integer to a string and passes it to an output function.
packedCom_activate
void packedCom_activate(void)
Turns the reception of data packets on.
lcdclr
void lcdclr(void)
Clears the display.
packedCom_get
uint8_t packedCom_get(ePackedComGet select)
Returns the last stored selected value.
lcdxy
void lcdxy(uint8_t x, uint8_t y)
Moves the cursor to a postion on the display.
kLausTrackerSelectAll
@ kLausTrackerSelectAll
bit mask (0x03): select all data blocks
Definition: lausTracker.h:151
kPackedComGetPacketCount
@ kPackedComGetPacketCount
constants (2): number of correct received packets
Definition: packedCom.h:264
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.
kLausTrackerSelectRival
@ kLausTrackerSelectRival
Definition: lausTracker.h:148
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.
kLausTrackerGetSelfOrientation
@ kLausTrackerGetSelfOrientation
Definition: lausTracker.h:165
lausTracker_changed
eLausTrackerSelectMask lausTracker_changed(eLausTrackerSelectMask bitmask)
Indicates if new data changed the selected data blocks.