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.
main.cpp
00001 // 00002 // MBED Application Board 00003 // Lightweight C12832 LCD library 00004 // 2014, Alexander Medvedev, @medvdv 00005 // 00006 00007 // 00008 // Usage Sample 00009 // 00010 00011 #include "mbed.h" 00012 00013 #include "lcd128lib.h" 00014 00015 #include "lcd128menu.h" 00016 00017 lcd128 lcd; 00018 00019 bool menuCheckVariable = false; 00020 int menuRadioVariable = 1; 00021 float menuProgressBar = 0.5; 00022 00023 lcd128entry menuMain[] = { 00024 00025 { APPMENU_COMMENT, 0, "Main Menu", true, false, 0, 0, 0, NULL }, 00026 { APPMENU_ACTION, 1, "Action Item", false, false, 0, 0, 0, NULL }, 00027 { APPMENU_ACTION, 2, "Other Action", false, false, 0, 0, 0, NULL }, 00028 { APPMENU_BREAK, 0, NULL, false, false, 0, 0, 0, NULL }, 00029 { APPMENU_CHECK, 0, "Check Button", false, false, 0, 0, 0, & menuCheckVariable }, 00030 { APPMENU_BREAK, 0, NULL, false, false, 0, 0, 0, NULL }, 00031 { APPMENU_COMMENT, 0, "Select one:", false, false, 0, 0, 0, NULL }, 00032 { APPMENU_RADIO, 1, "Radio Button 1", false, false, 0, 0, 0, & menuRadioVariable }, 00033 { APPMENU_RADIO, 2, "Radio Button 2", false, false, 0, 0, 0, & menuRadioVariable }, 00034 { APPMENU_RADIO, 3, "Radio Button 3", false, false, 0, 0, 0, & menuRadioVariable }, 00035 { APPMENU_BAR, 0, NULL, false, false, 0, 0, 0, & menuProgressBar }, 00036 00037 }; 00038 00039 int main() 00040 { 00041 BusIn joy(p15, p12, p13, p16); 00042 DigitalIn fire(p14); 00043 00044 lcd.Reset(); 00045 00046 lcd.XY(0, 0); 00047 lcd.Bold(true); lcd.String("LCD LIBRARY"); lcd.Bold(false); 00048 lcd.Row(1, "Simple interface library with nice proportional font."); 00049 lcd.Row(3, "Push joystick!", true, LCD_ALIGN_CENTER); 00050 lcd.InverseRow(2, 0x80); // Add one inverted pixel line upper than last row 00051 00052 lcd.Update(); 00053 00054 wait_ms(500); while(! fire) wait_ms(100); 00055 00056 lcd.Row(0, "Left aligned text"); 00057 lcd.Row(1, "Center aligned text", false, LCD_ALIGN_CENTER); 00058 lcd.Row(2, "Right aligned text", false, LCD_ALIGN_RIGHT); 00059 lcd.InverseRow(2, 0x80); // Add one inverted pixel line upper than last row 00060 00061 lcd.Update(); 00062 00063 wait_ms(500); while(! fire) wait_ms(100); 00064 00065 lcd.Clear(0); lcd.Clear(1); lcd.Clear(2); 00066 00067 lcd.XY(0, 1); 00068 lcd.Bold(true); lcd.String("Bold"); lcd.Bold(false); 00069 lcd.String(" and "); 00070 lcd.Underline(true); lcd.String("underlined"); lcd.Underline(false); 00071 lcd.String(" text"); 00072 00073 lcd.InverseRow(2, 0x80); // Add one inverted pixel line upper than last row 00074 00075 lcd.Update(); 00076 00077 wait_ms(500); while(! fire) wait_ms(100); 00078 00079 lcd.Clear(0); lcd.Clear(1); lcd.Clear(2); lcd.InverseRow(2, 0x80); 00080 00081 lcd.Row(0, "Arbitary X position:"); 00082 00083 wait_ms(500); 00084 00085 int x = 0; 00086 00087 do { 00088 lcd.Clear(1); 00089 lcd.XY(5 + x/8, 1); 00090 lcd.Character(LCD_CLOCK0 + (x % 8)); 00091 lcd.Update(); 00092 x += 1; 00093 x %= 113*8; 00094 wait_ms(100); 00095 } while(! fire); 00096 00097 wait_ms(500); 00098 00099 lcd.Clear(0); lcd.Clear(1); lcd.Clear(2); lcd.InverseRow(2, 0x80); 00100 00101 lcd.XY(0,1); lcd.String("Bar"); 00102 00103 x = 0; 00104 00105 do { 00106 lcd.Clear(2); 00107 lcd.XY(22, 1); 00108 lcd.Bar(98, x/96.0); 00109 lcd.Update(); 00110 x += 1; 00111 x %= 97; 00112 wait_ms(50); 00113 } while(! fire); 00114 00115 lcd.Clear(0); lcd.Clear(1); lcd.Clear(2); lcd.InverseRow(2, 0x80); 00116 00117 lcd.Row(1, "Hardware Inverse All"); 00118 lcd.Update(); 00119 00120 wait_ms(500); while(! fire) wait_ms(100); 00121 00122 lcd.InverseMode(true); 00123 00124 wait_ms(500); while(! fire) wait_ms(100); 00125 00126 lcd.InverseMode(false); 00127 00128 lcd.Clear(0); lcd.Clear(1); lcd.Clear(2); lcd.InverseRow(2, 0x80); 00129 00130 lcd.Row(1, "Hardware Power Off / On"); 00131 lcd.Update(); 00132 00133 wait_ms(500); while(! fire) wait_ms(100); 00134 00135 lcd.Power(false); 00136 00137 wait_ms(500); while(! fire) wait_ms(100); 00138 00139 lcd.Power(true); 00140 00141 lcd.Clear(0); lcd.Clear(1); lcd.Clear(2); 00142 00143 lcd.Row(0, "Menu interface:"); 00144 lcd.Row(1, "Values and sub-menu"); 00145 lcd.Row(2, "Checkbox, radiobutton"); 00146 00147 lcd.InverseRow(2, 0x80); 00148 00149 lcd.Update(); 00150 00151 wait_ms(500); while(! fire) wait_ms(100); 00152 00153 lcd128menu(&lcd, menuMain, sizeof(menuMain) / sizeof(lcd128entry)); 00154 00155 }
Generated on Sat Jul 23 2022 01:51:45 by
1.7.2