Base LCDPanel based, required for all LCDPanel drivers

LCDPanel.h

Committer:
silviogissi
Date:
2012-03-09
Revision:
1:073d4f161f23
Parent:
0:3f345274c737
Child:
2:ab4040a7e8c9

File content as of revision 1:073d4f161f23:

/*
Placeholder for Copyright notice, etc

Author: silviogissi
*/

#ifndef LCDPANEL_BASE_H
#define LCDPANEL_BASE_H

#include "mbed.h"

class LCDPanel {

  public:
    LCDPanel(unsigned int width, unsigned int height, PinName cs);

    virtual void fill(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int color);
    virtual void fill(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const unsigned int* color);
    virtual void set_pixel(unsigned int x, unsigned int y, unsigned int color);
    
    inline unsigned int height() { return _ymax+1; }
    inline unsigned int width() { return _xmax+1; }
    
  protected:
    unsigned int _ymax;
    unsigned int _xmax;
    DigitalOut _cs;
    
    class CsTransaction
    {
        private: LCDPanel *p;
        public:
            CsTransaction(LCDPanel *panel) : p(panel) { p->_cs=0; }
            ~CsTransaction() { p->_cs=1; }
    };
     
    virtual void pixel(unsigned int color)=0;
    virtual void window(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)=0;

};

#endif // LCDPANEL_BASE_H