Support for x-inverted display

This commit is contained in:
Stefan `Sec` Zehl 2011-07-09 23:23:33 +02:00
parent 51286999ea
commit b726d0d7bd
3 changed files with 25 additions and 8 deletions

View File

@ -11,7 +11,7 @@
/**************************************************************************/ /**************************************************************************/
uint8_t lcdBuffer[RESX*RESY_B]; uint8_t lcdBuffer[RESX*RESY_B];
int inverted = 0; int lcd_layout = 0;
uint32_t intstatus; uint32_t intstatus;
#define TYPE_CMD 0 #define TYPE_CMD 0
@ -115,6 +115,7 @@ bool lcdGetPixel(char x, char y){
} }
void lcdDisplay(uint32_t shift) { void lcdDisplay(uint32_t shift) {
char byte;
select(); select();
lcdWrite(TYPE_CMD,0xB0); lcdWrite(TYPE_CMD,0xB0);
@ -123,18 +124,25 @@ void lcdDisplay(uint32_t shift) {
uint16_t i,page; uint16_t i,page;
for(page=0; page<RESY_B;page++) { for(page=0; page<RESY_B;page++) {
for(i=0; i<RESX; i++) { for(i=0; i<RESX; i++) {
if (inverted) { if (lcd_layout & LCD_MIRRORX)
lcdWrite(TYPE_DATA,~lcdBuffer[page*RESX+((i+shift)%RESX)]); byte=lcdBuffer[page*RESX+RESX-((i+shift)%RESX)];
} else { else
lcdWrite(TYPE_DATA,lcdBuffer[page*RESX+((i+shift)%RESX)]); byte=lcdBuffer[page*RESX+((i+shift)%RESX)];
}
if (lcd_layout & LCD_INVERTED)
byte=~byte;
lcdWrite(TYPE_DATA,byte);
} }
} }
deselect(); deselect();
} }
void lcdInvert(void) { inline void lcdInvert(void) {
inverted = ~inverted; lcdToggleFlag(LCD_INVERTED);
} }
void lcdToggleFlag(int flag) {
lcd_layout=lcd_layout ^ flag;
}

View File

@ -13,6 +13,9 @@
#define RESY 68 #define RESY 68
#define RESY_B 9 #define RESY_B 9
#define LCD_INVERTED (1<<0)
#define LCD_MIRRORX (1<<1)
#define LCD_MIRRORY (1<<2)
/* Display buffer */ /* Display buffer */
extern uint8_t lcdBuffer[RESX*RESY_B]; extern uint8_t lcdBuffer[RESX*RESY_B];
@ -21,6 +24,7 @@ void lcdInit(void);
void lcdFill(char f); void lcdFill(char f);
void lcdDisplay(uint32_t shift); void lcdDisplay(uint32_t shift);
void lcdInvert(void); void lcdInvert(void);
void lcdToggleFlag(int flag);
void lcdSetPixel(char x, char y, bool f); void lcdSetPixel(char x, char y, bool f);
bool lcdGetPixel(char x, char y); bool lcdGetPixel(char x, char y);

5
firmware/lcd/lcd.h Normal file
View File

@ -0,0 +1,5 @@
#include "lcd/allfonts.h"
#include "lcd/backlight.h"
#include "lcd/decoder.h"
#include "lcd/display.h"
#include "lcd/render.h"