From 47fcece4b1d35197c1d8057a737e7307bab77113 Mon Sep 17 00:00:00 2001 From: Kevin Townsend Date: Tue, 24 Apr 2012 12:04:03 +0200 Subject: [PATCH] Prep for v1.1.2 --- ChangeLog.txt | 12 +++ build/crossworks/LPC1343_CodeBase.hzp | 5 +- build/crossworks/LPC1343_CodeBase.hzs | 20 +++-- drivers/displays/bitmap/ssd1306/ssd1306.h | 6 +- drivers/displays/tft/drawing.c | 11 ++- drivers/displays/tft/hw/ILI9325.c | 2 +- drivers/displays/tft/hw/ILI9328.c | 2 +- drivers/displays/tft/hw/hx8340b.c | 2 +- drivers/displays/tft/hw/ssd1331.c | 26 +----- drivers/displays/tft/hw/ssd1351.c | 96 ++++++++++++++++++----- drivers/displays/tft/hw/st7735.c | 2 +- drivers/displays/tft/hw/st7783.c | 2 +- drivers/displays/tft/lcd.h | 2 + 13 files changed, 122 insertions(+), 66 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index dd11870..a62048e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,15 @@ +v1.1.2 - ongoing +============================================================================== +NEW FEATURES +------------------------------------------------------------------------------ +- Added fastHLine and fastVLine to lcdProperties_t for all lcd drivers (to + known whether an accelerated vertical or horizontal line drawing function + is present in the driver or not). +- Updated all LCD drivers to include the fastHLine and fastVLine flags. +- Added PWM command to CLI (thanks Miceuz) +- Added optional callback in 32-bit timer ISR (thanks again Miceuz) + + v1.1.1 - 14 April 2012 ============================================================================== NEW FEATURES diff --git a/build/crossworks/LPC1343_CodeBase.hzp b/build/crossworks/LPC1343_CodeBase.hzp index 6883780..0f312e8 100644 --- a/build/crossworks/LPC1343_CodeBase.hzp +++ b/build/crossworks/LPC1343_CodeBase.hzp @@ -144,7 +144,7 @@ - + @@ -152,7 +152,7 @@ - + @@ -387,6 +387,7 @@ + diff --git a/build/crossworks/LPC1343_CodeBase.hzs b/build/crossworks/LPC1343_CodeBase.hzs index 9a397b7..2b310b0 100644 --- a/build/crossworks/LPC1343_CodeBase.hzs +++ b/build/crossworks/LPC1343_CodeBase.hzs @@ -24,12 +24,10 @@ - - - - - - + + + + @@ -49,10 +47,10 @@ - - - + + + @@ -65,7 +63,7 @@ - + - + diff --git a/drivers/displays/bitmap/ssd1306/ssd1306.h b/drivers/displays/bitmap/ssd1306/ssd1306.h index 1773050..d0f096b 100644 --- a/drivers/displays/bitmap/ssd1306/ssd1306.h +++ b/drivers/displays/bitmap/ssd1306/ssd1306.h @@ -53,8 +53,8 @@ SSD1306_BUS_I2C Use HW I2C -----------------------------------------------------------------------*/ - // #define SSD1306_BUS_SPI - #define SSD1306_BUS_I2C + #define SSD1306_BUS_SPI + // #define SSD1306_BUS_I2C #if defined SSD1306_BUS_SPI && defined SSD1306_BUS_I2C #error "Only one SSD1306 bus interface can be specified at once in ssd1306.h" @@ -69,7 +69,7 @@ /*========================================================================= I2C Address - 011110+SA0+RW ... 0x78 for SA0 = 0, 0x7A for SA0 = 1 ---------------------------------------------------------------------*/ - #define SSD1306_I2C_ADDRESS (0x78) + #define SSD1306_I2C_ADDRESS (0x7A) #define SSD1306_I2C_READWRITE (0x01) /*=========================================================================*/ #endif diff --git a/drivers/displays/tft/drawing.c b/drivers/displays/tft/drawing.c index 52cf1b7..b8ad086 100644 --- a/drivers/displays/tft/drawing.c +++ b/drivers/displays/tft/drawing.c @@ -95,7 +95,7 @@ void drawCharSmall(uint16_t x, uint16_t y, uint16_t color, uint8_t c, struct FON { uint8_t bit = 0x00; bit = (column[xoffset] << (8 - (yoffset + 1))); // Shift current row bit left - bit = (bit >> 7); // Shift current row but right (results in 0x01 for black, and 0x00 for white) + bit = (bit >> 7); // Shift current row bit right (results in 0x01 for black, and 0x00 for white) if (bit) { drawPixel(x + xoffset, y + yoffset, color); @@ -238,6 +238,11 @@ void drawLine ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t col /**************************************************************************/ void drawLineDotted ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t empty, uint16_t solid, uint16_t color ) { + lcdProperties_t properties; + + // Get the LCD properties (to check for HW acceleration in the driver) + properties = lcdGetProperties(); + if (solid == 0) { return; @@ -250,7 +255,7 @@ void drawLineDotted ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16 y1 = y1 > 65000 ? 0 : y1; // Check if we can use the optimised horizontal line method - if ((y0 == y1) && (empty == 0)) + if ((y0 == y1) && (empty == 0) && properties.fastHLine) { lcdDrawHLine(x0, x1, y0, color); return; @@ -259,7 +264,7 @@ void drawLineDotted ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16 // Check if we can use the optimised vertical line method. // This can make a huge difference in performance, but may // not work properly on every LCD controller: - if ((x0 == x1) && (empty == 0)) + if ((x0 == x1) && (empty == 0) && properties.fastVLine) { // Warning: This may actually be slower than drawing individual pixels on // short lines ... Set a minimum line size to use the 'optimised' method diff --git a/drivers/displays/tft/hw/ILI9325.c b/drivers/displays/tft/hw/ILI9325.c index 7489b85..42debbc 100644 --- a/drivers/displays/tft/hw/ILI9325.c +++ b/drivers/displays/tft/hw/ILI9325.c @@ -54,7 +54,7 @@ // #define ILI9235_USE_INLINE_METHODS (1) static lcdOrientation_t lcdOrientation = LCD_ORIENTATION_PORTRAIT; -static lcdProperties_t ili9325Properties = { 240, 320, TRUE, TRUE, TRUE }; +static lcdProperties_t ili9325Properties = { 240, 320, true, true, true, true, true }; /*************************************************/ /* Private Methods */ diff --git a/drivers/displays/tft/hw/ILI9328.c b/drivers/displays/tft/hw/ILI9328.c index ca7ec20..23017a1 100644 --- a/drivers/displays/tft/hw/ILI9328.c +++ b/drivers/displays/tft/hw/ILI9328.c @@ -47,7 +47,7 @@ #define ILI9238_USE_INLINE_METHODS (1) static volatile lcdOrientation_t lcdOrientation = LCD_ORIENTATION_PORTRAIT; -static lcdProperties_t ili9328Properties = { 240, 320, TRUE, TRUE, TRUE }; +static lcdProperties_t ili9328Properties = { 240, 320, true, true, true, true, true }; /*************************************************/ /* Private Methods */ diff --git a/drivers/displays/tft/hw/hx8340b.c b/drivers/displays/tft/hw/hx8340b.c index f6a7223..fd46cc6 100644 --- a/drivers/displays/tft/hw/hx8340b.c +++ b/drivers/displays/tft/hw/hx8340b.c @@ -45,7 +45,7 @@ #include "core/gpio/gpio.h" static lcdOrientation_t lcdOrientation = LCD_ORIENTATION_PORTRAIT; -static lcdProperties_t hx8340bProperties = { 176, 220, FALSE, FALSE, FALSE }; +static lcdProperties_t hx8340bProperties = { 176, 220, false, false, false, true, true }; /*************************************************/ /* Private Methods */ diff --git a/drivers/displays/tft/hw/ssd1331.c b/drivers/displays/tft/hw/ssd1331.c index b9e5d1a..11d983a 100644 --- a/drivers/displays/tft/hw/ssd1331.c +++ b/drivers/displays/tft/hw/ssd1331.c @@ -43,7 +43,7 @@ #include "core/systick/systick.h" static volatile lcdOrientation_t lcdOrientation = LCD_ORIENTATION_PORTRAIT; -static lcdProperties_t ssd1331Properties = { 96, 64, false, false, false }; +static lcdProperties_t ssd1331Properties = { 96, 64, false, false, false, true, true }; /*************************************************/ /* Private Methods */ @@ -87,28 +87,6 @@ void ssd1331SendByte(uint8_t byte) } } -/**************************************************************************/ -/*! - @brief Reads a 16-bit value from the 8-bit data bus -*/ -/**************************************************************************/ -uint16_t ssd1331ReadData(void) -{ - // ToDo - return 0; -} - -/**************************************************************************/ -/*! - @brief Reads a 16-bit value -*/ -/**************************************************************************/ -uint16_t ssd1331Read(uint16_t addr) -{ - // ToDo - return 0; -} - /**************************************************************************/ /*! @brief Sets the cursor to the specified X/Y position @@ -135,7 +113,7 @@ void ssd1331SetCursor(uint8_t x, uint8_t y) /**************************************************************************/ void ssd1331DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint16_t color) { - uint16_t x, pixels; + uint16_t x; if ((x1 >= ssd1331Properties.width) || (x2 >= ssd1331Properties.width) || (y1 >= ssd1331Properties.height) || (y2 >= ssd1331Properties.height)) { diff --git a/drivers/displays/tft/hw/ssd1351.c b/drivers/displays/tft/hw/ssd1351.c index 2c293e4..83e8ec0 100644 --- a/drivers/displays/tft/hw/ssd1351.c +++ b/drivers/displays/tft/hw/ssd1351.c @@ -43,15 +43,15 @@ #include "core/systick/systick.h" static volatile lcdOrientation_t lcdOrientation = LCD_ORIENTATION_PORTRAIT; -static lcdProperties_t ssd1351Properties = { 128, 128, false, false, false }; +static lcdProperties_t ssd1351Properties = { 128, 128, false, false, false, true, false }; /*************************************************/ /* Private Methods */ /*************************************************/ #define CMD(c) do { SET_CS; CLR_CS; CLR_DC; ssd1351SendByte( c, 1 ); SET_CS; } while (0) -#define DATA(c) do { SET_CS; CLR_CS; SET_DC; ssd1351SendByte( c, 0 ); SET_CS; } while (0); -#define DELAY(mS) do { systickDelay( mS / CFG_SYSTICK_DELAY_IN_MS ); } while(0); +#define DATA(c) do { SET_CS; CLR_CS; SET_DC; ssd1351SendByte( c, 0 ); SET_CS; } while (0) +#define DELAY(mS) do { systickDelay( mS / CFG_SYSTICK_DELAY_IN_MS ); } while(0) /**************************************************************************/ /*! @@ -113,7 +113,6 @@ void ssd1351SetCursor(uint8_t x, uint8_t y) if ((x >= ssd1351Properties.width) || (y >= ssd1351Properties.height)) return; - CMD(SSD1351_CMD_WRITERAM); CMD(SSD1351_CMD_SETCOLUMNADDRESS); DATA(x); // Start Address DATA(ssd1351Properties.width-1); // End Address (0x7F) @@ -121,7 +120,16 @@ void ssd1351SetCursor(uint8_t x, uint8_t y) CMD(SSD1351_CMD_SETROWADDRESS); DATA(y); // Start Address DATA(ssd1351Properties.height-1); // End Address (0x7F) - CMD(SSD1351_CMD_WRITERAM); +} + +/**************************************************************************/ +/*! + @brief Sets the cursor to 0, 0 and resets the window size +*/ +/**************************************************************************/ +void ssd1351GoHome(void) +{ + ssd1351SetCursor(0, 0); } /*************************************************/ @@ -145,6 +153,9 @@ void lcdInit(void) gpioSetDir(SSD1351_DC_PORT, SSD1351_DC_PIN, gpioDirection_Output); #endif + // Make sure CS starts low + // CLR_CS; + // Reset the LCD SET_RST; DELAY(20); @@ -153,53 +164,72 @@ void lcdInit(void) SET_RST; DELAY(20); - // Disable pullups + // Disable internal pullup resistors SSD1351_DISABLEPULLUPS(); CMD(SSD1351_CMD_SETCOMMANDLOCK); DATA(0x12); // Unlocked to enter commands + CMD(SSD1351_CMD_SETCOMMANDLOCK); DATA(0xB1); // Make all commands accessible + CMD(SSD1351_CMD_SLEEPMODE_DISPLAYOFF); + CMD(SSD1351_CMD_SETFRONTCLOCKDIV); - DATA(0xF1); + DATA(0xF1); // 7:4 = Oscillator Frequency, 3:0 = CLK Div Ratio (A[3:0]+1 = 1..16) + CMD(SSD1351_CMD_SETMUXRRATIO); DATA(0x7F); + CMD(SSD1351_CMD_COLORDEPTH); DATA(0x74); // Bit 7:6 = 65,536 Colors, Bit 3 = BGR or RGB + CMD(SSD1351_CMD_SETCOLUMNADDRESS); DATA(0x00); DATA(0x7F); + CMD(SSD1351_CMD_SETROWADDRESS); DATA(0x00); DATA(0x7F); + CMD(SSD1351_CMD_SETDISPLAYSTARTLINE); DATA(0x00); + CMD(SSD1351_CMD_SETDISPLAYOFFSET); DATA(0x00); + CMD(SSD1351_CMD_SETGPIO); DATA(0x00); // Disable GPIO pins + CMD(SSD1351_CMD_FUNCTIONSELECTION); - DATA(0x01); // External VDD (0 = External, 1 = Internal) + DATA(0x01); // External VDD (1 = External bias using diode drop, 0 = internal) + CMD(SSD1351_CMD_SETPHASELENGTH); DATA(0x32); - CMD(SSD1351_CMD_SETSEGMENTLOWVOLTAGE); - DATA(0xA0); // Enable External VSL - DATA(0xB5); - DATA(0x55); + CMD(SSD1351_CMD_SETPRECHARGEVOLTAGE); - DATA(0x17); + DATA(0x32); // was 0x17 + CMD(SSD1351_CMD_SETVCOMHVOLTAGE); DATA(0x05); + + CMD(SSD1351_CMD_SETDISPLAYMODE_RESET); + CMD(SSD1351_CMD_SETCONTRAST); DATA(0xC8); DATA(0x80); DATA(0xC8); + CMD(SSD1351_CMD_MASTERCONTRAST); DATA(0x0F); // Maximum contrast + + CMD(SSD1351_CMD_SETSEGMENTLOWVOLTAGE); + DATA(0xA0); // Enable External VSL + DATA(0xB5); + DATA(0x55); + CMD(SSD1351_CMD_SETSECONDPRECHARGEPERIOD); DATA(0x01); - CMD(SSD1351_CMD_SETDISPLAYMODE_RESET); // Use default grayscale for now to save flash space, but here are // the values if someone wants to change them ... @@ -322,6 +352,7 @@ void lcdFillRGB(uint16_t data) { uint16_t i; ssd1351SetCursor(0, 0); + CMD(SSD1351_CMD_WRITERAM); for (i=1; i<=((ssd1351Properties.width)*(ssd1351Properties.height)) * 2;i++) { DATA(data >> 8); @@ -340,6 +371,7 @@ void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) return; ssd1351SetCursor((uint8_t)x, (uint8_t)y); + CMD(SSD1351_CMD_WRITERAM); DATA(color >> 8); DATA(color); } @@ -363,7 +395,35 @@ void lcdDrawPixels(uint16_t x, uint16_t y, uint16_t *data, uint32_t len) /**************************************************************************/ void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color) { - // ToDo + // Allows for slightly better performance than setting individual pixels + uint16_t x, pixels; + + if (x1 < x0) + { + // Switch x1 and x0 + x = x1; + x1 = x0; + x0 = x; + } + + // Check limits + if (x1 >= ssd1351Properties.width) + { + x1 = ssd1351Properties.width - 1; + } + if (x0 >= ssd1351Properties.width) + { + x0 = ssd1351Properties.width - 1; + } + + ssd1351SetCursor(x0, y); + CMD(SSD1351_CMD_WRITERAM); + for (pixels = 0; pixels < x1 - x0 + 1; pixels++) + { + DATA(color >> 8); + DATA(color); + } + ssd1351GoHome(); } /**************************************************************************/ @@ -374,7 +434,7 @@ void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color) /**************************************************************************/ void lcdDrawVLine(uint16_t x, uint16_t y0, uint16_t y1, uint16_t color) { - // ToDo + // Not supported } /**************************************************************************/ @@ -384,7 +444,7 @@ void lcdDrawVLine(uint16_t x, uint16_t y0, uint16_t y1, uint16_t color) /**************************************************************************/ uint16_t lcdGetPixel(uint16_t x, uint16_t y) { - // ToDo + // Not supported return 0; } @@ -438,7 +498,7 @@ uint16_t lcdGetHeight(void) /**************************************************************************/ void lcdScroll(int16_t pixels, uint16_t fillColor) { - // ToDo + // Not Supported } /**************************************************************************/ diff --git a/drivers/displays/tft/hw/st7735.c b/drivers/displays/tft/hw/st7735.c index db222de..5b7b3be 100644 --- a/drivers/displays/tft/hw/st7735.c +++ b/drivers/displays/tft/hw/st7735.c @@ -45,7 +45,7 @@ #include "core/gpio/gpio.h" static lcdOrientation_t lcdOrientation = LCD_ORIENTATION_PORTRAIT; -static lcdProperties_t st7735Properties = { 128, 160, FALSE, FALSE, FALSE }; +static lcdProperties_t st7735Properties = { 128, 160, false, false, false, true, true }; /*************************************************/ /* Private Methods */ diff --git a/drivers/displays/tft/hw/st7783.c b/drivers/displays/tft/hw/st7783.c index 09b0dbb..1dbf082 100644 --- a/drivers/displays/tft/hw/st7783.c +++ b/drivers/displays/tft/hw/st7783.c @@ -48,7 +48,7 @@ #include "drivers/displays/tft/touchscreen.h" static lcdOrientation_t lcdOrientation = LCD_ORIENTATION_PORTRAIT; -static lcdProperties_t st7783Properties = { 240, 320, TRUE, TRUE, FALSE }; +static lcdProperties_t st7783Properties = { 240, 320, true, true, false, true, true}; /*************************************************/ /* Private Methods */ diff --git a/drivers/displays/tft/lcd.h b/drivers/displays/tft/lcd.h index d415d3e..9cb2973 100644 --- a/drivers/displays/tft/lcd.h +++ b/drivers/displays/tft/lcd.h @@ -59,6 +59,8 @@ typedef struct bool touchscreen; // Whether the LCD has a touch screen bool orientation; // Whether the LCD orientation can be modified bool hwscrolling; // Whether the LCD support HW scrolling + bool fastHLine; // Whether the driver contains an accelerated horizontal line function + bool fastVLine; // Whether the driver contains an accelerated vertical line function } lcdProperties_t; extern void lcdInit(void); -- 2.20.1