SG12864A

Dependents:   SG12864A_TestProgram

Committer:
shintamainjp
Date:
Tue Aug 10 12:52:53 2010 +0000
Revision:
5:4d86043f7942
Parent:
4:200d1ea4e76e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shintamainjp 5:4d86043f7942 1 /**
shintamainjp 5:4d86043f7942 2 * sample program for SG12864A Graphics LCD module driver class (Version 0.0.1)
shintamainjp 5:4d86043f7942 3 *
shintamainjp 5:4d86043f7942 4 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
shintamainjp 5:4d86043f7942 5 * http://shinta.main.jp/
shintamainjp 5:4d86043f7942 6 *
shintamainjp 5:4d86043f7942 7 * See also ...
shintamainjp 5:4d86043f7942 8 * http://mbed.org/users/shintamainjp/notebook/sg12864asunlike-display-graphics-lcd-driver/
shintamainjp 5:4d86043f7942 9 */
shintamainjp 5:4d86043f7942 10
shintamainjp 5:4d86043f7942 11 #include "mbed.h"
shintamainjp 5:4d86043f7942 12 #include "SG12864A.h"
shintamainjp 5:4d86043f7942 13
shintamainjp 5:4d86043f7942 14 int main() {
shintamainjp 5:4d86043f7942 15
shintamainjp 5:4d86043f7942 16 SG12864A lcd(p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18);
shintamainjp 5:4d86043f7942 17 #if 0
shintamainjp 5:4d86043f7942 18 lcd.clear();
shintamainjp 5:4d86043f7942 19 lcd.reset();
shintamainjp 5:4d86043f7942 20
shintamainjp 5:4d86043f7942 21 {
shintamainjp 5:4d86043f7942 22 static const int pages = 8;
shintamainjp 5:4d86043f7942 23 static const int columns = 64;
shintamainjp 5:4d86043f7942 24 for (int i = 0; i < pages; i++) {
shintamainjp 5:4d86043f7942 25 lcd.setPageAddress(SG12864A::CS1, i);
shintamainjp 5:4d86043f7942 26 lcd.setPageAddress(SG12864A::CS2, i);
shintamainjp 5:4d86043f7942 27 for (int j = 0; j < columns; j++) {
shintamainjp 5:4d86043f7942 28 uint8_t n = 1 << (j % 8);
shintamainjp 5:4d86043f7942 29 lcd.setColumnAddress(SG12864A::CS1, j);
shintamainjp 5:4d86043f7942 30 lcd.setColumnAddress(SG12864A::CS2, j);
shintamainjp 5:4d86043f7942 31 lcd.writeData(SG12864A::CS1, n);
shintamainjp 5:4d86043f7942 32 lcd.writeData(SG12864A::CS2, n);
shintamainjp 5:4d86043f7942 33 }
shintamainjp 5:4d86043f7942 34 }
shintamainjp 5:4d86043f7942 35 }
shintamainjp 5:4d86043f7942 36
shintamainjp 5:4d86043f7942 37 uint8_t n = 0;
shintamainjp 5:4d86043f7942 38 while (1) {
shintamainjp 5:4d86043f7942 39 lcd.setDisplayStartLine(SG12864A::CS1, n);
shintamainjp 5:4d86043f7942 40 lcd.setDisplayStartLine(SG12864A::CS2, n);
shintamainjp 5:4d86043f7942 41 n++;
shintamainjp 5:4d86043f7942 42 wait_ms(100);
shintamainjp 5:4d86043f7942 43 }
shintamainjp 5:4d86043f7942 44 #else
shintamainjp 5:4d86043f7942 45 lcd.clear();
shintamainjp 5:4d86043f7942 46 lcd.reset();
shintamainjp 5:4d86043f7942 47 bool reverse = false;
shintamainjp 5:4d86043f7942 48 while (1) {
shintamainjp 5:4d86043f7942 49 //
shintamainjp 5:4d86043f7942 50 lcd.bufferClear(reverse);
shintamainjp 5:4d86043f7942 51 lcd.bufferDrawLine(0, 0, SG12864A::PIXEL_X - 1, SG12864A::PIXEL_Y - 1, reverse);
shintamainjp 5:4d86043f7942 52 lcd.bufferDrawLine(0, SG12864A::PIXEL_Y - 1, SG12864A::PIXEL_X - 1, 0, reverse);
shintamainjp 5:4d86043f7942 53 lcd.bufferDrawString(1, 1, "This is a test #1.\b", reverse);
shintamainjp 5:4d86043f7942 54 lcd.bufferDrawCheckbox(50, 50, 60, 60, true, reverse);
shintamainjp 5:4d86043f7942 55 lcd.bufferPush();
shintamainjp 5:4d86043f7942 56 wait_ms(1000);
shintamainjp 5:4d86043f7942 57
shintamainjp 5:4d86043f7942 58 //
shintamainjp 5:4d86043f7942 59 lcd.bufferClear(reverse);
shintamainjp 5:4d86043f7942 60 lcd.bufferDrawBox(0, 0, SG12864A::PIXEL_X - 1, SG12864A::PIXEL_Y - 1, reverse);
shintamainjp 5:4d86043f7942 61 lcd.bufferDrawString(1, 2, "This is a test #2.\b", reverse);
shintamainjp 5:4d86043f7942 62 lcd.bufferDrawCheckbox(50, 50, 60, 60, false, reverse);
shintamainjp 5:4d86043f7942 63 lcd.bufferPush();
shintamainjp 5:4d86043f7942 64 wait_ms(1000);
shintamainjp 5:4d86043f7942 65
shintamainjp 5:4d86043f7942 66 #if 0
shintamainjp 5:4d86043f7942 67 //
shintamainjp 5:4d86043f7942 68 lcd.bufferClear(reverse);
shintamainjp 5:4d86043f7942 69 lcd.bufferFillBox(0, 0, SG12864A::PIXEL_X - 1, SG12864A::PIXEL_Y - 1, reverse);
shintamainjp 5:4d86043f7942 70 lcd.bufferDrawString(1, 3, "This is a test #3.\b", reverse);
shintamainjp 5:4d86043f7942 71 lcd.bufferDrawCheckbox(50, 50, 60, 60, true, reverse);
shintamainjp 5:4d86043f7942 72 lcd.bufferPush();
shintamainjp 5:4d86043f7942 73 wait_ms(1000);
shintamainjp 5:4d86043f7942 74 #endif
shintamainjp 5:4d86043f7942 75
shintamainjp 5:4d86043f7942 76 //
shintamainjp 5:4d86043f7942 77 {
shintamainjp 5:4d86043f7942 78 lcd.bufferClear(reverse);
shintamainjp 5:4d86043f7942 79 int min = 0;
shintamainjp 5:4d86043f7942 80 int max = 100;
shintamainjp 5:4d86043f7942 81 for (int i = min; i <= max; i++) {
shintamainjp 5:4d86043f7942 82 lcd.bufferDrawProgressbar(10, 10, 118, 20, min, max, i, reverse);
shintamainjp 5:4d86043f7942 83 lcd.bufferPush();
shintamainjp 5:4d86043f7942 84 wait_ms(2);
shintamainjp 5:4d86043f7942 85 }
shintamainjp 5:4d86043f7942 86 }
shintamainjp 5:4d86043f7942 87
shintamainjp 5:4d86043f7942 88 //
shintamainjp 5:4d86043f7942 89 {
shintamainjp 5:4d86043f7942 90 lcd.bufferClear(reverse);
shintamainjp 5:4d86043f7942 91 int min = -100;
shintamainjp 5:4d86043f7942 92 int max = 100;
shintamainjp 5:4d86043f7942 93 for (int i = min; i <= max; i++) {
shintamainjp 5:4d86043f7942 94 lcd.bufferDrawProgressbar(10, 10, 118, 20, min, max, i, reverse);
shintamainjp 5:4d86043f7942 95 lcd.bufferPush();
shintamainjp 5:4d86043f7942 96 wait_ms(2);
shintamainjp 5:4d86043f7942 97 }
shintamainjp 5:4d86043f7942 98 }
shintamainjp 5:4d86043f7942 99
shintamainjp 5:4d86043f7942 100 //
shintamainjp 5:4d86043f7942 101 {
shintamainjp 5:4d86043f7942 102 lcd.bufferClear(reverse);
shintamainjp 5:4d86043f7942 103 int min = 100;
shintamainjp 5:4d86043f7942 104 int max = 600;
shintamainjp 5:4d86043f7942 105 for (int i = min; i <= max; i++) {
shintamainjp 5:4d86043f7942 106 lcd.bufferDrawProgressbar(10, 10, 118, 20, min, max, i, reverse);
shintamainjp 5:4d86043f7942 107 lcd.bufferPush();
shintamainjp 5:4d86043f7942 108 wait_ms(2);
shintamainjp 5:4d86043f7942 109 }
shintamainjp 5:4d86043f7942 110 }
shintamainjp 5:4d86043f7942 111
shintamainjp 5:4d86043f7942 112 //
shintamainjp 5:4d86043f7942 113 reverse = !reverse;
shintamainjp 5:4d86043f7942 114 }
shintamainjp 5:4d86043f7942 115 #endif
shintamainjp 5:4d86043f7942 116 }