Demo program for driving the memory LCD on the Zero Gecko Starter Kit.

Dependencies:   MemoryLCD mbed

This demo program shows how to drive the memory LCD on the Zero Gecko Starter Kit, by using asynchronous transfers.

Information

All examples in this repo are considered EXPERIMENTAL QUALITY, meaning this code has been created as one-off proof-of-concept and is suitable as a demonstration for experimental purposes only. This code will not be regularly maintained by Silicon Labs and there is no guarantee that these projects will work across all environments, SDK versions and hardware.

Committer:
stevew817
Date:
Fri Apr 17 19:36:10 2015 +0000
Revision:
6:f334f0adb99b
Parent:
0:ecfcdf193e3d
Update pinout for ZG

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stevew817 0:ecfcdf193e3d 1 #include "LS013B7DH03.h"
stevew817 0:ecfcdf193e3d 2 #include "mbed_logo.h"
stevew817 0:ecfcdf193e3d 3 /******************** Define I/O *****************************/
stevew817 0:ecfcdf193e3d 4 DigitalOut myled(LED1);
stevew817 0:ecfcdf193e3d 5
stevew817 6:f334f0adb99b 6 #define SCK PC15
stevew817 6:f334f0adb99b 7 #define MOSI PD7
stevew817 0:ecfcdf193e3d 8
stevew817 6:f334f0adb99b 9 DigitalOut CS(PE11);
stevew817 6:f334f0adb99b 10 DigitalOut EXTCOM(PE10);
stevew817 6:f334f0adb99b 11 DigitalOut DISP(PA10);
stevew817 6:f334f0adb99b 12 DigitalOut DISP_SEL(PA8);
stevew817 0:ecfcdf193e3d 13
stevew817 0:ecfcdf193e3d 14 SPI displaySPI(MOSI, NC, SCK);
stevew817 0:ecfcdf193e3d 15 silabs::LS013B7DH03 display(&displaySPI, &CS, &EXTCOM);
stevew817 0:ecfcdf193e3d 16
stevew817 0:ecfcdf193e3d 17 /******************** Define Timers *****************************/
stevew817 0:ecfcdf193e3d 18
stevew817 0:ecfcdf193e3d 19 LowPowerTicker timeKeeping;
stevew817 0:ecfcdf193e3d 20
stevew817 0:ecfcdf193e3d 21 /***************** Define global variables **********************/
stevew817 0:ecfcdf193e3d 22 #define INIT_SECONDS 17600
stevew817 0:ecfcdf193e3d 23
stevew817 0:ecfcdf193e3d 24 volatile uint32_t prevSeconds = INIT_SECONDS, seconds = INIT_SECONDS;
stevew817 0:ecfcdf193e3d 25 volatile bool refreshed = false;
stevew817 0:ecfcdf193e3d 26
stevew817 0:ecfcdf193e3d 27 /***************** Define callback handlers *********************/
stevew817 0:ecfcdf193e3d 28 void secondsCallback(void);
stevew817 0:ecfcdf193e3d 29 void refreshCallback(void);
stevew817 0:ecfcdf193e3d 30
stevew817 0:ecfcdf193e3d 31 void secondsCallback(void) {
stevew817 0:ecfcdf193e3d 32 seconds++;
stevew817 0:ecfcdf193e3d 33 }
stevew817 0:ecfcdf193e3d 34
stevew817 0:ecfcdf193e3d 35 /**
stevew817 0:ecfcdf193e3d 36 * Callback for refresh completion
stevew817 0:ecfcdf193e3d 37 */
stevew817 0:ecfcdf193e3d 38 void refreshCallback(void) {
stevew817 0:ecfcdf193e3d 39 refreshed = true;
stevew817 0:ecfcdf193e3d 40 }
stevew817 0:ecfcdf193e3d 41
stevew817 0:ecfcdf193e3d 42 /*************************** MAIN *******************************/
stevew817 0:ecfcdf193e3d 43 int main() {
stevew817 0:ecfcdf193e3d 44 // Enable the LCD
stevew817 6:f334f0adb99b 45 DISP_SEL = 1;
stevew817 0:ecfcdf193e3d 46 DISP = 1;
stevew817 0:ecfcdf193e3d 47
stevew817 0:ecfcdf193e3d 48 // Start generating the 1Hz call for keeping time
stevew817 0:ecfcdf193e3d 49 timeKeeping.attach(&secondsCallback, 1.0f);
stevew817 0:ecfcdf193e3d 50
stevew817 0:ecfcdf193e3d 51 // Reset the LCD to a blank state. (All white)
stevew817 0:ecfcdf193e3d 52 refreshed = false;
stevew817 0:ecfcdf193e3d 53 display.clearImmediate(refreshCallback);
stevew817 0:ecfcdf193e3d 54 while(refreshed == false) sleep();
stevew817 0:ecfcdf193e3d 55
stevew817 0:ecfcdf193e3d 56 printf("Initialization done! \n");
stevew817 0:ecfcdf193e3d 57
stevew817 0:ecfcdf193e3d 58 // Apply mbed logo bitmap to the pixel buffer
stevew817 0:ecfcdf193e3d 59 display.showBMP((uint8_t*)mbed_enabled_logo, 128, 128, 0, 0);
stevew817 0:ecfcdf193e3d 60 display.printf("I like MBED!");
stevew817 0:ecfcdf193e3d 61
stevew817 0:ecfcdf193e3d 62 // Push update to the display
stevew817 0:ecfcdf193e3d 63 refreshed = false;
stevew817 0:ecfcdf193e3d 64 display.update(refreshCallback);
stevew817 0:ecfcdf193e3d 65
stevew817 0:ecfcdf193e3d 66 // Sleep while doing the transmit
stevew817 0:ecfcdf193e3d 67 while(refreshed == false) sleep();
stevew817 0:ecfcdf193e3d 68
stevew817 0:ecfcdf193e3d 69 // Go into clock mode
stevew817 0:ecfcdf193e3d 70 while(1) {
stevew817 0:ecfcdf193e3d 71 sleep();
stevew817 0:ecfcdf193e3d 72
stevew817 0:ecfcdf193e3d 73 // In clock mode, only update once per second
stevew817 0:ecfcdf193e3d 74 if(prevSeconds != seconds) {
stevew817 0:ecfcdf193e3d 75 display.locate(4,15);
stevew817 0:ecfcdf193e3d 76 display.printf("%02d:%02d:%02d", (seconds / 1200) % 24, (seconds / 60) % 60, seconds % 60);
stevew817 0:ecfcdf193e3d 77 if(refreshed == true) {
stevew817 0:ecfcdf193e3d 78 prevSeconds = seconds;
stevew817 0:ecfcdf193e3d 79 refreshed = false;
stevew817 0:ecfcdf193e3d 80 display.update(refreshCallback);
stevew817 0:ecfcdf193e3d 81 }
stevew817 0:ecfcdf193e3d 82 }
stevew817 0:ecfcdf193e3d 83 }
stevew817 0:ecfcdf193e3d 84 }