Eyebot 7  7.16
A Hardware API to control various hardware
eyebot.h
Go to the documentation of this file.
1 
61 #ifndef EYEBOT_H_
62 #define EYEBOT_H_
63 
64 #include "types.h"
65 
69 
75 int LCDPrintf(const char *format, ...);
76 
84 int LCDSetPrintf(int row, int column, const char *format, ...);
85 
90 int LCDClear(void);
91 
98 int LCDSetPos(int row, int column);
99 
106 int LCDGetPos(int *row, int *column);
107 
114 int LCDSetColor(COLOR fg, COLOR bg);
115 
122 int LCDSetFont(int font, int variation);
123 
129 int LCDSetFontSize(int fontsize);
130 
136 int LCDSetMode(int mode);
137 
146 int LCDMenu(char *st1, char *st2, char *st3, char *st4);
147 
156 int LCDMenuI(int pos, char *string, COLOR fg, COLOR bg);
157 
164 int LCDGetSize(int *x, int *y);
165 
173 int LCDPixel(int x, int y, COLOR col);
174 
181 int LCDPixelInvert(int x, int y);
182 
189 COLOR LCDGetPixel (int x, int y);
190 
200 int LCDLine(int x1, int y1, int x2, int y2, COLOR col);
201 
210 int LCDLineInvert(int x1, int y1, int x2, int y2);
211 
221 int LCDArea(int x1, int y1, int x2, int y2, COLOR col, int fill);
222 
232 int LCDAreaInvert(int x1, int y1, int x2, int y2);
233 
243 int LCDCircle(int x1, int y1, int size, COLOR col, int fill);
244 
252 int LCDCircleInvert(int x1, int y1, int size);
253 
259 int LCDImageSize(int t);
260 
270 int LCDImageStart(int x, int y, int xs, int ys);
271 
277 int LCDImage(BYTE *img);
278 
284 int LCDImageGray(BYTE *g);
285 
291 int LCDImageBinary(BYTE *b);
292 
297 int LCDRefresh(void);
299 
300 /******************************************************************************************************************************/
301 
305 
310 int KEYGet(void);
311 
316 int KEYRead(void);
317 
323 int KEYWait(int key);
324 
329 int KEYGetXY (int *x, int *y); /
330 
335 int KEYReadXY(int *x, int *y);
336 
338 
339 /******************************************************************************************************************************/
340 
344 
350 int CAMInit(int resolution);
351 
357 int CAMRelease(void);
358 
364 int CAMGet(BYTE *buf);
365 
371 int CAMGetGray(BYTE *buf);
372 
374 
375 /******************************************************************************************************************************/
376 
380 
386 int IPSetSize(int resolution);
387 
394 int IPReadFile(char *filename, BYTE* img);
395 
402 int IPWriteFile(char *filename, BYTE* img);
403 
410 int IPWriteFileGray(char *filename, BYTE* gray);
411 
417 void IPLaplace(BYTE* grayIn, BYTE* grayOut);
418 
424 void IPSobel(BYTE* imageIn, BYTE* imageOut);
425 
431 void IPCol2Gray(BYTE* imgIn, BYTE* grayOut);
432 
438 void IPGray2Col(BYTE* imgIn, BYTE* colOut);
439 
445 void IPRGB2Col (BYTE* r, BYTE* g, BYTE* b, BYTE* imgOut);
446 
454 void IPCol2HSI (BYTE* img, BYTE* h, BYTE* s, BYTE* i);
455 
462 void IPOverlay(BYTE* c1, BYTE* c2, BYTE* cOut);
463 
471 void IPOverlayGray(BYTE* g1, BYTE* g2, COLOR col, BYTE* cOut);
472 
480 COLOR IPPRGB2Col(BYTE r, BYTE g, BYTE b);
481 
489 void IPPCol2RGB(COLOR col, BYTE* r, BYTE* g, BYTE* b);
490 
498 void IPPCol2HSI(COLOR c, BYTE* h, BYTE* s, BYTE* i);
499 
507 BYTE IPPRGB2Hue(BYTE r, BYTE g, BYTE b);
508 
518 void IPPRGB2HSI(BYTE r, BYTE g, BYTE b, BYTE* h, BYTE* s, BYTE* i);
519 
521 
522 /******************************************************************************************************************************/
523 
527 
533 char * OSExecute(char* command);
534 
539 int OSVersion(char* buf);
540 
546 int OSVersionIO(char* buf);
547 
552 int OSMachineSpeed(void);
553 
559 int OSMachineType(void);
560 
565 int OSMachineName(char* buf);
566 
571 int OSMachineID(void);
572 
574 
575 /******************************************************************************************************************************/
576 
580 
585 int MTInit(void);
586 
592 int MTSleep(int n);
593 
600 TASK MTSpawn(void* (*fct) (void*), int id);
601 
607 int MTGetUID(TASK t);
608 
614 int MTKill(TASK t);
615 
620 int MTExit(void);
621 
628 int SEMAInit(SEMA *sem, int val);
629 
635 int SEMALock(SEMA* sem);
636 
642 int SEMAUnlock(SEMA* sem);
643 
644 
650 int OSWait(int n);
651 
659 TIMER OSAttachTimer(int scale, void (*fct)(void));
660 
666 int OSDetachTimer(TIMER t);
667 
675 int OSSetTime(int hrs,int mins,int secs);
676 
685 int OSGetTime(int *hrs,int *mins,int *secs,int *ticks);
686 
691 int OSGetCount(void);
692 
694 
695 /******************************************************************************************************************************/
696 
700 
708 int SERInit(int interface, int baud,int handshake);
709 
716 int SERSendChar(int interface, char ch);
717 
725 int SERSend(int interface, char *buf);
726 
732 char SERReceiveChar(int interface);
733 
741 int SERReceive(int interface, char *buf);
742 
748 bool SERCheck(int interface);
749 
755 int SERFlush(int interface);
756 
762 int SERClose(int interface);
763 
765 
766 /******************************************************************************************************************************/
767 
771 
776 int AUBeep(void);
777 
784 int AUTone(int freq, int time);
785 
790 int AUCheckTone(void);
791 
797 int AUPlay(BYTE* sample);
798 
803 int AUCheckPlay(void);
804 
809 int AUMicrophone(void);
810 
818 int AURecord(BYTE* buf, int time, long freq);
819 
824 int AUCheckRecord(void);
825 
827 
828 /******************************************************************************************************************************/
829 
833 
839 int PSDGet(int psd);
840 
846 int PSDGetRaw(int psd);
847 
849 
850 /******************************************************************************************************************************/
851 
855 
862 int SERVOSet(int servo, int angle);
863 
870 int SERVOSetRaw (int servo, int angle);
871 
879 int SERVORange(int servo, int low, int high);
880 
882 
883 /******************************************************************************************************************************/
884 
888 
895 int MOTORDrive(int motor, int speed);
896 
903 int MOTORDriveRaw(int motor, int speed);
904 
913 int MOTORPID(int motor, int p, int i, int d);
914 
920 int MOTORPIDOff(int motor);
921 
928 int MOTORSpeed(int motor, int ticks);
929 
931 
932 /******************************************************************************************************************************/
933 
937 
943 int ENCODERRead(int quad);
944 
950 int ENCODERReset(int quad);
951 
953 
954 /******************************************************************************************************************************/
955 
959 
966 int VWSetSpeed(int linSpeed, int angSpeed);
967 
974 int VWGetSpeed(int *linSspeed, int *angSpeed);
975 
983 int VWSetPosition(int x, int y, int phi);
984 
992 int VWGetPosition(int *x, int *y, int *phi);
993 
1002 int VWControl(int Vv, int Tv, int Vw, int Tw);
1003 
1008 int VWControlOff(void);
1009 
1016 int VWStraight(int dist, int lin_speed);
1017 
1024 int VWTurn(int angle, int ang_speed);
1025 
1033 int VWCurve(int dist, int angle, int lin_speed);
1034 
1042 int VWDrive(int dx, int dy, int lin_speed);
1043 
1048 int VWDriveRemain(void);
1049 
1054 int VWDriveDone(void);
1055 
1060 int VWDriveWait(void);
1061 
1066 int VWStalled(void);
1067 
1069 
1070 /******************************************************************************************************************************/
1071 
1075 
1082 int DIGITALSetup(int io, char direction);
1083 
1089 int DIGITALRead(int io);
1090 
1095 int DIGITALReadAll(void);
1096 
1103 int DIGITALWrite(int io, int state);
1104 
1110 int ANALOGRead(int channel);
1111 
1116 int ANALOGVoltage(void);
1117 
1119 
1120 /******************************************************************************************************************************/
1121 
1125 
1130 int IRTVGet(void);
1131 
1136 int IRTVRead(void);
1137 
1142 int IRTVFlush(void);
1143 
1148 int IRTVGetStatus(void);
1149 
1151 
1152 /******************************************************************************************************************************/
1153 
1157 
1162 int RADIOInit(void);
1163 
1168 int RADIOGetID(void);
1169 
1177 int RADIOSend(int id_no, BYTE* buf, int size);
1178 
1186 int RADIOReceive(int *id_no, BYTE* buf, int *size);
1187 
1193 int RADIOCheck(int *id_no);
1194 
1200 int RADIOStatus(int IDlist[]);
1201 
1206 int RADIORelease(void);
1207 
1209 
1210 
1211 #endif /* EYEBOT_H_ */
int RADIOReceive(int *id_no, BYTE *buf, int *size)
Read num. of bytes from ID source.
void IPCol2Gray(BYTE *imgIn, BYTE *grayOut)
Transfer color to gray image.
int MTKill(TASK t)
kills the task t
int MTSleep(int n)
sleeps for 10ms ie n/100s
int VWControl(int Vv, int Tv, int Vw, int Tw)
Set PI params. for v and w (typical 70 30 70 10)
void IPRGB2Col(BYTE *r, BYTE *g, BYTE *b, BYTE *imgOut)
Transfer grey to color (3-byte) image.
int VWDriveWait(void)
Blocks until the drive is complete.
int VWSetSpeed(int linSpeed, int angSpeed)
Sets the VW speed, angle.
COLOR LCDGetPixel(int x, int y)
Get the RGB color value of the pixel at (x,y) coordinate.
int VWGetSpeed(int *linSspeed, int *angSpeed)
Obtains the current speeds.
int KEYGetXY(int *x, int *y)
Blocking read for touch at any position, and returns the coordinates of the pressed position...
int SERSendChar(int interface, char ch)
Sends a single character to the given port handle.
int LCDImageSize(int t)
Specifies the size of subsequent LCDImage functions.
Defines types used for the EyeBot 7.
int SEMAInit(SEMA *sem, int val)
initialises the semaphores
void IPPCol2HSI(COLOR c, BYTE *h, BYTE *s, BYTE *i)
Transforms RGB to HSI (for one pixel)
int SERFlush(int interface)
flushes the port
int KEYGet(void)
Blocking read (and wait) for key press (returns KEY1..KEY4)
int IPReadFile(char *filename, BYTE *img)
Read PNM file, fill/crop if req.; return 0 for color, 1 for gray image.
int VWCurve(int dist, int angle, int lin_speed)
Turns the vehicle in a curve.
int LCDSetPrintf(int row, int column, const char *format,...)
LCDPrintf with text position specified.
int CAMGet(BYTE *buf)
Retrieve a camera frame into the provided buffer.
int OSMachineSpeed(void)
Inform the user how fast the processor runs.
int OSVersion(char *buf)
Returns string containing running RoBIOS version.
int OSMachineID(void)
Inform the user with which ID the Eyebot is titled.
int VWTurn(int angle, int ang_speed)
Turns the vehicle on the spot.
int OSMachineName(char *buf)
Inform the user with which name the Eyebot is titled.
int LCDLineInvert(int x1, int y1, int x2, int y2)
Draw a line from (x1,y1) to (x2,y2). The line pixels will invert the color of existing pixels...
int AUTone(int freq, int time)
Play tone with FREQ for time/100 sec.
int COLOR
Definition: types.h:109
int LCDImageBinary(BYTE *b)
Draws a binary [0..1] image to the LCD.
int AUCheckRecord(void)
Non-blocking check whether recording has finished.
int ANALOGRead(int channel)
Reads the analog channel on the IO board.
int IPWriteFileGray(char *filename, BYTE *gray)
Write greyscale PNM file.
int LCDImageGray(BYTE *g)
Draws a greyscale [0..255] image to the LCD.
void IPGray2Col(BYTE *imgIn, BYTE *colOut)
Transfer grey to color (3-byte) image.
int VWSetPosition(int x, int y, int phi)
Sets the position wrt current position.
int IRTVGetStatus(void)
Checks to see if IR input is enabled;.
int VWDriveDone(void)
Checks to see if the current drive is complete.
int AUPlay(BYTE *sample)
Play audio sample.
int LCDSetPos(int row, int column)
Set the text cursor position to (row, column).
int OSDetachTimer(TIMER t)
removes the Timer from the list
int IRTVRead(void)
Non-blocking read, return 0 if nothing and returns the keycode.
int VWControlOff(void)
Stop PI control for v and w.
int MOTORPID(int motor, int p, int i, int d)
Set the given motors with PID control.
int IPSetSize(int resolution)
Sets the size for the image processing (also automatically set by CAMInit).
void IPOverlay(BYTE *c1, BYTE *c2, BYTE *cOut)
Overlay c2 onto c1, all color images.
int LCDClear(void)
Clear the LCD display and all display buffers ie. turn it black.
int ENCODERRead(int quad)
Reads the value from the encoder.
int RADIOCheck(int *id_no)
Non-blocking check whether message is waiting.
int LCDSetFont(int font, int variation)
Sets the font using font type and variation.
int OSWait(int n)
Waits for 1 ms.
int MOTORSpeed(int motor, int ticks)
Sets the controlled motor speed in ticks/sec.
int CAMRelease(void)
Stops and releases all camera structures.
int OSSetTime(int hrs, int mins, int secs)
sets the system time
int LCDImage(BYTE *img)
Draws a colour (RGB) image to the LCD.
int PSDGet(int psd)
Delivers actual timestamp or distance measured by the selected PSD.
int LCDCircleInvert(int x1, int y1, int size)
Inverts the pixels inside of the given circle.
int SEMAUnlock(SEMA *sem)
unlocks the given semaphore
void IPLaplace(BYTE *grayIn, BYTE *grayOut)
apply Laplace tranform to the image
void IPCol2HSI(BYTE *img, BYTE *h, BYTE *s, BYTE *i)
Transfer color image to hue sat int.
int RADIOSend(int id_no, BYTE *buf, int size)
Send spec. number of bytes to ID destination.
int KEYRead(void)
Non-blocking read of key press (returns NOKEY=0 if no key)
int LCDAreaInvert(int x1, int y1, int x2, int y2)
Draw a rectangle with (x1,y1) as top-left coordinate and (x2,y2) as the bottom-right coordinate...
BYTE IPPRGB2Hue(BYTE r, BYTE g, BYTE b)
Convert RGB to hue (0 for gray values)
void IPOverlayGray(BYTE *g1, BYTE *g2, COLOR col, BYTE *cOut)
Overlay gray image g2 onto g1, using col.
int LCDMenuI(int pos, char *string, COLOR fg, COLOR bg)
Set specific menu entry in KEY_CLASSIC mode (index given by pos).
int VWDriveRemain(void)
Checks the remaining drive time.
int SERVORange(int servo, int low, int high)
Sets the range for the servos.
int AUCheckPlay(void)
Non-blocking test if playing has finished.
int DIGITALSetup(int io, char direction)
Sets up the digital input/output pins.
int IRTVGet(void)
Blocking read of IRTV command and returns the keycode.
int AURecord(BYTE *buf, int time, long freq)
Record sound for time/100sec using sample FREQ.
int LCDSetMode(int mode)
Update the internal mode flag bits.
int LCDImageStart(int x, int y, int xs, int ys)
Sets the location and size parameters for subsequent image draws.
int AUCheckTone(void)
Non-blocking test if tone has finished.
int MTGetUID(TASK t)
gets the ID of the taks
int LCDPixel(int x, int y, COLOR col)
Sets the color of the pixel at (x,y) coordinate to color.
int LCDSetFontSize(int fontsize)
Sets the font size.
int MOTORDrive(int motor, int speed)
Set the given motors to the same given speed dependant on hdt table.
int MTExit(void)
kills current task
int LCDLine(int x1, int y1, int x2, int y2, COLOR col)
Draw a color line from (x1,y1) to (x2,y2).
int SERClose(int interface)
closes the port
int AUBeep(void)
Play beep sound.
int LCDArea(int x1, int y1, int x2, int y2, COLOR col, int fill)
Draw a color-filled rectangle with (x1,y1) as top-left coordinate and (x2,y2) as the bottom-right coo...
int LCDPrintf(const char *format,...)
Print formatted string to LCD and refresh LCD. Cursor position is updated.
int RADIOStatus(int IDlist[])
Returns number of robots (incl. self) and list of IDs in network.
int SERSend(int interface, char *buf)
Sends a string to the given port handle.
int RADIOInit(void)
Starts radio communication between the Eyebots.
int TIMER
Definition: types.h:112
int VWStalled(void)
Checks to see if the vehicle is stalled.
int DIGITALWrite(int io, int state)
Writes to the digital input/output pins.
int SERReceive(int interface, char *buf)
Receives a string from port handle.
int OSMachineType(void)
Inform the user in which environment the program runs.
int AUMicrophone(void)
Return microphone A-to-D sample value.
int SERInit(int interface, int baud, int handshake)
Initialises the port.
int CAMInit(int resolution)
Initialises the camera.
COLOR IPPRGB2Col(BYTE r, BYTE g, BYTE b)
Transforms RGB to a COLOR (for one Pixel)
char SERReceiveChar(int interface)
Receives a single character from the given port handle.
char * OSExecute(char *command)
Executes a system command and obtains the string returned after the command.
int SERVOSet(int servo, int angle)
Set the given servos to the same given angle depending on table value.
int VWDrive(int dx, int dy, int lin_speed)
Turns the vehicle in a curve: x[mm] straight and y[mm] left, x>|y|.
int OSGetTime(int *hrs, int *mins, int *secs, int *ticks)
Get system time (ticks in 1/100 sec)
void IPPCol2RGB(COLOR col, BYTE *r, BYTE *g, BYTE *b)
Transforms COLOR to RGB (for one Pixel)
int PSDGetRaw(int psd)
Delivers raw-data measured by the selected PSD.
int MOTORDriveRaw(int motor, int speed)
Set the given motor to a given speed.
TIMER OSAttachTimer(int scale, void(*fct)(void))
adds a function to a 1kHz/scale timer, ie. executes every 1ms*scale usage: OSAttachTimer(<scale>, &<function>);
int LCDSetColor(COLOR fg, COLOR bg)
Set the default color for text (including background).
int KEYReadXY(int *x, int *y)
Non-blocking read for touch at any position, returns coordinates of pressed position.
void IPPRGB2HSI(BYTE r, BYTE g, BYTE b, BYTE *h, BYTE *s, BYTE *i)
Convert RGB to hue, sat, int; hue=0 for gray values.
int ANALOGVoltage(void)
Finds the Analog Voltage as read from the IO board.
int DIGITALRead(int io)
Reads the digital input/output pins.
int CAMGetGray(BYTE *buf)
Grabs a gray image off the camera.
int MOTORPIDOff(int motor)
Shuts off PID control.
void IPSobel(BYTE *imageIn, BYTE *imageOut)
apply Sobel tranform to the image
int LCDGetSize(int *x, int *y)
Get LCD resolution in pixels.
int DIGITALReadAll(void)
Reads all digital pins.
int LCDMenu(char *st1, char *st2, char *st3, char *st4)
Set menu entries in KEY_CLASSIC mode (4-buttons).
int LCDGetPos(int *row, int *column)
Get the text cursor position.
int ENCODERReset(int quad)
Resets the encoder to 0.
int LCDPixelInvert(int x, int y)
Bit-invert the color of the pixel at (x,y) coordinate.
char BYTE
Definition: types.h:110
int VWStraight(int dist, int lin_speed)
Drives straight.
int LCDCircle(int x1, int y1, int size, COLOR col, int fill)
Draws a circle.
int IRTVFlush(void)
Terminates the remote control decoder and releases the irtv thread.
int OSVersionIO(char *buf)
Gives the version of the IO board.
int RADIOGetID(void)
Get own radio ID.
int SEMALock(SEMA *sem)
locks the given semaphoe
int MTInit(void)
initialises the threads
int KEYWait(int key)
Wait for specific keys to be pressed. (use ANYKEY for any key)
int RADIORelease(void)
Terminate radio communication.
int LCDRefresh(void)
Refresh the screen. Refreshes the menu.
int VWGetPosition(int *x, int *y, int *phi)
Gets the position wrt original position.
int IPWriteFile(char *filename, BYTE *img)
Write color PNM file.
int OSGetCount(void)
gives you the count in 1/100 sec since the system start
int SERVOSetRaw(int servo, int angle)
Set the given servos to the same given angle in raw mode.
TASK MTSpawn(void *(*fct)(void *), int id)
Create and initialize thread with given ID.
bool SERCheck(int interface)
checks and flushes the port by sending enter until seeing prompt