Revert "Remove unnecessary commands from N1600 initialization; refactor display memory write setup to use macros"

This reverts commit e66910638d.
This commit is contained in:
Stefan `Sec` Zehl 2012-02-06 21:00:37 +01:00
parent 5d5ba8c4a7
commit a3091ff683
1 changed files with 21 additions and 34 deletions

View File

@ -56,15 +56,14 @@ static const struct display_macro INIT_N1200[] = {
{COMMAND_TYPE_CMD, 0x10}, {COMMAND_TYPE_CMD, 0x10},
}; };
static const struct display_macro PREPARE_N1200[] = {
{COMMAND_TYPE_CMD, 0xB0},
{COMMAND_TYPE_CMD, 0x10},
{COMMAND_TYPE_CMD, 0x00},
};
/* Decoded: /* Decoded:
* CMD 36: MADCTL (argument missing!)
* CMD 29: DISPON * CMD 29: DISPON
* CMD BA: Data order (1) * CMD BA: Data order (1)
* DAT 07: ignored?
* CMD 15: undefined?
* DAT 25: ignored?
* DAT 3F: ignored?
* CMD 11: sleep out * CMD 11: sleep out
* CMD 13: normal display mode on * CMD 13: normal display mode on
* CMD 37: set scroll entry point * CMD 37: set scroll entry point
@ -80,8 +79,13 @@ static const struct display_macro PREPARE_N1200[] = {
*/ */
static const struct display_macro INIT_N1600[] = { static const struct display_macro INIT_N1600[] = {
{COMMAND_TYPE_CMD, 0x01, 10}, {COMMAND_TYPE_CMD, 0x01, 10},
{COMMAND_TYPE_CMD, 0x36},
{COMMAND_TYPE_CMD, 0x29}, {COMMAND_TYPE_CMD, 0x29},
{COMMAND_TYPE_CMD, 0xBA}, {COMMAND_TYPE_CMD, 0xBA},
{COMMAND_TYPE_DATA, 0x07},
{COMMAND_TYPE_CMD, 0x15},
{COMMAND_TYPE_DATA, 0x25},
{COMMAND_TYPE_DATA, 0x3F},
{COMMAND_TYPE_CMD, 0x11}, {COMMAND_TYPE_CMD, 0x11},
{COMMAND_TYPE_CMD, 0x13}, {COMMAND_TYPE_CMD, 0x13},
{COMMAND_TYPE_CMD, 0x37}, {COMMAND_TYPE_CMD, 0x37},
@ -96,30 +100,14 @@ static const struct display_macro INIT_N1600[] = {
{COMMAND_TYPE_DATA, 70-1}, {COMMAND_TYPE_DATA, 70-1},
}; };
static const struct display_macro PREPARE_N1600[] = {
{COMMAND_TYPE_CMD, 0x2C},
};
struct display_descriptor { struct display_descriptor {
/* Macro to execute in order to initialize the display from scratch */
const struct display_macro * init_macro; const struct display_macro * init_macro;
int init_macro_length; int init_macro_length;
/* Macro to execute to prepare the display for sending raw contents */
const struct display_macro * prepare_macro;
int prepare_macro_length;
}; };
const struct display_descriptor DISPLAY_DESCRIPTORS[] = { const struct display_descriptor DISPLAY_DESCRIPTORS[] = {
[DISPLAY_TYPE_N1200] = { [DISPLAY_TYPE_N1200] = { INIT_N1200, sizeof(INIT_N1200)/sizeof(INIT_N1200[0]) },
INIT_N1200, sizeof(INIT_N1200)/sizeof(INIT_N1200[0]), [DISPLAY_TYPE_N1600] = { INIT_N1600, sizeof(INIT_N1600)/sizeof(INIT_N1600[0]) },
PREPARE_N1200, sizeof(PREPARE_N1200)/sizeof(PREPARE_N1200[0])
},
[DISPLAY_TYPE_N1600] = {
INIT_N1600, sizeof(INIT_N1600)/sizeof(INIT_N1600[0]),
PREPARE_N1600, sizeof(PREPARE_N1600)/sizeof(PREPARE_N1600[0])
},
}; };
/**************************************************************************/ /**************************************************************************/
@ -233,13 +221,6 @@ uint8_t lcdRead(uint8_t data)
return ret; return ret;
} }
static void lcdExecuteMacro(const struct display_macro *macro, int macro_length)
{
for(int i=0; i<macro_length; i++) {
lcdWrite(macro[i].type, macro[i].data);
delayms(macro[i].delay_after);
}
}
void lcdInit(void) { void lcdInit(void) {
int id; int id;
@ -268,7 +249,10 @@ void lcdInit(void) {
displayDescriptor = DISPLAY_DESCRIPTORS + displayType; displayDescriptor = DISPLAY_DESCRIPTORS + displayType;
lcd_select(); lcd_select();
lcdExecuteMacro(displayDescriptor->init_macro, displayDescriptor->init_macro_length); for(int i=0; i<displayDescriptor->init_macro_length; i++) {
lcdWrite(displayDescriptor->init_macro[i].type, displayDescriptor->init_macro[i].data);
delayms(displayDescriptor->init_macro[i].delay_after);
}
lcd_deselect(); lcd_deselect();
} }
@ -326,9 +310,10 @@ void lcdDisplay(void) {
char byte; char byte;
lcd_select(); lcd_select();
lcdExecuteMacro(displayDescriptor->prepare_macro, displayDescriptor->prepare_macro_length);
if(displayType==DISPLAY_TYPE_N1200){ if(displayType==DISPLAY_TYPE_N1200){
lcdWrite(COMMAND_TYPE_CMD,0xB0);
lcdWrite(COMMAND_TYPE_CMD,0x10);
lcdWrite(COMMAND_TYPE_CMD,0x00);
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++) {
@ -347,6 +332,8 @@ void lcdDisplay(void) {
uint16_t x,y; uint16_t x,y;
bool px; bool px;
lcdWrite(COMMAND_TYPE_CMD,0x2C);
//top line of the frame... //top line of the frame...
_helper_hline(COLOR_FRAME); _helper_hline(COLOR_FRAME);