Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
Display.cpp
00001 #include "mbed.h" 00002 #include "util.h" 00003 #include "Display.h" 00004 00005 // TODO 3 would also be nice if we did all the printf crap here too 00006 00007 #define LCD_FMT "%-20s" // used to fill a single line on the LCD screen 00008 00009 // This is for the Sparkfun module 00010 #define DISPLAY_CLEAR 0x01 00011 #define DISPLAY_SET_POS 0x08 00012 00013 Display::Display(void): 00014 lcd(p17, p18, SD_FW), 00015 v(1, 20, 35, 20, 'V'), 00016 //a(11, 40, 15, 'A'), 00017 g1(22, 20, 35, 20, 'G'), 00018 g2(43, 20, 35, 20, 'H') 00019 { 00020 // nothin to do 00021 } 00022 00023 void Display::init() 00024 { 00025 lcd.baud(115200); 00026 lcd.puts("test\n"); // hopefully force 115200 on powerup 00027 lcd.clear(); 00028 wait(0.3); 00029 } 00030 00031 void Display::status(const char *st) 00032 { 00033 int pad; 00034 char *s = (char *) st; 00035 for (pad=20; pad > 0; pad--) { 00036 if (*s++ == '\0') break; 00037 } 00038 lcd.pos(0,1); 00039 lcd.puts(st); 00040 while (pad--) { 00041 lcd.puts(" "); 00042 } 00043 } 00044 00045 void Display::menu(const char *itemName) 00046 { 00047 int pad; 00048 char *s = (char *) itemName; 00049 for (pad=20; pad > 0; pad--) { 00050 if (*s++ == '\0') break; 00051 } 00052 lcd.pos(0,0); 00053 lcd.puts("< "); 00054 lcd.puts(itemName); 00055 lcd.puts(" >"); 00056 pad -= 4; // account for "< " and " >" 00057 while (pad--) { 00058 lcd.puts(" "); 00059 } 00060 } 00061 00062 void Display::select(const char *itemName) 00063 { 00064 lcd.pos(0,0); 00065 lcd.puts(">>"); 00066 lcd.puts(itemName); 00067 } 00068 00069 // display gauge at a given position (slot) along the bottom 00070 void Display::gauge(int slot) 00071 { 00072 } 00073 00074 #define WIDTH 22 00075 00076 void Display::update(SystemState *state) { 00077 if (state) { 00078 // TODO 2 fix padding/overwrite 00079 lcd.pos(0,3); 00080 lcd.puts("V:"); 00081 lcd.puts(cvftos(state->voltage, 1)); 00082 lcd.puts(" G:"); 00083 lcd.puts(cvftos(state->gpsHDOP, 1)); 00084 lcd.puts(" "); 00085 lcd.puts(cvitos(state->gpsSats)); 00086 00087 lcd.pos(0,4); 00088 lcd.puts("H:"); 00089 lcd.puts(cvftos(state->estHeading, 1)); 00090 lcd.puts(" B:"); 00091 lcd.puts(cvftos(state->bearing, 1)); 00092 lcd.puts(" "); 00093 lcd.puts(cvftos(state->LABrg, 1)); 00094 } 00095 } 00096 00097 void Display::redraw() { // TODO 3 rename 00098 } 00099 00100 00101
Generated on Tue Jul 12 2022 21:36:18 by
1.7.2