From a67bde079c40653333f4c35045cb407ec89d92f9 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 11 Jun 2012 00:00:07 +0200 Subject: [PATCH] cleanups --- drivers/ssd1289_lld.c | 4 ++++ drivers/ssd1289_lld.h | 11 ++++++----- glcd.c | 37 ++++++++++--------------------------- glcd.h | 5 ++--- touchpad.h | 1 + 5 files changed, 23 insertions(+), 35 deletions(-) diff --git a/drivers/ssd1289_lld.c b/drivers/ssd1289_lld.c index 495a4fc7..d07b6742 100644 --- a/drivers/ssd1289_lld.c +++ b/drivers/ssd1289_lld.c @@ -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; } diff --git a/drivers/ssd1289_lld.h b/drivers/ssd1289_lld.h index dfe52165..650ceb04 100644 --- a/drivers/ssd1289_lld.h +++ b/drivers/ssd1289_lld.h @@ -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); diff --git a/glcd.c b/glcd.c index 0819687c..17a501c9 100644 --- a/glcd.c +++ b/glcd.c @@ -2,11 +2,16 @@ #include "fonts.h" #include -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; -} - diff --git a/glcd.h b/glcd.h index 0f4c7f8c..4fc375c6 100644 --- a/glcd.h +++ b/glcd.h @@ -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); diff --git a/touchpad.h b/touchpad.h index ce88e3cc..e6fbcb50 100644 --- a/touchpad.h +++ b/touchpad.h @@ -3,6 +3,7 @@ #include "ch.h" #include "hal.h" +#include "glcd.h" #define CONVERSIONS 3