Hi,
By datasheet this glcd 128x64 using ST7920 driver need at least 72us for each transaction except the clear command which needs 1.6ms.
I'm doing the time delays in my library and it's working ok, but what is interesting is that there's a master library by cbm80amiga which is found here:
Is not using delays ! when I compile the examples from this library, it works.
So I tried to remove the delays from my library but it failed !
So what's I'm missing ?
The master library init function is this:
void ST7920_SPI::init()
{
scrWd=SCR_WD/8;
scrHt=SCR_HT;
isNumberFun = &isNumber;
cr = 0;
cfont.font = NULL;
dualChar = 0;
pinMode(csPin, OUTPUT);
digitalWrite(csPin, LOW);
SPI.begin();
sendCmd(LCD_BASIC);
sendCmd(LCD_BASIC);
sendCmd(LCD_CLS); delay(2);
sendCmd(LCD_ADDRINC);
sendCmd(LCD_DISPLAYON);
setGfxMode(true);
}
My init function is this:
void glcd_init(void){
CO_BEGIN;
// #1
pinMode(CS_PIN, OUTPUT);
pinMode(CLK_PIN, OUTPUT);
pinMode(MOSI_PIN, OUTPUT);
digitalWrite(CS_PIN, LOW);
SPI.begin(); CO_DELAY(100000);
// #2
digitalWrite(CS_PIN, HIGH); CO_DELAY(40000);
// #3
glcd_cmd(FUNCTION_SET_BASIC); CO_DELAY(72);
glcd_cmd(FUNCTION_SET_BASIC); CO_DELAY(72);
glcd_cmd(DISPLAY_CLEAR); CO_DELAY(1600);
glcd_cmd(ENTERY_MODE); CO_DELAY(72);
glcd_cmd(DISPLAY_CONTROL); CO_DELAY(72);
glcd_task_flag = FINISHED;
CO_END;
}
As you notice I must use different delays to get the glcd to work.