This Library for DOGS-102 Graphic LCD module. Based on Igor Skochinsky's "DOGLCDDemo" program.

Dependents:   DOGS102_Example1 DOGS102_Example2

Fork of DOGLCDDemo by Igor Skochinsky

LCD/DogLCD.h

Committer:
ban4jp
Date:
2014-05-03
Revision:
1:2145a74df666
Parent:
0:2a5dccfd318f

File content as of revision 1:2145a74df666:

#ifndef MBED_DOGLCD_H
#define MBED_DOGLCD_H

#include "AbstractLCD.h"

/***********
 * Module for Electronic Assembly's DOGL128-6 display module
 * Should be compatible with other modules using ST7565 controller
 ***********/
 
#define LCDWIDTH 102
#define LCDHEIGHT 64
#define LCDPAGES  (LCDHEIGHT+7)/8

//#define ENABLE_DOGLCD_POWERCTL
//#define READJUST_SPI_FREQUENCY

/*

 Each page is 8 lines, one byte per column
 
         Col0
        +---+--
        | 0 |
Page 0  | 1 |
        | 2 |
        | 3 |
        | 4 |
        | 5 |
        | 6 |
        | 7 |
        +---+--
*/

/*
  LCD interface class.
  Usage: 
    DogLCD dog(spi, pin_power, pin_cs, pin_a0, pin_reset);
    where spi is an instance of SPI class
*/

class DogLCD: public AbstractLCD
{
    SPI& _spi;
#ifdef ENABLE_DOGLCD_POWERCTL
    DigitalOut _cs, _a0, _reset, _power;
#else
    DigitalOut _cs, _a0, _reset;
#endif
    int _updating;
    void _send_commands(const unsigned char* buf, size_t size);
    void _send_data(const unsigned char* buf, size_t size);
    void _set_xy(int x, int y);
    unsigned char _framebuffer[LCDWIDTH*LCDPAGES];
public:
#ifdef ENABLE_DOGLCD_POWERCTL
    DogLCD(SPI& spi, PinName cs, PinName a0, PinName reset, PinName power):
    _spi(spi), _cs(cs), _a0(a0), _reset(reset), _power(power), _updating(0)
    {
    }
#else
    DogLCD(SPI& spi, PinName cs, PinName a0, PinName reset):
    _spi(spi), _cs(cs), _a0(a0), _reset(reset), _updating(0)
    {
    }
#endif
    // initialize and turn on the display
    void init();
    // send a 128x64 picture for the whole screen
    void send_pic(const unsigned char* data);
    // clear screen
    void clear_screen();
    // turn all pixels on
    void all_on(bool on = true);
    
    // AbstractLCD methods
    virtual int width()  {return LCDWIDTH;};
    virtual int height() {return LCDHEIGHT;};
    virtual void pixel(int x, int y, int colour);
    virtual void fill(int x, int y, int width, int height, int colour);
    virtual void beginupdate();
    virtual void endupdate();
};

#endif