Fragments of a BOB-4 control program used in the University of Michigan's 2007 Continuum Solar Car project. Runs on Microchip's PIC18F series MCU. Jeff Rogers added the following comments on 10/8/2007: "Regarding the example application code, I had to make a few revisions to it. The BobClearScreen(BOB_CLEAR_ALL); command was giving unexpected results. Even though I restricted the drawing area with BobSetWindowPxStr("30;43;195;267"); the screen clear was effecting areas to the right of and below of the active drawing area. Instead, I now set the drawing window, move the cursor to 0,0 and then overwrite the desired text, using write space characters ' ' to erase anything extra." Example use: void UpdateCruise(float cspeed) { int speed = cspeed*36.0; BobSetFont(BOB_FONT_DEFAULT); BobSetAttribute("70"); BobSetWindowPxStr("30;43;195;267"); BobClearScreen(BOB_CLEAR_ALL); BobSend('C'); BobSend(' '); if(speed < 0) { BobWriteRom("OFF"); } else { BobWriteRam(itoa(speed / 10, tmpbuf)); BobSend('.'); BobSend((speed%10) + '0'); } } /************************************ University of Michigan Solar Car Team Continuum 2007 Written by: Jeffrey B. Rogers - jbrogers@mich.edu Steven Hechtman - shechtman@umich.edu ************************************/ #include "bob.h" #include char tmpbuf[32]; void BobMoveCursor(char x, char y) { SendCSI(); BobWriteRam(itoa(y, tmpbuf)); BobSend(';'); BobWriteRam(itoa(x, tmpbuf)); BobSend('H'); } void BobMoveCursorRelative(char distance, char direction) { SendCSI(); BobWriteRam(itoa(distance, tmpbuf)); BobSend(direction); } void BobClearScreen(char type) { SendCSI(); BobSend(type); BobSend('J'); } void BobClearLine(char type) { SendCSI(); BobSend(type); BobSend('K'); } void BobInsertLines(char number) { SendCSI(); BobWriteRam(itoa(number, tmpbuf)); BobSend('L'); } void BobDeleteLines(char number) { SendCSI(); BobWriteRam(itoa(number, tmpbuf)); BobSend('M'); } void BobClearAttributes(void) { SendCSI(); BobSend('0'); BobSend('m'); } void BobSetAttribute(const rom char* attribute) { SendCSI(); BobWriteRom(attribute); BobSend('m'); } void BobSetWindow(char top, char bottom, char left, char right) { SendCSI(); BobWriteRam(itoa(top, tmpbuf)); BobSend(';'); BobWriteRam(itoa(bottom, tmpbuf)); BobSend(';'); BobWriteRam(itoa(left, tmpbuf)); BobSend(';'); BobWriteRam(itoa(right, tmpbuf)); BobSend('q'); } void BobSetWindowPx(int top, int bottom, int left, int right) { SendCSI(); BobWriteRam(itoa(top, tmpbuf)); BobSend(';'); BobWriteRam(itoa(bottom, tmpbuf)); BobSend(';'); BobWriteRam(itoa(left, tmpbuf)); BobSend(';'); BobWriteRam(itoa(right, tmpbuf)); BobSend('.'); BobSend('q'); } void BobSetWindowPxStr(const rom char* str) { SendCSI(); BobWriteRom(str); BobSend('.'); BobSend('q'); } void BobSaveCursor(void) { SendCSI(); BobSend('s'); } void BobRestoreCursor(void) { SendCSI(); BobSend('u'); } void BobFormFeed(void) { SendCSI(); BobSend('U'); } void BobSetConfig(const rom char* setting, char value) { SendCSI(); BobWriteRom(setting); BobSend(';'); BobSend(value); BobSend('v'); } void BobEraseAfter(char number) { SendCSI(); BobWriteRam(itoa(number, tmpbuf)); BobSend('X'); } void BobSetFont(char font) { SendCSI(); BobSend(font); BobSend('z'); } void BobEnableTimingSignal(void) { SendCSI(); BobSend('9'); BobSend(';'); BobSend('1'); BobSend('|'); } void BobWriteRom(const rom char* msg) { for( ; *msg != '\0'; msg++) { UARTIntPutChar(*msg); } } void BobWriteRam(const char* msg) { for( ; *msg != '\0'; msg++) { UARTIntPutChar(*msg); } } /************************************ University of Michigan Solar Car Team Continuum 2007 Written by: Jeffrey B. Rogers - jbrogers@mich.edu Steven Hechtman - shechtman@umich.edu ************************************/ #ifndef BOB_H_ #define BOB_H_ #include "UARTIntC.h" #define SendCSI() UARTIntPutChar(0x1B);\ UARTIntPutChar(0x5B) #define SendESC() UARTIntPutChar(0x1B) #define BobSend(x) UARTIntPutChar(x) #define BOB_CLEAR_AFTER '0' #define BOB_CLEAR_BEFORE '1' #define BOB_CLEAR_ALL '2' #define BOB_MOVE_UP 'A' #define BOB_MOVE_DOWN 'B' #define BOB_MOVE_RIGHT 'C' #define BOB_MOVE_LEFT 'D' #define BOB_BOLD "1" #define BOB_FAINT "2" #define BOB_BLINK "5" #define BOB_REVERSE "7" #define BOB_NO_BOLD "22" #define BOB_NO_FAINT "22" #define BOB_NO_BLINK "25" #define BOB_NO_REVERSE "27" #define BOB_TEXT_WHITE "64" #define BOB_TEXT_WHITE_BLACK "69" #define BOB_FONT_DEFAULT '0' #define BOB_FONT_8X13 '1' #define BOB_FONT_TARGET '2' #define BOB_FONT_MISC '3' #define BOB_FONT_6X10 '4' #define BOB_FONT_13X34 '5' #define BOB_FONT_20X40 '6' #define BOB_FONT_BOB4 '7' #define BOB_CONFIG_HIGH_RATE "20" #define BOB_CONFIG_RESTRICT_AREA "21" #define BOB_CONFIG_BLINK_ENABLE "32" #define BOB_TRUE '1' #define BOB_FALSE '0' void BobMoveCursor(char x, char y); void BobMoveCursorRelative(char distance, char direction); void BobClearScreen(char type); void BobClearLine(char type); void BobInsertLines(char number); void BobDeleteLines(char number); void BobClearAttributes(void); void BobSetAttribute(const rom char*); void BobSetWindow(char top, char bottom, char left, char right); void BobSetWindowPx(int top, int bottom, int left, int right); void BobSetWindowPxStr(const rom char* str); void BobSaveCursor(void); void BobRestoreCursor(void); void BobFormFeed(void); void BobSetConfig(const rom char* setting, char value); void BobEraseAfter(char number); void BobSetFont(char font); void BobEnableTimingSignal(void); void BobWriteRom(const rom char* msg); void BobWriteRam(const char* msg); #endif