Coordinate safe SetPixel. I will need it.

This commit is contained in:
Stefan `Sec` Zehl 2011-07-17 12:14:49 +02:00
parent 33af906622
commit 932455ccd3
2 changed files with 8 additions and 0 deletions

View File

@ -100,7 +100,14 @@ void lcdFill(char f){
} }
}; };
void lcdSafeSetPixel(char x, char y, bool f){
if (x>=0 && x<=RESX && y>=0 && y <= RESY)
lcdSetPixel(x, y, f);
}
void lcdSetPixel(char x, char y, bool f){ void lcdSetPixel(char x, char y, bool f){
if (x<0 || x> RESX || y<0 || y > RESY)
return;
char y_byte = (RESY-(y+1)) / 8; char y_byte = (RESY-(y+1)) / 8;
char y_off = (RESY-(y+1)) % 8; char y_off = (RESY-(y+1)) % 8;
char byte = lcdBuffer[y_byte*RESX+(RESX-(x+1))]; char byte = lcdBuffer[y_byte*RESX+(RESX-(x+1))];

View File

@ -26,6 +26,7 @@ void lcdDisplay(uint32_t shift);
void lcdInvert(void); void lcdInvert(void);
void lcdToggleFlag(int flag); void lcdToggleFlag(int flag);
void lcdSetPixel(char x, char y, bool f); void lcdSetPixel(char x, char y, bool f);
void lcdSafeSetPixel(char x, char y, bool f);
bool lcdGetPixel(char x, char y); bool lcdGetPixel(char x, char y);
#endif #endif