SG12864A

Dependents:   SG12864A_TestProgram

main.cpp

Committer:
shintamainjp
Date:
2010-07-20
Revision:
2:91c03e41c927
Parent:
1:aacd73a4e7ee
Child:
3:86e7fba29623

File content as of revision 2:91c03e41c927:

/**
 * SG12864A Graphics LCD module driver class (Version 0.0.1)
 *
 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
 * http://shinta.main.jp/
 */

#include "mbed.h"
#include "SG12864A.h"

int main() {

    SG12864A lcd(p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18);
#if 0
    lcd.clear();
    lcd.reset();

    {
        static const int pages = 8;
        static const int columns = 64;
        for (int i = 0; i < pages; i++) {
            lcd.setPageAddress(SG12864A::CS1, i);
            lcd.setPageAddress(SG12864A::CS2, i);
            for (int j = 0; j < columns; j++) {
                uint8_t n = 1 << (j % 8);
                lcd.setColumnAddress(SG12864A::CS1, j);
                lcd.setColumnAddress(SG12864A::CS2, j);
                lcd.writeData(SG12864A::CS1, n);
                lcd.writeData(SG12864A::CS2, n);
            }
        }
    }

    uint8_t n = 0;
    while (1) {
        lcd.setDisplayStartLine(SG12864A::CS1, n);
        lcd.setDisplayStartLine(SG12864A::CS2, n);
        n++;
        wait_ms(100);
    }
#else
    lcd.clear();
    lcd.reset();
    while (1) {
        //
        lcd.bufferClear();
        lcd.bufferDrawLine(0, 0, SG12864A::PIXEL_X - 1, SG12864A::PIXEL_Y - 1);
        lcd.bufferDrawLine(0, SG12864A::PIXEL_Y - 1, SG12864A::PIXEL_X - 1, 0);
        lcd.bufferDrawString(1, 1, "This is a test #1.\b");
        lcd.bufferPush();
        wait_ms(1000);

        //
        lcd.bufferClear();
        lcd.bufferDrawBox(0, 0, SG12864A::PIXEL_X - 1, SG12864A::PIXEL_Y - 1);
        lcd.bufferDrawString(1, 2, "This is a test #2.\b");
        lcd.bufferPush();
        wait_ms(1000);

        //
        lcd.bufferClear();
        lcd.bufferFillBox(0, 0, SG12864A::PIXEL_X - 1, SG12864A::PIXEL_Y - 1);
        lcd.bufferDrawString(1, 3, "This is a test #3.\b");
        lcd.bufferPush();
        wait_ms(1000);
    }
#endif
}