SG12864A

Dependents:   SG12864A_TestProgram

Committer:
shintamainjp
Date:
Tue Jul 20 07:23:15 2010 +0000
Revision:
3:86e7fba29623
Parent:
2:91c03e41c927
Child:
4:200d1ea4e76e

        

Who changed what in which revision?

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