Issue 204 fixed (Tx Batt spoken) [X9D] It was impossible to avoid a Format on EEPROM Alert [all] Function v1==x modified to v1~=x (needs to be tested) Developers list updated
132 lines
3.9 KiB
C++
132 lines
3.9 KiB
C++
/*
|
|
* Authors (alphabetical order)
|
|
* - Andre Bernet <bernet.andre@gmail.com>
|
|
* - Andreas Weitl
|
|
* - Bertrand Songis <bsongis@gmail.com>
|
|
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
|
* - Cameron Weeks <th9xer@gmail.com>
|
|
* - Erez Raviv
|
|
* - Gabriel Birkus
|
|
* - Jean-Pierre Parisy
|
|
* - Karl Szmutny
|
|
* - Michael Blandford
|
|
* - Michal Hlavinka
|
|
* - Pat Mackenzie
|
|
* - Philip Moss
|
|
* - Rob Thomson
|
|
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
|
* - Thomas Husterer
|
|
*
|
|
* open9x is based on code named
|
|
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
|
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
|
* and the original (and ongoing) project by
|
|
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#include "open9x.h"
|
|
|
|
#define delay_1us() _delay_us(1)
|
|
void delay_1_5us(int ms)
|
|
{
|
|
for(int i=0; i<ms; i++) delay_1us();
|
|
}
|
|
|
|
void lcdSendCtl(uint8_t val)
|
|
{
|
|
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_CS1);
|
|
#ifdef LCD_MULTIPLEX
|
|
DDRA = 0xFF; // set LCD_DAT pins to output
|
|
#endif
|
|
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_A0);
|
|
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW);
|
|
PORTA_LCD_DAT = val;
|
|
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_E);
|
|
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
|
|
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0);
|
|
#ifdef LCD_MULTIPLEX
|
|
DDRA = 0x00; // set LCD_DAT pins to input
|
|
#endif
|
|
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_CS1);
|
|
}
|
|
|
|
#if defined(PCBSTD) && defined(VOICE)
|
|
volatile uint8_t LcdLock ;
|
|
#define LCD_LOCK() LcdLock = 1
|
|
#define LCD_UNLOCK() LcdLock = 0
|
|
#else
|
|
#define LCD_LOCK()
|
|
#define LCD_UNLOCK()
|
|
#endif
|
|
|
|
inline void lcdInit()
|
|
{
|
|
// /home/thus/txt/datasheets/lcd/KS0713.pdf
|
|
// ~/txt/flieger/ST7565RV17.pdf from http://www.glyn.de/content.asp?wdid=132&sid=
|
|
|
|
LCD_LOCK();
|
|
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RES); //LCD_RES
|
|
delay_1us();
|
|
delay_1us();// f520 call 0xf4ce delay_1us() ; 0x0xf4ce
|
|
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_RES); // f524 sbi 0x15, 2 IOADR-PORTC_LCD_CTRL; 21 1
|
|
delay_1_5us(1500);
|
|
lcdSendCtl(0xe2); //Initialize the internal functions
|
|
lcdSendCtl(0xae); //DON = 0: display OFF
|
|
lcdSendCtl(0xa1); //ADC = 1: reverse direction(SEG132->SEG1)
|
|
lcdSendCtl(0xA6); //REV = 0: non-reverse display
|
|
lcdSendCtl(0xA4); //EON = 0: normal display. non-entire
|
|
lcdSendCtl(0xA2); // Select LCD bias=0
|
|
lcdSendCtl(0xC0); //SHL = 0: normal direction (COM1->COM64)
|
|
lcdSendCtl(0x2F); //Control power circuit operation VC=VR=VF=1
|
|
lcdSendCtl(0x25); //Select int resistance ratio R2 R1 R0 =5
|
|
lcdSendCtl(0x81); //Set reference voltage Mode
|
|
lcdSendCtl(0x22); // 24 SV5 SV4 SV3 SV2 SV1 SV0 = 0x18
|
|
lcdSendCtl(0xAF); //DON = 1: display ON
|
|
g_eeGeneral.contrast = 0x22;
|
|
LCD_UNLOCK();
|
|
}
|
|
|
|
void lcdSetRefVolt(uint8_t val)
|
|
{
|
|
LCD_LOCK();
|
|
lcdSendCtl(0x81);
|
|
lcdSendCtl(val);
|
|
LCD_UNLOCK();
|
|
}
|
|
|
|
void lcdRefresh()
|
|
{
|
|
LCD_LOCK();
|
|
uint8_t *p=displayBuf;
|
|
for(uint8_t y=0; y < 8; y++) {
|
|
lcdSendCtl(0x04);
|
|
lcdSendCtl(0x10); //column addr 0
|
|
lcdSendCtl( y | 0xB0); //page addr y
|
|
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_CS1);
|
|
#ifdef LCD_MULTIPLEX
|
|
DDRA = 0xFF; // set LCD_DAT pins to output
|
|
#endif
|
|
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0);
|
|
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_RnW);
|
|
for (xcoord_t x=LCD_W; x>0; --x) {
|
|
PORTA_LCD_DAT = *p++;
|
|
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_E);
|
|
PORTC_LCD_CTRL &= ~(1<<OUT_C_LCD_E);
|
|
}
|
|
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_A0);
|
|
PORTC_LCD_CTRL |= (1<<OUT_C_LCD_CS1);
|
|
}
|
|
LCD_UNLOCK();
|
|
}
|
|
|