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