From 7b2e0d06d4cd8a472a9162460f5cf8d2d263cee4 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 28 Nov 2012 22:40:23 +0100 Subject: [PATCH] ILI9320 landscape mode --- drivers/gdisp/ILI9320/gdisp_lld.c | 43 +++++++++++++++---- .../ginput/touch/ADS7843/ginput_lld_mouse.c | 4 +- ...input_lld_mouse_board_firebull_stm32f103.h | 2 +- .../touch/ADS7843/ginput_lld_mouse_config.h | 4 +- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/drivers/gdisp/ILI9320/gdisp_lld.c b/drivers/gdisp/ILI9320/gdisp_lld.c index 5ca5dceb..ada0f27d 100644 --- a/drivers/gdisp/ILI9320/gdisp_lld.c +++ b/drivers/gdisp/ILI9320/gdisp_lld.c @@ -237,8 +237,23 @@ static void lld_lcdSetCursor(uint16_t x, uint16_t y) { addr = y * 0x100 + x; - lld_lcdWriteReg(0x0020, addr & 0xff); /* low addr */ - lld_lcdWriteReg(0x0021, (addr >> 8) & 0x1ff); /* high addr */ + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + lld_lcdWriteReg(0x0020, addr & 0xff); /* low addr */ + lld_lcdWriteReg(0x0021, (addr >> 8) & 0x1ff); /* high addr */ + break; + + case GDISP_ROTATE_90: + lld_lcdWriteReg(0x0020, (addr >> 8) & 0x1ff); /* low addr */ + lld_lcdWriteReg(0x0021, addr & 0xff); /* high addr */ + break; + + case GDISP_ROTATE_180: + break; + + case GDISP_ROTATE_270: + break; + } } static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) { @@ -251,6 +266,10 @@ static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) break; case GDISP_ROTATE_90: + lld_lcdWriteReg(0x0050, y); + lld_lcdWriteReg(0x0051, y + cy - 1); + lld_lcdWriteReg(0x0052, x); + lld_lcdWriteReg(0x0053, x + cx - 1); break; case GDISP_ROTATE_180: @@ -265,7 +284,16 @@ static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) } static __inline void lld_lcdResetViewPort(void) { - /* ToDo */ + switch(GDISP.Orientation) { + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + lld_lcdSetViewPort(0, 0, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT); + break; + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + lld_lcdSetViewPort(0, 0, GDISP_SCREEN_HEIGHT, GDISP_SCREEN_WIDTH); + break; + } } void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { @@ -479,20 +507,20 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { GDISP.Powermode = (gdisp_powermode_t)value; return; -#if 0 - // NOT IMPLEMENTED YET case GDISP_CONTROL_ORIENTATION: if(GDISP.Orientation == (gdisp_orientation_t)value) return; switch((gdisp_orientation_t)value) { case GDISP_ROTATE_0: - /* ToDo */ + lld_lcdWriteReg(0x0001, 0x0100); + lld_lcdWriteReg(0x0003, 0x1038); GDISP.Height = GDISP_SCREEN_HEIGHT; GDISP.Width = GDISP_SCREEN_WIDTH; break; case GDISP_ROTATE_90: - /* ToDo */ + lld_lcdWriteReg(0x0001, 0x0000); + lld_lcdWriteReg(0x0003, 0x1030); GDISP.Height = GDISP_SCREEN_WIDTH; GDISP.Width = GDISP_SCREEN_HEIGHT; break; @@ -521,7 +549,6 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { #endif GDISP.Orientation = (gdisp_orientation_t)value; return; -#endif case GDISP_CONTROL_BACKLIGHT: if((unsigned)value > 100) value = (void *)100; diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c b/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c index 9c1a582b..5e390399 100644 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c +++ b/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c @@ -119,7 +119,7 @@ void ginput_lld_mouse_get_reading(MouseReading *pt) { sampleBuf[i] = read_value(0xD1); read_value(0xD0); filter(); - lastx = (coord_t)sampleBuf[3]; + lastx = 42;//(coord_t)sampleBuf[3]; /* Get the Y value using the same process as above */ read_value(0x91); @@ -127,7 +127,7 @@ void ginput_lld_mouse_get_reading(MouseReading *pt) { sampleBuf[i] = read_value(0x91); read_value(0x90); filter(); - lasty = (coord_t)sampleBuf[3]; + lasty = 42;//(coord_t)sampleBuf[3]; // Release the bus release_bus(); diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h index cba9497d..d213cd17 100644 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h +++ b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h @@ -90,7 +90,7 @@ static __inline uint16_t read_value(uint16_t port) { spiExchange(&SPID1, 3, txbuf, rxbuf); ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); - +return 42; return ret; } diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h index 1ab568f5..de04e1f0 100644 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h +++ b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h @@ -28,9 +28,9 @@ #define _LLD_GINPUT_MOUSE_CONFIG_H #define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH -#define GINPUT_MOUSE_NEED_CALIBRATION TRUE +#define GINPUT_MOUSE_NEED_CALIBRATION FALSE #define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE -#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 2 +#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 4 #define GINPUT_MOUSE_READ_CYCLES 4 #define GINPUT_MOUSE_POLL_PERIOD 100 #define GINPUT_MOUSE_MAX_CLICK_JITTER 2