SG12864A

Dependents:   SG12864A_TestProgram

SG12864A.h

Committer:
shintamainjp
Date:
2010-07-20
Revision:
1:aacd73a4e7ee
Parent:
0:238f2d048222
Child:
2:91c03e41c927

File content as of revision 1:aacd73a4e7ee:

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

#ifndef _SG12864A_H_
#define _SG12864A_H_

#include "mbed.h"

/**
 */
class SG12864A {
public:
    SG12864A(
        PinName di,
        PinName rw,
        PinName en,
        PinName db0,
        PinName db1,
        PinName db2,
        PinName db3,
        PinName db4,
        PinName db5,
        PinName db6,
        PinName db7,
        PinName cs1,
        PinName cs2,
        PinName res);
    ~SG12864A();
    enum Target {
        CS1,
        CS2
    };
    void bufferPush(void);
    void bufferPull(void);
    void bufferClear(void);
    void bufferDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
    void bufferDrawBox(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
    void bufferFillBox(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);

    void reset(void);
    void clear(void);
    
    void setDisplayOnOff(Target t, bool on);
    void setDisplayStartLine(Target t, uint8_t displayStartLine);
    void setPageAddress(Target t, uint8_t addr);
    void setColumnAddress(Target t, uint8_t addr);
    void readStatus(Target t, uint8_t *c);
    void writeData(Target t, uint8_t c);
    void readData(Target t, uint8_t *c);
    static const int PIXEL_X = 128;
    static const int PIXEL_Y = 64;
private:
    static const int PAGES = 8;
    static const int COLUMNS = 64;
    uint8_t buffer[PAGES * COLUMNS * 2];
    DigitalOut ioDI;
    DigitalOut ioRW;
    DigitalOut ioEN;
    BusInOut ioDB;
    DigitalOut ioCS1;
    DigitalOut ioCS2;
    DigitalOut ioRES;
    enum Mode {
        Data,
        Instruction
    };
    void setDirectionToRead();
    void setDirectionToWrite();
    void write(Target t, Mode m, uint8_t c);
    void read(Target t, Mode m, uint8_t *c);
    void reset(bool b);
};

#endif