This commit is contained in:
Tectu 2012-06-11 00:00:07 +02:00
parent 12427eb272
commit a67bde079c
5 changed files with 23 additions and 35 deletions

View File

@ -217,6 +217,10 @@ void lld_lcdInit(void) {
lcdWriteReg(0x004e,0x0000); lcdDelay(5);
}
uint16_t lld_lcdGetOrientation(void) {
return orientation;
}
uint16_t lld_lcdGetHeight(void) {
return lcd_height;
}

View File

@ -1,17 +1,18 @@
#ifndef SSD1289_H
#define SSD1289_H
#include "glcd.h"
#ifndef LCD_USE_SSD1289
uint16_t lld_lcdInit(void);
#include "glcd.h"
void lld_lcdInit(void);
void lld_lcdSetCursor(uint16_t x, uint16_t y);
void lld_lcdSetOrientation(uint8_t newOrientation);
void lld_lcdSetWindow(x0, y0, x1, y1);
void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
void lld_lcdClear(uint16_t color);
void lld_lcdDrawPixel(uint16_t x, uint16_ty, uint16_t color);
void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color);
uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y);
uint16_t lld_lcdGetOrientation(void);
uint16_t lld_lcdGetHeight(void);
uint16_t lld_lcdGetWidth(void);

37
glcd.c
View File

@ -2,11 +2,16 @@
#include "fonts.h"
#include <math.h>
extern uint8_t orientation;
uint16_t DeviceCode;
uint8_t font_width = 8, font_height = 16;
uint16_t lcd_width, lcd_height;
void lcdInit(void) {
lld_lcdInit();
lcd_width = SCREEN_WIDTH;
lcd_height = SCREEN_HEIGHT;
}
uint16_t lcdGetHeight(void) {
return lld_lcdGetHeight();
}
@ -15,6 +20,10 @@ uint16_t lcdGetWidth(void) {
return lld_lcdGetWidth();
}
uint16_t lcdGetOrientation(void) {
return lld_lcdGetOrientation();
}
static void lcdSetCursor(uint16_t x, uint16_t y) {
lld_lcdSetCursor(x, y);
}
@ -23,10 +32,6 @@ void lcdSetOrientation(uint8_t newOrientation) {
lld_lcdSetOrientation(newOrientation);
}
uint16_t lcdGetOrientation(void) {
return orientation;
}
void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
lld_lcdSetWindow(x0, y0, x1, y1);
}
@ -238,25 +243,3 @@ void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint
} while(a <= b);
}
void lcdTest(void) {
uint16_t x;
uint8_t y;
uint8_t r,g,b;
for(y = 0; y < lcd_height; y++) {
for(x = 0; x < lcd_width; x++) {
r = x + y;
g = x - y;
b = y - x;
lcdDrawPixel(y, x, RGB565CONVERT(r,g,b));
}
}
}
void lcdInit() {
lld_lcdInit();
lcd_height = SCREEN_HEIGHT;
lcd_width = SCREEN_WIDTH;
}

5
glcd.h
View File

@ -5,8 +5,8 @@
#include "hal.h"
#include "drivers/ssd1289_lld.h"
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv)
#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv)
@ -40,7 +40,6 @@ enum filled {frame, filled};
void lcdInit(void);
void lcdClear(uint16_t color);
void lcdTest(void);
void lcdSetOrientation(uint8_t newOrientation);
void lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
void lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);

View File

@ -3,6 +3,7 @@
#include "ch.h"
#include "hal.h"
#include "glcd.h"
#define CONVERSIONS 3