prefixed lcd functions

lcd uses basic now
This commit is contained in:
kiu 2011-05-21 01:12:09 +02:00
parent dd5b101589
commit 76e3cf789f
4 changed files with 50 additions and 40 deletions

View File

@ -3,7 +3,6 @@
#include "lpc134x.h"
#include "gpio/gpio.h"
/**************************************************************************/
/*!
Approximates a 1 millisecond delay using "nop". This is less
@ -30,14 +29,22 @@ void delayms(uint32_t ms)
/* Utility routines to manage nokia display */
/**************************************************************************/
uint8_t buffer[RESX*RESY_B];
uint8_t lcdBuffer[RESX*RESY_B];
/*
//TODO FIXME why doenst that work ?
#define CS RB_LCD_CS
#define SCK RB_SPI_SCK
#define SDA RB_SPI_MOSI
#define RST RB_LCD_RST
*/
#define CS 2,1
#define SCK 0,10
#define SDA 0,9
#define RST 2,2
void write(uint8_t cd, uint8_t data)
void lcdWrite(uint8_t cd, uint8_t data)
{
uint8_t i;
@ -67,7 +74,7 @@ void write(uint8_t cd, uint8_t data)
//delayms(0);
}
void read(uint8_t data)
void lcdRead(uint8_t data)
{
uint8_t i;
@ -106,7 +113,7 @@ void read(uint8_t data)
delayms(1);
}
void init(void)
void lcdInit(void)
{
IOCON_SWCLK_PIO0_10 = 0x51;
@ -124,34 +131,36 @@ void init(void)
gpioSetValue(RST, 1);
delayms(100);
write(0,0xE2);
lcdWrite(0,0xE2);
delayms(5);
write(0,0xAF);
write(0,0xA4);
write(0,0x2F);
write(0,0xB0);
write(0,0x10);
write(0,0x00);
lcdWrite(0,0xAF);
lcdWrite(0,0xA4);
lcdWrite(0,0x2F);
lcdWrite(0,0xB0);
lcdWrite(0,0x10);
lcdWrite(0,0x00);
uint16_t i;
for(i=0; i<100; i++)
write(1,0x00);
lcdWrite(1,0x00);
}
void fill(char f){
void lcdFill(char f){
int x;
for(x=0;x<RESX*RESY_B;x++)
buffer[x]=f;
for(x=0;x<RESX*RESY_B;x++) {
lcdBuffer[x]=f;
}
};
void display(uint32_t shift)
void lcdDisplay(uint32_t shift)
{
write(0,0xB0);
write(0,0x10);
write(0,0x00);
lcdWrite(0,0xB0);
lcdWrite(0,0x10);
lcdWrite(0,0x00);
uint16_t i,page;
for(page=0; page<RESY_B;page++)
for(i=0; i<RESX; i++)
write(1,buffer[page*RESX+((i+shift)%RESX)]);
for(page=0; page<RESY_B;page++) {
for(i=0; i<RESX; i++) {
lcdWrite(1,lcdBuffer[page*RESX+((i+shift)%RESX)]);
}
}
}

View File

@ -15,12 +15,12 @@
/* Display buffer */
extern uint8_t buffer[RESX*RESY_B];
extern uint8_t lcdBuffer[RESX*RESY_B];
void write(uint8_t cd, uint8_t data);
void read(uint8_t data);
void init(void);
void fill(char f);
void display(uint32_t shift);
void lcdWrite(uint8_t cd, uint8_t data);
void lcdRead(uint8_t data);
void lcdInit(void);
void lcdFill(char f);
void lcdDisplay(uint32_t shift);
#endif

View File

@ -100,7 +100,7 @@ int DoChar(int sx, int sy, char c){
flip(mask);
for(int m=1;m<=preblank;m++){
buffer[(rx-dmul*(m))+(yidx+y)*RESX]&=~mask;
lcdBuffer[(rx-dmul*(m))+(yidx+y)*RESX]&=~mask;
};
for(x=0;x<width;x++){
unsigned char b1,b2;
@ -117,11 +117,11 @@ int DoChar(int sx, int sy, char c){
if(font_direction==FONT_DIR_LTR)
flip(byte);
buffer[(rx+dmul*x)+(yidx+y)*RESX]&=~mask;
buffer[(rx+dmul*x)+(yidx+y)*RESX]|=byte;
lcdBuffer[(rx+dmul*x)+(yidx+y)*RESX]&=~mask;
lcdBuffer[(rx+dmul*x)+(yidx+y)*RESX]|=byte;
};
for(int m=0;m<blank;m++){
buffer[(rx+dmul*(x+m))+(yidx+y)*RESX]&=~mask;
lcdBuffer[(rx+dmul*(x+m))+(yidx+y)*RESX]&=~mask;
};
};
return sx-dmul*(x+preblank+blank);

13
main.c
View File

@ -1,12 +1,13 @@
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/render.h"
#include "lcd/smallfonts.h"
#include "lcd/ubuntu18.h"
#include "pmu/pmu.h"
#include "eeprom/eeprom.h"
#include "basic/basic.h"
void ReinvokeISP(void);
@ -22,7 +23,7 @@ int main(void) {
// initialise basic badge functions
rbInit();
init(); // display
lcdInit(); // display
//Make PIO1_11 an analog input
gpioSetDir(RB_LED3, gpioDirection_Input);
@ -30,8 +31,8 @@ int main(void) {
adcInit();
fill(255);
display(0);
lcdFill(255);
lcdDisplay(0);
uint32_t j=0;
//disable the JTAG on PIO3_3
@ -56,7 +57,7 @@ int main(void) {
uint8_t eeprom_val = 0;
while (1) {
display(j);
lcdDisplay(j);
delayms(10);
font=fonts[fontctr];
@ -93,7 +94,7 @@ int main(void) {
while(gpioGetValue(RB_LED3) == 0){
};
gpioSetValue (RB_LED3, 1);
fill(255);
lcdFill(255);
fontctr++;
if(fontctr > 2) {
fontctr = 0;