Example of how to use an Ada Fruit RGB LCD with the Ada Fruit RGB LCD Shield Library

Dependencies:   AdaFruit_RGBLCDShield MCP23017 mbed RTclock

Dependents:   SX1276_GPS

Fork of MCP_test by Wim Huiskamp

Updated the Adafruit RGB LCD Shield test app with a module system.

It pulls in RTclock which is another library I did for controlling the DS1307 RTC in a sane way (marries stdlib time and the RTC together cleanly). You don't need an RTC to run the example, it'll just use stdlib time instead. This class also maps RTC to system time, so if you loose the RTC the mbed will free run.

Four modules are defined in the modules folder plus the module base class. These examples provide:

  • title menu item
  • time menu item (updates automatically)
  • date menu item
  • fake temp menu item

Press select to switch modes: menu->cursor->change

Menu switches menu items going up/down. Cursor allows you to move around editable fields using the cursor keys / marker. Change allows you to move left/right on a particular line and change values by using up/down on an item with the blink box.

Custom fonts are defined for UI arrows and degree character.

If you want a menu item to update over time then you need to implement the canRefresh() member function in any child module you derive from class Module. Make it return true to receive update requests in your show() member function. Date and time both check when refreshing to see if anything has changed, then update.

main() registers a table of modules with the MenuManager. Others can be added easily by creating children derived from the Module base class..

Depending on what you want to do you may need to adjust the loop wait time in MenuManager::loop(). If you don't balance this based on work you need to do then the key presses may get a little lively. I may adjust the key checking to be fixed to 200ms regardless of loop wait time, however the catch there is that you'll consume more power the more loops you do so the wait is still important.

Happy coding!

Committer:
vtraveller
Date:
Fri Oct 10 11:10:56 2014 +0000
Revision:
28:fbcd3bac0cd7
Parent:
21:c44cfd3259c0
Reduced write delay - faster LCD response

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vtraveller 10:3fcab08717fc 1 #ifndef __TEMPMODULE_H__
vtraveller 10:3fcab08717fc 2 #define __TEMPMODULE_H__
vtraveller 10:3fcab08717fc 3
vtraveller 20:93c70a1869ee 4 #include "mbed.h"
vtraveller 10:3fcab08717fc 5 #include "module.h"
vtraveller 10:3fcab08717fc 6
vtraveller 10:3fcab08717fc 7 class TempModule
vtraveller 10:3fcab08717fc 8 : public Module
vtraveller 10:3fcab08717fc 9 {
vtraveller 10:3fcab08717fc 10 public:
vtraveller 21:c44cfd3259c0 11 TempModule
vtraveller 21:c44cfd3259c0 12 (
vtraveller 21:c44cfd3259c0 13 Serial & in_cDisplay,
vtraveller 21:c44cfd3259c0 14 I2C & in_cI2C,
vtraveller 21:c44cfd3259c0 15 uint8_t in_nAddress
vtraveller 21:c44cfd3259c0 16 );
vtraveller 10:3fcab08717fc 17 virtual ~TempModule();
vtraveller 10:3fcab08717fc 18
vtraveller 20:93c70a1869ee 19 virtual bool canRefresh() { return true; }
vtraveller 21:c44cfd3259c0 20 virtual bool isValid() { return m_bValid; }
vtraveller 15:d1eaddb363be 21 virtual void show(bool in_bRefresh);
vtraveller 17:731a47339cb8 22
vtraveller 11:96146db429de 23 protected:
vtraveller 20:93c70a1869ee 24 float readTempC();
vtraveller 20:93c70a1869ee 25 uint16_t read16(uint8_t in_nRegister);
vtraveller 20:93c70a1869ee 26 void write16(uint8_t in_nRegister, uint16_t in_nValue);
vtraveller 20:93c70a1869ee 27
vtraveller 21:c44cfd3259c0 28 I2C & m_cI2C;
vtraveller 20:93c70a1869ee 29 uint8_t m_nAddress;
vtraveller 21:c44cfd3259c0 30 bool m_bValid;
vtraveller 10:3fcab08717fc 31 };
vtraveller 10:3fcab08717fc 32
vtraveller 10:3fcab08717fc 33 #endif /* __TEMPMODULE_H__ */