Sample usage of lightweight C12832 LCD library
Just look at that sample - easy and lightweight text driven interface
Diff: main.cpp
- Revision:
- 1:58927e4da529
- Parent:
- 0:9b6c469485ea
- Child:
- 2:e3c117a9b81b
--- a/main.cpp Sat Feb 01 13:33:51 2014 +0000 +++ b/main.cpp Sat Feb 01 15:39:00 2014 +0000 @@ -14,8 +14,11 @@ BusIn joy(p15,p12,p13,p16); DigitalIn fire(p14); - + BusOut leds(LED1,LED2,LED3,LED4); + +AnalogIn Pot1(p19); +AnalogIn Pot2(p20); lcd128 lcd; @@ -31,20 +34,56 @@ lcd.XY(0,1); } +char* BANG = " BANG! "; + int main() { lcd.Reset(); // Nice header with bold first word header("MBED","Application Board"); - - // Horizontal line - lcd.Write((char)0x02, LCD_X); + + int pot = 0, old = 0; + bool update = true; - // Sample text - lcd.XY(0,2); - lcd.String(lorem); - lcd.Update(); + do { + + pot = Pot1 * 130; + if((old/2) != (pot/2)) update = true; // +-1 to eliminate jitter + old = pot; + + if (update) { + + lcd.Clear(1); + lcd.Clear(2); + lcd.Clear(3); + + lcd.XY(0,1); + lcd.Bar(LCD_X, pot / 128.0); + + if (fire) { + + lcd.Bold(true); + lcd.Invert(true); + lcd.XY(64-lcd.StringWidth(BANG)/2,3); + lcd.String(BANG); + lcd.Bold(false); + lcd.Invert(false); + + } else { + + lcd.XY(0,2); + lcd.String(lorem); + + } + + lcd.Update(); + update = false; + } + + wait(0.1); - while(1); + if (fire) { leds = 0xf; update = true; } else leds = joy; + + } while(1); } \ No newline at end of file