SG12864A
Dependents: SG12864A_TestProgram
main.cpp@2:91c03e41c927, 2010-07-20 (annotated)
- Committer:
- shintamainjp
- Date:
- Tue Jul 20 05:30:47 2010 +0000
- Revision:
- 2:91c03e41c927
- Parent:
- 1:aacd73a4e7ee
- Child:
- 3:86e7fba29623
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:aacd73a4e7ee | 44 | while (1) { |
shintamainjp | 1:aacd73a4e7ee | 45 | // |
shintamainjp | 1:aacd73a4e7ee | 46 | lcd.bufferClear(); |
shintamainjp | 1:aacd73a4e7ee | 47 | lcd.bufferDrawLine(0, 0, SG12864A::PIXEL_X - 1, SG12864A::PIXEL_Y - 1); |
shintamainjp | 1:aacd73a4e7ee | 48 | lcd.bufferDrawLine(0, SG12864A::PIXEL_Y - 1, SG12864A::PIXEL_X - 1, 0); |
shintamainjp | 2:91c03e41c927 | 49 | lcd.bufferDrawString(1, 1, "This is a test #1.\b"); |
shintamainjp | 1:aacd73a4e7ee | 50 | lcd.bufferPush(); |
shintamainjp | 1:aacd73a4e7ee | 51 | wait_ms(1000); |
shintamainjp | 2:91c03e41c927 | 52 | |
shintamainjp | 1:aacd73a4e7ee | 53 | // |
shintamainjp | 1:aacd73a4e7ee | 54 | lcd.bufferClear(); |
shintamainjp | 1:aacd73a4e7ee | 55 | lcd.bufferDrawBox(0, 0, SG12864A::PIXEL_X - 1, SG12864A::PIXEL_Y - 1); |
shintamainjp | 2:91c03e41c927 | 56 | lcd.bufferDrawString(1, 2, "This is a test #2.\b"); |
shintamainjp | 1:aacd73a4e7ee | 57 | lcd.bufferPush(); |
shintamainjp | 1:aacd73a4e7ee | 58 | wait_ms(1000); |
shintamainjp | 2:91c03e41c927 | 59 | |
shintamainjp | 1:aacd73a4e7ee | 60 | // |
shintamainjp | 1:aacd73a4e7ee | 61 | lcd.bufferClear(); |
shintamainjp | 1:aacd73a4e7ee | 62 | lcd.bufferFillBox(0, 0, SG12864A::PIXEL_X - 1, SG12864A::PIXEL_Y - 1); |
shintamainjp | 2:91c03e41c927 | 63 | lcd.bufferDrawString(1, 3, "This is a test #3.\b"); |
shintamainjp | 1:aacd73a4e7ee | 64 | lcd.bufferPush(); |
shintamainjp | 1:aacd73a4e7ee | 65 | wait_ms(1000); |
shintamainjp | 1:aacd73a4e7ee | 66 | } |
shintamainjp | 1:aacd73a4e7ee | 67 | #endif |
shintamainjp | 0:238f2d048222 | 68 | } |