LCD driver simplification, 8 bytes saved (ST7565)

This commit is contained in:
JivaroFAD
2015-05-20 18:08:33 +02:00
parent 28812997ab
commit de13291db1
+5 -12
View File
@@ -36,13 +36,6 @@
#include "opentx.h" #include "opentx.h"
#define delay_1us() _delay_us(1)
#define delay_2us() _delay_us(2)
void delay_1_5us(uint16_t ms)
{
for (uint16_t i=0; i<ms; i++) delay_1us();
}
void lcdSendCtl(uint8_t val) void lcdSendCtl(uint8_t val)
{ {
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_CS1); PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_CS1);
@@ -76,7 +69,7 @@ const static pm_uchar lcdInitSequence[] PROGMEM =
#if defined(LCD_ST7565R) #if defined(LCD_ST7565R)
0xE2, //Initialize the internal functions 0xE2, //Initialize the internal functions
0xAE, //DON = 0: display OFF 0xAE, //DON = 0: display OFF
0xA0, //ADC = 0: normal direction(SEG132->SEG1) 0xA0, //ADC = 0: normal direction (SEG132->SEG1)
0xA6, //REV = 0: non-reverse display 0xA6, //REV = 0: non-reverse display
0xA4, //EON = 0: normal display. non-entire 0xA4, //EON = 0: normal display. non-entire
0xA2, //Select LCD bias 0xA2, //Select LCD bias
@@ -90,7 +83,7 @@ const static pm_uchar lcdInitSequence[] PROGMEM =
#elif defined(LCD_ERC12864FSF) #elif defined(LCD_ERC12864FSF)
0xE2, //Initialize the internal functions 0xE2, //Initialize the internal functions
0xAE, //DON = 0: display OFF 0xAE, //DON = 0: display OFF
0xA1, //ADC = 1: reverse direction(SEG132->SEG1) 0xA1, //ADC = 1: reverse direction (SEG132->SEG1)
0xA6, //REV = 0: non-reverse display 0xA6, //REV = 0: non-reverse display
0xA4, //EON = 0: normal display. non-entire 0xA4, //EON = 0: normal display. non-entire
0xA3, //Select LCD bias 0xA3, //Select LCD bias
@@ -126,12 +119,12 @@ inline void lcdInit()
{ {
LCD_LOCK(); LCD_LOCK();
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RES); //LCD reset PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RES); //LCD reset
delay_2us(); _delay_us(2);
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_RES); //LCD normal operation PORTC_LCD_CTRL |= (1<<OUT_C_LCD_RES); //LCD normal operation
#ifdef LCD_ST7920 #ifdef LCD_ST7920
_delay_ms(40); _delay_ms(40);
#else #else
delay_1_5us(1500); //TODO : verify if can be set to 40 ms instead of 1.5 ms _delay_us(1500);
#endif #endif
for (uint8_t i=0; i<DIM(lcdInitSequence); i++) { for (uint8_t i=0; i<DIM(lcdInitSequence); i++) {
lcdSendCtl(pgm_read_byte(&lcdInitSequence[i])) ; lcdSendCtl(pgm_read_byte(&lcdInitSequence[i])) ;
@@ -149,7 +142,7 @@ inline void lcdInit()
void lcdSetRefVolt(uint8_t val) void lcdSetRefVolt(uint8_t val)
{ {
#ifndef LCD_ST7920 //No contrast setting in the ST7920 controller #ifndef LCD_ST7920 //No contrast setting for ST7920
LCD_LOCK(); LCD_LOCK();
lcdSendCtl(0x81); lcdSendCtl(0x81);
lcdSendCtl(val); lcdSendCtl(val);