2011-07-21 18:01:49 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2011-05-11 21:18:46 +00:00
|
|
|
#include <display.h>
|
|
|
|
#include <sysdefs.h>
|
|
|
|
#include "lpc134x.h"
|
2011-06-15 14:17:42 +00:00
|
|
|
#include "core/ssp/ssp.h"
|
2011-05-11 21:18:46 +00:00
|
|
|
#include "gpio/gpio.h"
|
2011-06-13 19:06:09 +00:00
|
|
|
#include "basic/basic.h"
|
2011-07-31 23:12:21 +00:00
|
|
|
#include "basic/config.h"
|
2011-06-27 08:43:46 +00:00
|
|
|
#include "usb/usbmsc.h"
|
2011-05-11 21:18:46 +00:00
|
|
|
|
2011-08-12 13:33:12 +00:00
|
|
|
|
2011-12-18 20:57:17 +00:00
|
|
|
#define DISPLAY_UNKNOWN 0
|
|
|
|
#define DISPLAY_N1200 1
|
|
|
|
#define DISPLAY_N1600 2
|
2011-08-12 13:33:12 +00:00
|
|
|
|
2011-05-11 21:18:46 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* Utility routines to manage nokia display */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2011-05-20 23:12:09 +00:00
|
|
|
uint8_t lcdBuffer[RESX*RESY_B];
|
2011-07-12 23:13:19 +00:00
|
|
|
uint32_t intstatus; // Caches USB interrupt state
|
|
|
|
// (need to disable MSC while displaying)
|
2011-12-18 20:57:17 +00:00
|
|
|
uint8_t displayType;
|
2011-05-20 23:12:09 +00:00
|
|
|
|
2011-06-15 14:17:42 +00:00
|
|
|
#define TYPE_CMD 0
|
|
|
|
#define TYPE_DATA 1
|
|
|
|
|
2011-07-24 12:08:52 +00:00
|
|
|
static void lcd_select() {
|
2011-07-10 13:32:20 +00:00
|
|
|
#if CFG_USBMSC
|
2011-06-27 08:43:46 +00:00
|
|
|
if(usbMSCenabled){
|
|
|
|
intstatus=USB_DEVINTEN;
|
|
|
|
USB_DEVINTEN=0;
|
|
|
|
};
|
2011-07-10 13:32:20 +00:00
|
|
|
#endif
|
2011-06-15 14:17:42 +00:00
|
|
|
/* the LCD requires 9-Bit frames */
|
|
|
|
uint32_t configReg = ( SSP_SSP0CR0_DSS_9BIT // Data size = 9-bit
|
|
|
|
| SSP_SSP0CR0_FRF_SPI // Frame format = SPI
|
|
|
|
| SSP_SSP0CR0_SCR_8); // Serial clock rate = 8
|
|
|
|
SSP_SSP0CR0 = configReg;
|
|
|
|
gpioSetValue(RB_LCD_CS, 0);
|
2011-05-11 21:18:46 +00:00
|
|
|
}
|
|
|
|
|
2011-07-24 12:08:52 +00:00
|
|
|
static void lcd_deselect() {
|
2011-06-15 14:17:42 +00:00
|
|
|
gpioSetValue(RB_LCD_CS, 1);
|
|
|
|
/* reset the bus to 8-Bit frames that everyone else uses */
|
|
|
|
uint32_t configReg = ( SSP_SSP0CR0_DSS_8BIT // Data size = 8-bit
|
|
|
|
| SSP_SSP0CR0_FRF_SPI // Frame format = SPI
|
|
|
|
| SSP_SSP0CR0_SCR_8); // Serial clock rate = 8
|
|
|
|
SSP_SSP0CR0 = configReg;
|
2011-07-10 13:32:20 +00:00
|
|
|
#if CFG_USBMSC
|
2011-06-27 08:43:46 +00:00
|
|
|
if(usbMSCenabled){
|
|
|
|
USB_DEVINTEN=intstatus;
|
|
|
|
};
|
2011-07-10 13:32:20 +00:00
|
|
|
#endif
|
2011-06-15 14:17:42 +00:00
|
|
|
}
|
2011-05-11 21:18:46 +00:00
|
|
|
|
2011-06-15 14:17:42 +00:00
|
|
|
static void lcdWrite(uint8_t cd, uint8_t data) {
|
|
|
|
uint16_t frame = 0x0;
|
|
|
|
|
|
|
|
frame = cd << 8;
|
|
|
|
frame |= data;
|
2011-05-11 21:18:46 +00:00
|
|
|
|
2011-06-15 14:17:42 +00:00
|
|
|
while ((SSP_SSP0SR & (SSP_SSP0SR_TNF_NOTFULL | SSP_SSP0SR_BSY_BUSY)) != SSP_SSP0SR_TNF_NOTFULL);
|
|
|
|
SSP_SSP0DR = frame;
|
|
|
|
while ((SSP_SSP0SR & (SSP_SSP0SR_BSY_BUSY|SSP_SSP0SR_RNE_NOTEMPTY)) != SSP_SSP0SR_RNE_NOTEMPTY);
|
|
|
|
/* clear the FIFO */
|
|
|
|
frame = SSP_SSP0DR;
|
2011-05-11 21:18:46 +00:00
|
|
|
}
|
|
|
|
|
2011-08-01 00:18:03 +00:00
|
|
|
#define CS 2,1
|
|
|
|
#define SCK 2,11
|
|
|
|
#define SDA 0,9
|
|
|
|
#define RST 2,2
|
|
|
|
|
|
|
|
uint8_t lcdRead(uint8_t data)
|
|
|
|
{
|
2011-08-21 23:19:42 +00:00
|
|
|
uint32_t op211cache=IOCON_PIO2_11;
|
|
|
|
uint32_t op09cache=IOCON_PIO0_9;
|
|
|
|
uint32_t dircache=GPIO_GPIO2DIR;
|
|
|
|
IOCON_PIO2_11=IOCON_PIO2_11_FUNC_GPIO|IOCON_PIO2_11_MODE_PULLUP;
|
|
|
|
IOCON_PIO0_9=IOCON_PIO0_9_FUNC_GPIO|IOCON_PIO0_9_MODE_PULLUP;
|
|
|
|
gpioSetDir(SCK, 1);
|
|
|
|
|
2011-08-01 00:18:03 +00:00
|
|
|
uint8_t i;
|
|
|
|
|
|
|
|
gpioSetDir(SDA, 1);
|
|
|
|
gpioSetValue(SCK, 0);
|
|
|
|
gpioSetValue(CS, 0);
|
|
|
|
delayms(1);
|
|
|
|
|
|
|
|
gpioSetValue(SDA, 0);
|
|
|
|
gpioSetValue(SCK, 1);
|
|
|
|
delayms(1);
|
|
|
|
|
|
|
|
for(i=0; i<8; i++){
|
|
|
|
gpioSetValue(SCK, 0);
|
|
|
|
delayms(1);
|
|
|
|
if( data & 0x80 )
|
|
|
|
gpioSetValue(SDA, 1);
|
|
|
|
else
|
|
|
|
gpioSetValue(SDA, 0);
|
|
|
|
data <<= 1;
|
|
|
|
gpioSetValue(SCK, 1);
|
|
|
|
delayms(1);
|
|
|
|
}
|
|
|
|
uint8_t ret = 0;
|
|
|
|
|
|
|
|
gpioSetDir(SDA, 0);
|
|
|
|
for(i=0; i<8; i++){
|
|
|
|
gpioSetValue(SCK, 0);
|
|
|
|
delayms(1);
|
|
|
|
ret <<= 1;
|
|
|
|
ret |= gpioGetValue(SDA);
|
|
|
|
gpioSetValue(SCK, 1);
|
|
|
|
delayms(1);
|
|
|
|
}
|
2011-08-21 23:19:42 +00:00
|
|
|
gpioSetValue(SCK, 0);
|
2011-08-01 00:18:03 +00:00
|
|
|
|
2011-08-21 23:19:42 +00:00
|
|
|
gpioSetValue(CS, 1);
|
2011-08-01 00:18:03 +00:00
|
|
|
gpioSetDir(SDA, 1);
|
2011-08-21 23:19:42 +00:00
|
|
|
IOCON_PIO2_11=op211cache;
|
|
|
|
IOCON_PIO0_9=op09cache;
|
|
|
|
GPIO_GPIO2DIR=dircache;
|
2011-08-01 00:18:03 +00:00
|
|
|
delayms(1);
|
2011-08-21 23:19:42 +00:00
|
|
|
return ret;
|
2011-08-01 00:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-15 14:17:42 +00:00
|
|
|
void lcdInit(void) {
|
2011-12-18 20:57:17 +00:00
|
|
|
int id1,id2,id3,id4;
|
|
|
|
|
2011-06-15 14:17:42 +00:00
|
|
|
sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge);
|
|
|
|
|
|
|
|
gpioSetValue(RB_LCD_CS, 1);
|
|
|
|
gpioSetValue(RB_LCD_RST, 1);
|
|
|
|
|
|
|
|
gpioSetDir(RB_LCD_CS, gpioDirection_Output);
|
|
|
|
gpioSetDir(RB_LCD_RST, gpioDirection_Output);
|
|
|
|
|
2011-05-11 21:18:46 +00:00
|
|
|
delayms(100);
|
2011-06-15 14:17:42 +00:00
|
|
|
gpioSetValue(RB_LCD_RST, 0);
|
2011-05-11 21:18:46 +00:00
|
|
|
delayms(100);
|
2011-06-15 14:17:42 +00:00
|
|
|
gpioSetValue(RB_LCD_RST, 1);
|
2011-05-11 21:18:46 +00:00
|
|
|
delayms(100);
|
|
|
|
|
2011-12-18 20:57:17 +00:00
|
|
|
id1=lcdRead(128+64+16+8 +2 ); // it will screw up everything.. better do it before anything else --the_nihilant
|
|
|
|
id2=lcdRead(128+64+16+8 +2+1); // .. but after the code above! --the_nihilant
|
|
|
|
// id3=lcdRead(128+64+16+8+4 ); // id1 and id2 are enough for most screens
|
|
|
|
// id4=lcdRead(128+64+16+8+4 +1); // id3 and id4 would only use up PRECIOUS SPACE --the_nihilant
|
2011-06-15 14:17:42 +00:00
|
|
|
|
2011-12-18 20:57:17 +00:00
|
|
|
lcd_select();
|
|
|
|
|
|
|
|
if((id1==69)&&(id2==214))displayType=DISPLAY_N1600;
|
|
|
|
//if((id1==254)&&(id2==2))displayType=DISPLAY_N1200;
|
|
|
|
else displayType=DISPLAY_N1200; // unknown displays are treated like N1200s anyway, this saves an if (PRECIOUS SPACE) --the_nihilant
|
|
|
|
|
2011-07-27 15:19:29 +00:00
|
|
|
/* Small Nokia 1200 LCD docs:
|
|
|
|
* clear/ set
|
|
|
|
* on 0xae / 0xaf
|
|
|
|
* invert 0xa6 / 0xa7
|
|
|
|
* mirror-x 0xA0 / 0xA1
|
|
|
|
* mirror-y 0xc7 / 0xc8
|
|
|
|
*
|
|
|
|
* 0x20+x contrast (0=black - 0x2e)
|
|
|
|
* 0x40+x offset in rows from top (-0x7f)
|
|
|
|
* 0x80+x contrast? (0=black -0x9f?)
|
|
|
|
* 0xd0+x black lines from top? (-0xdf?)
|
|
|
|
*
|
|
|
|
*/
|
2011-12-18 20:57:17 +00:00
|
|
|
if(displayType<=DISPLAY_N1200){
|
|
|
|
// lcdWrite(TYPE_CMD,0xE2);
|
|
|
|
// delayms(5);
|
|
|
|
uint8_t initseq[] = {0xE2,0xAF, // Display ON
|
|
|
|
0xA1, // Mirror-X
|
|
|
|
0xA4, 0x2F, 0xB0, 0x10};
|
|
|
|
int i = 0;
|
|
|
|
while(i<sizeof(initseq)){
|
2011-12-18 02:59:52 +00:00
|
|
|
lcdWrite(TYPE_CMD,initseq[i++]);
|
2011-12-18 20:57:17 +00:00
|
|
|
delayms(5); // this is only needed after the first command (0xE2), but doing like this saves space and it still works --the_nihilant
|
|
|
|
}
|
|
|
|
// lcdWrite(TYPE_CMD,0x00);
|
2011-12-18 21:05:00 +00:00
|
|
|
goto end;
|
|
|
|
}/*else if(displayType==DISPLAY_N1600)*/{
|
2011-12-18 20:57:17 +00:00
|
|
|
uint8_t initseq_d[] = {
|
|
|
|
0x36,
|
|
|
|
0x29, 0xBA, 0x07,
|
|
|
|
0x15,0x25, 0x3f,
|
|
|
|
0x11, 0x13, 0X37,
|
|
|
|
0x00, 0x3A, 0x05,
|
|
|
|
0x2A, 0, 98-1,
|
|
|
|
0x2B, 0, 70-1};
|
|
|
|
uint32_t initseq_c = ~/*0x95a7;*/0x12BA7; // this saves 12 bytes overall --the_nihilant
|
|
|
|
int i = 0;
|
|
|
|
//// delayms(10); // useless --the_nihilant
|
|
|
|
lcdWrite(TYPE_CMD,0x01); //sw reset
|
|
|
|
//// delayms(10); // useless
|
|
|
|
//// lcdWrite(TYPE_CMD,0x11); //sleepout (useless --the_nihilant)
|
|
|
|
delayms(10); // NOT useless! --the_nihilant
|
2011-08-12 13:33:12 +00:00
|
|
|
|
2011-12-18 20:57:17 +00:00
|
|
|
// lcdWrite(TYPE_CMD,0x36); //MADCTL MY MX V LAO RGB X X X
|
|
|
|
//// lcdWrite(TYPE_DATA,0x00); // useless
|
2011-08-12 13:33:12 +00:00
|
|
|
|
2011-12-18 20:57:17 +00:00
|
|
|
//// lcdWrite(TYPE_CMD,0x25); // contrast... useless (set below anyway)
|
|
|
|
//// lcdWrite(TYPE_DATA,0x3F);
|
|
|
|
//// delayms(10); // useless --the_nihilant
|
2011-12-18 02:59:52 +00:00
|
|
|
|
2011-12-18 20:57:17 +00:00
|
|
|
while(i<sizeof(initseq_d)){
|
|
|
|
lcdWrite(initseq_c&1, initseq_d[i++]);
|
|
|
|
initseq_c = initseq_c >> 1;
|
|
|
|
}
|
2011-12-18 02:59:52 +00:00
|
|
|
}
|
2011-12-18 21:05:00 +00:00
|
|
|
end:
|
2011-07-24 12:08:52 +00:00
|
|
|
lcd_deselect();
|
2011-05-11 21:18:46 +00:00
|
|
|
}
|
|
|
|
|
2011-05-20 23:12:09 +00:00
|
|
|
void lcdFill(char f){
|
2011-12-18 20:57:17 +00:00
|
|
|
// using memset saves 4 bytes compared with the loop!
|
|
|
|
memset(lcdBuffer,f,RESX*RESY_B);
|
|
|
|
/* int x;
|
2011-06-15 14:17:42 +00:00
|
|
|
for(x=0;x<RESX*RESY_B;x++) {
|
|
|
|
lcdBuffer[x]=f;
|
2011-12-18 20:57:17 +00:00
|
|
|
}*/
|
2011-05-11 21:18:46 +00:00
|
|
|
};
|
|
|
|
|
2011-12-18 20:57:17 +00:00
|
|
|
/* it's not used... it would have no footprint anyway as it's apparently removed anyway at some point (yes I tried, same size) --the_nihilant
|
2011-07-17 10:14:49 +00:00
|
|
|
void lcdSafeSetPixel(char x, char y, bool f){
|
2011-07-17 10:32:19 +00:00
|
|
|
if (x>=0 && x<RESX && y>=0 && y < RESY)
|
2011-07-17 10:14:49 +00:00
|
|
|
lcdSetPixel(x, y, f);
|
2011-12-18 20:57:17 +00:00
|
|
|
}*/
|
2011-07-17 10:14:49 +00:00
|
|
|
|
2011-06-13 17:55:51 +00:00
|
|
|
void lcdSetPixel(char x, char y, bool f){
|
2011-07-17 10:14:49 +00:00
|
|
|
if (x<0 || x> RESX || y<0 || y > RESY)
|
|
|
|
return;
|
2011-06-15 14:17:42 +00:00
|
|
|
char y_byte = (RESY-(y+1)) / 8;
|
|
|
|
char y_off = (RESY-(y+1)) % 8;
|
|
|
|
char byte = lcdBuffer[y_byte*RESX+(RESX-(x+1))];
|
|
|
|
if (f) {
|
|
|
|
byte |= (1 << y_off);
|
|
|
|
} else {
|
|
|
|
byte &= ~(1 << y_off);
|
|
|
|
}
|
|
|
|
lcdBuffer[y_byte*RESX+(RESX-(x+1))] = byte;
|
2011-06-13 17:55:51 +00:00
|
|
|
}
|
2011-06-14 00:20:15 +00:00
|
|
|
|
|
|
|
bool lcdGetPixel(char x, char y){
|
2011-06-15 14:17:42 +00:00
|
|
|
char y_byte = (RESY-(y+1)) / 8;
|
|
|
|
char y_off = (RESY-(y+1)) % 8;
|
|
|
|
char byte = lcdBuffer[y_byte*RESX+(RESX-(x+1))];
|
|
|
|
return byte & (1 << y_off);
|
2011-06-14 00:20:15 +00:00
|
|
|
}
|
|
|
|
|
2011-12-18 20:57:17 +00:00
|
|
|
|
|
|
|
static void _helper_pixel16(uint16_t color){ // putting this here saves a few bytes overall --the_nihilant
|
|
|
|
lcdWrite(TYPE_DATA,color>>8);
|
|
|
|
lcdWrite(TYPE_DATA,color&0xFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _helper_hline(uint16_t color){ // same for this --the_nihilant
|
|
|
|
for(int cx=0;cx<98;cx++) _helper_pixel16(color);
|
|
|
|
}
|
|
|
|
|
2011-08-12 13:33:12 +00:00
|
|
|
#define THECOLOR_R 0x0
|
2011-12-18 20:57:17 +00:00
|
|
|
#define THECOLOR_G 0x60
|
2011-08-12 13:33:12 +00:00
|
|
|
#define THECOLOR_B 0x0
|
|
|
|
|
2011-07-18 20:09:31 +00:00
|
|
|
void lcdDisplay(void) {
|
2011-07-09 21:23:33 +00:00
|
|
|
char byte;
|
2011-07-24 12:08:52 +00:00
|
|
|
lcd_select();
|
2011-06-15 14:17:42 +00:00
|
|
|
|
2011-12-18 20:57:17 +00:00
|
|
|
if(displayType<=DISPLAY_N1200){
|
|
|
|
lcdWrite(TYPE_CMD,0xB0);
|
|
|
|
lcdWrite(TYPE_CMD,0x10);
|
|
|
|
lcdWrite(TYPE_CMD,0x00);
|
|
|
|
uint16_t i,page;
|
|
|
|
for(page=0; page<RESY_B;page++) {
|
|
|
|
for(i=0; i<RESX; i++) {
|
|
|
|
if (GLOBAL(lcdmirror))
|
|
|
|
byte=lcdBuffer[page*RESX+RESX-1-(i)];
|
|
|
|
else
|
|
|
|
byte=lcdBuffer[page*RESX+(i)];
|
|
|
|
|
|
|
|
if (GLOBAL(lcdinvert))
|
|
|
|
byte=~byte;
|
|
|
|
|
|
|
|
lcdWrite(TYPE_DATA,byte);
|
|
|
|
}
|
|
|
|
}
|
2011-12-18 21:05:00 +00:00
|
|
|
goto end;
|
|
|
|
}/*else if(displayType==DISPLAY_N1600)*/{
|
2011-12-18 20:57:17 +00:00
|
|
|
unsigned char r=THECOLOR_R,g=THECOLOR_G,b=THECOLOR_B;
|
|
|
|
unsigned char br=0xFF, bg=0xFF, bb=0xFF;
|
|
|
|
unsigned char frame_r=0x00, frame_g=0x00, frame_b=0x80;
|
|
|
|
uint16_t color,framecolor,backcolor;
|
|
|
|
uint16_t x,y,i;
|
|
|
|
bool px;
|
|
|
|
uint16_t actualcolor;
|
|
|
|
color = ((r&0xF8) << 8) | ((g&0xFC)<<3) | ((b&0xF8) >> 3);
|
|
|
|
framecolor= ((frame_r&0xF8) << 8) | ((frame_g&0xFC)<<3) | ((frame_b&0xF8) >> 3);
|
|
|
|
backcolor= ((br&0xF8) << 8) | ((bg&0xFC)<<3) | ((bb&0xF8) >> 3);
|
|
|
|
|
|
|
|
lcdWrite(TYPE_CMD,0x2C);
|
|
|
|
|
|
|
|
//top line of the frame...
|
|
|
|
_helper_hline(framecolor);
|
|
|
|
|
|
|
|
for(y=RESY;y>0;y--){
|
|
|
|
//left line of the frame
|
|
|
|
_helper_pixel16(framecolor);
|
|
|
|
|
|
|
|
for(x=RESX;x>0;x--){
|
|
|
|
if(GLOBAL(lcdmirror))
|
|
|
|
px=lcdGetPixel(RESX-x+1,y-1);
|
|
|
|
else
|
|
|
|
px=lcdGetPixel(x-1,y-1);
|
|
|
|
|
|
|
|
if((!px)^(!GLOBAL(lcdinvert))) actualcolor=color;
|
|
|
|
else actualcolor=backcolor; /* white */
|
|
|
|
|
|
|
|
_helper_pixel16(actualcolor);
|
|
|
|
}
|
|
|
|
//right line of the frame
|
|
|
|
_helper_pixel16(framecolor);
|
|
|
|
}
|
|
|
|
|
|
|
|
//bottom line of the frame
|
|
|
|
_helper_hline(framecolor);
|
|
|
|
}
|
2011-12-18 21:05:00 +00:00
|
|
|
end:
|
2011-07-24 12:08:52 +00:00
|
|
|
lcd_deselect();
|
2011-05-11 21:18:46 +00:00
|
|
|
}
|
2011-08-03 17:08:44 +00:00
|
|
|
void lcdRefresh() __attribute__ ((weak, alias ("lcdDisplay")));
|
2011-05-22 15:48:02 +00:00
|
|
|
|
2011-07-09 21:23:33 +00:00
|
|
|
inline void lcdInvert(void) {
|
2011-07-31 16:15:44 +00:00
|
|
|
GLOBAL(lcdinvert)=!GLOBAL(lcdinvert);
|
2011-05-22 15:48:02 +00:00
|
|
|
}
|
|
|
|
|
2011-07-31 16:15:44 +00:00
|
|
|
void lcdSetContrast(int c) {
|
|
|
|
lcd_select();
|
2011-12-18 20:57:17 +00:00
|
|
|
if(displayType<=DISPLAY_N1200){
|
|
|
|
c+=0x80;
|
|
|
|
if(c>0x9F) goto end;
|
|
|
|
lcdWrite(TYPE_CMD,c);
|
2011-12-18 21:05:00 +00:00
|
|
|
goto end;
|
|
|
|
}/*else if(displayType==DISPLAY_N1600)*/{
|
2011-12-18 20:57:17 +00:00
|
|
|
if(c>=0x40) goto end;
|
|
|
|
lcdWrite(TYPE_CMD,0x25);
|
|
|
|
lcdWrite(TYPE_DATA,4*c);
|
|
|
|
}
|
|
|
|
end:
|
2011-08-12 13:33:12 +00:00
|
|
|
lcd_deselect();
|
2011-07-31 16:15:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void lcdSetInvert(int c) {
|
2011-12-18 20:57:17 +00:00
|
|
|
/* if it's just to force c to be either 0 or 1, it can be done more efficiently --the_nihilant
|
2011-07-31 16:15:44 +00:00
|
|
|
if(c>1)
|
|
|
|
c=1;
|
|
|
|
if(c<0)
|
|
|
|
c=1;
|
2011-12-18 20:57:17 +00:00
|
|
|
*/
|
|
|
|
c=(c&1)+0xa6; // like this --the_nihilant
|
2011-07-31 16:15:44 +00:00
|
|
|
lcd_select();
|
2011-12-18 20:57:17 +00:00
|
|
|
// if(displayType<=DISPLAY_N1200){ // it doesn't harm N1600 displays, does nothing. The if, on the other hand, uses PRECIOUS SPACE --the_nihilant
|
|
|
|
lcdWrite(TYPE_CMD,c);
|
|
|
|
// }
|
2011-07-31 16:15:44 +00:00
|
|
|
lcd_deselect();
|
|
|
|
};
|
|
|
|
|
|
|
|
/* deprecated */
|
|
|
|
void __attribute__((__deprecated__)) lcdToggleFlag(int flag) {
|
|
|
|
if(flag==LCD_MIRRORX)
|
|
|
|
GLOBAL(lcdmirror)=!GLOBAL(lcdmirror);
|
|
|
|
if(flag==LCD_INVERTED)
|
|
|
|
GLOBAL(lcdinvert)=!GLOBAL(lcdinvert);
|
|
|
|
}
|
2011-07-19 00:43:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
void lcdShiftH(bool right, bool wrap) {
|
|
|
|
uint8_t tmp;
|
|
|
|
for (int yb = 0; yb<RESY_B; yb++) {
|
|
|
|
if (right) {
|
|
|
|
tmp = lcdBuffer[yb*RESX];
|
|
|
|
memmove(lcdBuffer + yb*RESX,lcdBuffer + yb*RESX+1 ,RESX-1);
|
2011-07-21 20:21:41 +00:00
|
|
|
lcdBuffer[yb*RESX+(RESX-1)] = wrap?tmp:0;
|
2011-07-19 00:43:15 +00:00
|
|
|
} else {
|
|
|
|
tmp = lcdBuffer[yb*RESX+(RESX-1)];
|
|
|
|
memmove(lcdBuffer + yb*RESX+1,lcdBuffer + yb*RESX ,RESX-1);
|
2011-07-21 20:21:41 +00:00
|
|
|
lcdBuffer[yb*RESX] = wrap?tmp:0;
|
2011-07-19 00:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcdShiftV8(bool up, bool wrap) {
|
|
|
|
uint8_t tmp[RESX];
|
2011-07-21 20:27:08 +00:00
|
|
|
if (!up) {
|
2011-07-21 20:21:41 +00:00
|
|
|
if (wrap)
|
|
|
|
memmove(tmp, lcdBuffer, RESX);
|
|
|
|
else
|
|
|
|
memset(tmp,0,RESX);
|
2011-07-19 00:43:15 +00:00
|
|
|
memmove(lcdBuffer,lcdBuffer+RESX ,RESX*(RESY_B-1));
|
2011-07-21 20:21:41 +00:00
|
|
|
memmove(lcdBuffer+RESX*(RESY_B-1),tmp,RESX);
|
2011-07-19 00:43:15 +00:00
|
|
|
} else {
|
2011-07-21 20:21:41 +00:00
|
|
|
if (wrap)
|
|
|
|
memmove(tmp, lcdBuffer+RESX*(RESY_B-1), RESX);
|
|
|
|
else
|
|
|
|
memset(tmp,0,RESX);
|
2011-07-19 00:43:15 +00:00
|
|
|
memmove(lcdBuffer+RESX,lcdBuffer ,RESX*(RESY_B-1));
|
2011-07-21 20:21:41 +00:00
|
|
|
memmove(lcdBuffer,tmp,RESX);
|
2011-07-19 00:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcdShiftV(bool up, bool wrap) {
|
|
|
|
uint8_t tmp[RESX];
|
|
|
|
if (up) {
|
2011-07-21 20:21:41 +00:00
|
|
|
if (wrap)
|
|
|
|
memmove(tmp,lcdBuffer+((RESY_B-1)*RESX),RESX);
|
|
|
|
else
|
|
|
|
memset(tmp,0,RESX);
|
2011-07-19 00:43:15 +00:00
|
|
|
for (int x = 0; x<RESX; x++){
|
|
|
|
for (int y = RESY_B-1; y > 0; y--){
|
|
|
|
lcdBuffer[x+(y*RESX)] = (lcdBuffer[x+(y*RESX)] << 1) |( lcdBuffer[x+((y-1)*RESX)] >> 7);
|
|
|
|
}
|
2011-07-21 20:21:41 +00:00
|
|
|
lcdBuffer[x] = ( lcdBuffer[x] << 1) | ((tmp[x]>>3)&1);
|
2011-07-19 00:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2011-07-21 20:21:41 +00:00
|
|
|
if (wrap)
|
|
|
|
memmove(tmp,lcdBuffer,RESX);
|
|
|
|
else
|
|
|
|
memset(tmp,0,RESX);
|
2011-07-19 00:43:15 +00:00
|
|
|
for (int x = 0; x<RESX; x++){
|
|
|
|
for (int y = 0; y < (RESY_B-1); y++){
|
|
|
|
lcdBuffer[x+(y*RESX)] = (lcdBuffer[x+(y*RESX)] >> 1) |( lcdBuffer[x+((y+1)*RESX)] << 7);
|
|
|
|
}
|
2011-07-21 20:21:41 +00:00
|
|
|
lcdBuffer[x+((RESY_B-1)*RESX)] = ( lcdBuffer[x+((RESY_B-1)*RESX)] >> 1) | ((tmp[x]<<3)&8);
|
2011-07-19 00:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcdShift(int x, int y, bool wrap) {
|
2011-07-21 18:01:49 +00:00
|
|
|
bool dir=true;
|
2011-07-19 00:43:15 +00:00
|
|
|
|
2011-07-21 18:01:49 +00:00
|
|
|
if(x<0){
|
|
|
|
dir=false;
|
|
|
|
x=-x;
|
|
|
|
};
|
|
|
|
|
|
|
|
while(x-->0)
|
|
|
|
lcdShiftH(dir, wrap);
|
|
|
|
|
|
|
|
if(y<0){
|
|
|
|
dir=false;
|
|
|
|
y=-y;
|
|
|
|
}else{
|
|
|
|
dir=true;
|
|
|
|
};
|
|
|
|
|
|
|
|
while(y>=8){
|
|
|
|
y-=8;
|
|
|
|
lcdShiftV8(dir, wrap);
|
|
|
|
};
|
|
|
|
|
|
|
|
while(y-->0)
|
2011-07-19 00:43:15 +00:00
|
|
|
lcdShiftV(dir, wrap);
|
|
|
|
}
|
2011-07-27 15:19:29 +00:00
|
|
|
|