Base LCDPanel based, required for all LCDPanel drivers

LCDPanel.cpp

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

File content as of revision 0:3f345274c737:

/*
Placeholder for Copyright notice, etc

Author: silviogissi
*/
#include "LCDPanel.h"

 LCDPanel::LCDPanel(unsigned int width, unsigned int height) : _ymax(height-1), _xmax(width-1)
 {
 }

// Default implementation, pixel by pixel
void LCDPanel::fill(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int color) {
    CsTransaction(*this);
    if (x1>x2) {unsigned int tmp=x1; x1=x2; x2=tmp;}
    if (y1>y2) {unsigned int tmp=y1; y1=y2; y2=tmp;}
    window(x1,y1,x2,y2);
    for(unsigned int i=0;i<(x2-x1)*(y2-y1);i++) { pixel(color); }    
}

// Default implementation, pixel by pixel
void LCDPanel::fill(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const unsigned int* color) {
    CsTransaction(*this);
    if (x1>x2) {unsigned int tmp=x1; x1=x2; x2=tmp;}
    if (y1>y2) {unsigned int tmp=y1; y1=y2; y2=tmp;}
    window(x1,y1,x2,y2);
    for(unsigned int i=0;i<(x2-x1)*(y2-y1);i++) { pixel(color[i]); }    
}

void LCDPanel::set_pixel(unsigned int x, unsigned int y, unsigned int color) {
    CsTransaction(*this);
    window(x,y,1,1);
    pixel(x,y,color);
}