/**************************************************************************/\r
/*!\r
@file hx8347d.c\r
- @author TauonTeilchen\r
+ @author Tauon {TauonTeilchen} Jabber ID Tauon[at]jabber.ccc.de\r
\r
@section DESCRIPTION\r
+ Driver for hx8347h 240x320 pixel TFT LCD displays.\r
Is written for MI0283QT-2 LCD from watterott.com\r
More infos: http://www.watterott.com/de/MI0283QT-2-Adapter\r
- Based on Watterott C Lib for MI0283QT-2\r
http://www.watterott.com/index.php?page=product&info=1597&dl_media=3202\r
\r
@section LICENSE\r
\r
Software License Agreement (BSD License)\r
\r
- Copyright (c) 2010, microBuilder SARL\r
- All rights reserved.\r
-\r
- Redistribution and use in source and binary forms, with or without\r
- modification, are permitted provided that the following conditions are met:\r
- 1. Redistributions of source code must retain the above copyright\r
- notice, this list of conditions and the following disclaimer.\r
- 2. Redistributions in binary form must reproduce the above copyright\r
- notice, this list of conditions and the following disclaimer in the\r
- documentation and/or other materials provided with the distribution.\r
- 3. Neither the name of the copyright holders nor the\r
- names of its contributors may be used to endorse or promote products\r
- derived from this software without specific prior written permission.\r
-\r
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\r
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY\r
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ Copyright (c) 2012, TauonTeilchen \r
+ ----------------------------------------------------------------------------\r
+ "THE ClubMate-WARE LICENSE" (Revision 42):\r
+ JID: <Tauon@jabber.ccc.de> wrote this file. As long as you retain this notice you\r
+ can do whatever you want with this stuff. If we meet some day, and you think\r
+ this stuff is worth it, you can buy me a ClubMate in return Tauon\r
+ ----------------------------------------------------------------------------\r
+ ----------------------------------------------------------------------------\r
+ "THE ClubMate-WARE LICENSE" (Revision 42):\r
+ JID: <Tauon@jabber.ccc.de> schrieb diese Datei. Solange Sie diesen Vermerk nicht entfernen, k�nnen\r
+ Sie mit dem Material machen, was Sie m�chten. Wenn wir uns eines Tages treffen und Sie\r
+ denken, das Material ist es wert, k�nnen Sie mir daf�r ein ClubMate ausgeben. Tauon\r
+ ----------------------------------------------------------------------------\r
+\r
*/\r
/**************************************************************************/\r
#include "drivers/displays/tft/hw/hx8347d.h"\r
\r
-#define LCD_ID (0x00)\r
-#define LCD_DATA ((0x72)|(LCD_ID<<2))\r
-#define LCD_REGISTER ((0x70)|(LCD_ID<<2))\r
+#define LCD_ID (0x00)\r
+#define LCD_DATA ((0x72)|(LCD_ID<<2))\r
+#define LCD_REGISTER ((0x70)|(LCD_ID<<2))\r
\r
-#define LCD_BACK_LIGHT 6\r
-#define LCD_RST 5\r
-#define LCD_CS 4\r
+#define LCD_BACK_LIGHT 6\r
+#define LCD_RST 5\r
+#define LCD_CS 4\r
\r
// Macros for control line state\r
-#define LCD_CS_ENABLE() GPIO_GPIO2DATA &= ~0x10 // gpioSetValue(2, 4, 0)\r
-#define LCD_CS_DISABLE() GPIO_GPIO2DATA |= 0x10 // gpioSetValue(2, 4, 1)\r
-#define LCD_RST_ENABLE() GPIO_GPIO2DATA &= ~0x20 // gpioSetValue(2, 5, 0)\r
-#define LCD_RST_DISABLE() GPIO_GPIO2DATA |= 0x20 // gpioSetValue(2, 5, 1)\r
-\r
-#define Himax ID 0x00\r
-#define Display_Mode_Control 0x01\r
-\r
-#define Column_Address_Start_2 0x02\r
-#define Column_Address_Start_1 0x03\r
-#define Column_Address_End_2 0x04\r
-#define Column_Address_End_1 0x05\r
-\r
-#define Row_Address_Start_2 0x06\r
-#define Row_Address_Start_1 0x07\r
-#define Row_Address_End_2 0x08\r
-#define Row_Address_End_1 0x09\r
-\r
-#define Partial_Area_Start_Row_2 0x0A\r
-#define Partial_Area_Start_Row_1 0x0B\r
-#define Partial_Area_End_Row_2 0x0C\r
-#define Partial_Area_End_Row_1 0x0D\r
-\r
-#define TFA_REGISTER 0x0E\r
-#define VSA_REGISTER 0x10\r
-#define BFA_REGISTER 0x12\r
-#define VSP_REGISTER 0x14\r
-\r
-#define COLMOD 0x17\r
-#define OSC_Control_1 0x18\r
-#define OSC_Control_2 0x19\r
-#define Power_Control_1 0x1A\r
-#define Power_Control_2 0x1B\r
-#define Power_Control_3 0x1C\r
-#define Power_Control_4 0x1D\r
-#define Power_Control_5 0x1E\r
-#define Power_Control_6 0x1F\r
-#define VCOM_Control_1 0x23\r
-#define VCOM_Control_2 0x24\r
-#define VCOM_Control_3 0x25\r
-#define Display_Control_1 0x26\r
-#define Display_Control_2 0x27\r
-#define Display_Control_3 0x28\r
-#define Source_OP_Control_Normal 0xE8\r
-#define Source_OP_Control_IDLE 0xE9\r
-#define Power_Control_Internal_1 0xEA\r
-#define Power_Control_Internal_2 0xEB\r
-#define Source_Control_Internal_1 0xEC\r
-#define Source_Control_Internal_2 0xED\r
-\r
-#define OSC_Control_2_OSC_EN 0x01\r
-#define Display_Control_3_GON 0x20\r
-#define Display_Control_3_DTE 0x10\r
-#define Display_Control_3_D0 0x04\r
-#define Display_Control_3_D1 0x08\r
-#define Power_Control_6_STB 0x01\r
+#define LCD_CS_ENABLE() GPIO_GPIO2DATA &= ~0x10 // gpioSetValue(2, 4, 0)\r
+#define LCD_CS_DISABLE() GPIO_GPIO2DATA |= 0x10 // gpioSetValue(2, 4, 1)\r
+#define LCD_RST_ENABLE() GPIO_GPIO2DATA &= ~0x20 // gpioSetValue(2, 5, 0)\r
+#define LCD_RST_DISABLE() GPIO_GPIO2DATA |= 0x20 // gpioSetValue(2, 5, 1)\r
+\r
+#define Himax ID 0x00\r
+#define Display_Mode_Control 0x01\r
+\r
+#define Column_Address_Start_2 0x02\r
+#define Column_Address_Start_1 0x03\r
+#define Column_Address_End_2 0x04\r
+#define Column_Address_End_1 0x05\r
+\r
+#define Row_Address_Start_2 0x06\r
+#define Row_Address_Start_1 0x07\r
+#define Row_Address_End_2 0x08\r
+#define Row_Address_End_1 0x09\r
+\r
+#define Partial_Area_Start_Row_2 0x0A\r
+#define Partial_Area_Start_Row_1 0x0B\r
+#define Partial_Area_End_Row_2 0x0C\r
+#define Partial_Area_End_Row_1 0x0D\r
+\r
+#define TFA_REGISTER 0x0E\r
+#define VSA_REGISTER 0x10\r
+#define BFA_REGISTER 0x12\r
+#define VSP_REGISTER 0x14\r
+\r
+#define COLMOD 0x17\r
+#define OSC_Control_1 0x18\r
+#define OSC_Control_2 0x19\r
+#define Power_Control_1 0x1A\r
+#define Power_Control_2 0x1B\r
+#define Power_Control_3 0x1C\r
+#define Power_Control_4 0x1D\r
+#define Power_Control_5 0x1E\r
+#define Power_Control_6 0x1F\r
+#define VCOM_Control_1 0x23\r
+#define VCOM_Control_2 0x24\r
+#define VCOM_Control_3 0x25\r
+#define Display_Control_1 0x26\r
+#define Display_Control_2 0x27\r
+#define Display_Control_3 0x28\r
+#define Source_OP_Control_Normal 0xE8\r
+#define Source_OP_Control_IDLE 0xE9\r
+#define Power_Control_Internal_1 0xEA\r
+#define Power_Control_Internal_2 0xEB\r
+#define Source_Control_Internal_1 0xEC\r
+#define Source_Control_Internal_2 0xED\r
+\r
+#define OSC_Control_2_OSC_EN 0x01\r
+#define Display_Control_3_GON 0x20\r
+#define Display_Control_3_DTE 0x10\r
+#define Display_Control_3_D0 0x04\r
+#define Display_Control_3_D1 0x08\r
+#define Power_Control_6_STB 0x01\r
#define Display_Mode_Control_DP_STB_S 0x40\r
-#define Display_Mode_Control_DP_STB 0x80\r
+#define Display_Mode_Control_DP_STB 0x80\r
+\r
uint16_t offset;\r
\r
/*************************************************/\r
/* Private Methods */\r
/*************************************************/\r
void lcd_drawstart(void);\r
-void lcd_cmd(unsigned int reg, unsigned int param);\r
-void lcd_clear(unsigned int color);\r
-void lcd_draw(unsigned int color);\r
+void lcd_cmd(uint16_t reg, uint16_t param);\r
+void lcd_clear(uint16_t color);\r
+void lcd_draw(uint16_t color);\r
void lcd_drawstart(void);\r
void lcd_drawstop(void);\r
void hx8347d_DisplayOnFlow(void);\r
void hx8347d_DisplayOffFlow(void);\r
-void lcd_area(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1);\r
+void lcd_area(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);\r
\r
\r
void hx8347d_Scroll(uint16_t tfa,uint16_t vsa,uint16_t bfa, uint16_t vsp)\r
{\r
- lcd_cmd(TFA_REGISTER , tfa >> 8);\r
- lcd_cmd(TFA_REGISTER + 1, tfa & 0xFF);\r
+ lcd_cmd(TFA_REGISTER , tfa >> 8);\r
+ lcd_cmd(TFA_REGISTER + 1, tfa & 0xFF);\r
\r
- lcd_cmd(VSA_REGISTER , vsa >> 8);\r
- lcd_cmd(VSA_REGISTER + 1, vsa & 0xFF);\r
+ lcd_cmd(VSA_REGISTER , vsa >> 8);\r
+ lcd_cmd(VSA_REGISTER + 1, vsa & 0xFF);\r
\r
- lcd_cmd(BFA_REGISTER , bfa >> 8);\r
- lcd_cmd(BFA_REGISTER + 1, bfa & 0xFF);\r
+ lcd_cmd(BFA_REGISTER , bfa >> 8);\r
+ lcd_cmd(BFA_REGISTER + 1, bfa & 0xFF);\r
\r
- lcd_cmd(VSP_REGISTER , vsp>> 8);\r
- lcd_cmd(VSP_REGISTER + 1, vsp & 0xFF);\r
- lcd_cmd(0x01, 0x08); //scroll on\r
+ lcd_cmd(VSP_REGISTER , vsp>> 8);\r
+ lcd_cmd(VSP_REGISTER + 1, vsp & 0xFF);\r
+ lcd_cmd(0x01, 0x08); //scroll on\r
}\r
\r
void displayOnFlow(void)\r
{\r
- lcd_cmd(Display_Control_3, 0x0038);\r
- systickDelay(4);\r
- lcd_cmd(Display_Control_3, 0x003C);\r
+ lcd_cmd(Display_Control_3, 0x0038);\r
+ systickDelay(4);\r
+ lcd_cmd(Display_Control_3, 0x003C);\r
}\r
void displayOffFlow(void)\r
{\r
- lcd_cmd(Display_Control_3, Display_Control_3_GON | Display_Control_3_DTE | Display_Control_3_D1);\r
- systickDelay(4);\r
- lcd_cmd(Display_Control_3, Display_Control_3_D0);\r
+ lcd_cmd(Display_Control_3, Display_Control_3_GON | Display_Control_3_DTE | Display_Control_3_D1);\r
+ systickDelay(4);\r
+ lcd_cmd(Display_Control_3, Display_Control_3_D0);\r
}\r
\r
-void lcd_cmd(unsigned int reg, unsigned int param)\r
+void lcd_cmd(uint16_t reg, uint16_t param)\r
{\r
- uint8_t b_first[2];\r
- uint8_t b_sec[2];\r
- LCD_CS_ENABLE();\r
+ uint8_t b_first[2];\r
+ uint8_t b_sec[2];\r
+ LCD_CS_ENABLE();\r
\r
- b_first[0] = LCD_REGISTER;\r
- b_first[1] = reg;\r
+ b_first[0] = LCD_REGISTER;\r
+ b_first[1] = reg;\r
\r
- sspSend(0, b_first, 2);\r
- LCD_CS_DISABLE();\r
+ sspSend(0, b_first, 2);\r
+ LCD_CS_DISABLE();\r
\r
- b_sec[0] = LCD_DATA;\r
- b_sec[1] = param;\r
- LCD_CS_ENABLE();\r
+ b_sec[0] = LCD_DATA;\r
+ b_sec[1] = param;\r
+ LCD_CS_ENABLE();\r
\r
- sspSend(0, b_sec, 2);\r
- LCD_CS_DISABLE();\r
+ sspSend(0, b_sec, 2);\r
+ LCD_CS_DISABLE();\r
\r
return;\r
}\r
-void lcd_clear(unsigned int color)\r
+\r
+void lcd_clear(uint16_t color)\r
{\r
unsigned int i;\r
\r
return;\r
}\r
\r
-void lcd_draw(unsigned int color)\r
+void lcd_draw(uint16_t color)\r
{\r
- // Writing data in 16Bit mode for saving a lot of time\r
- /* Move on only if NOT busy and TX FIFO not full. */\r
- while ((SSP_SSP0SR & (SSP_SSP0SR_TNF_NOTFULL | SSP_SSP0SR_BSY_BUSY)) != SSP_SSP0SR_TNF_NOTFULL);\r
- SSP_SSP0DR = color;\r
-\r
- while ( (SSP_SSP0SR & (SSP_SSP0SR_BSY_BUSY|SSP_SSP0SR_RNE_NOTEMPTY)) != SSP_SSP0SR_RNE_NOTEMPTY );\r
- /* Whenever a byte is written, MISO FIFO counter increments, Clear FIFO\r
- on MISO. Otherwise, when SSP0Receive() is called, previous data byte\r
- is left in the FIFO. */\r
- uint8_t Dummy = SSP_SSP0DR;\r
- return;\r
+ // Writing data in 16Bit mode for saving a lot of time\r
+ /* Move on only if NOT busy and TX FIFO not full. */\r
+ while ((SSP_SSP0SR & (SSP_SSP0SR_TNF_NOTFULL | SSP_SSP0SR_BSY_BUSY)) != SSP_SSP0SR_TNF_NOTFULL);\r
+ SSP_SSP0DR = color;\r
+\r
+ while ( (SSP_SSP0SR & (SSP_SSP0SR_BSY_BUSY|SSP_SSP0SR_RNE_NOTEMPTY)) != SSP_SSP0SR_RNE_NOTEMPTY );\r
+ /* Whenever a byte is written, MISO FIFO counter increments, Clear FIFO\r
+ on MISO. Otherwise, when SSP0Receive() is called, previous data byte\r
+ is left in the FIFO. */\r
+ uint8_t Dummy = SSP_SSP0DR;\r
+ return;\r
}\r
\r
void lcd_drawstop(void)\r
{\r
- while ((SSP_SSP0SR & SSP_SSP0SR_TFE_MASK ) != SSP_SSP0SR_TFE_EMPTY );\r
- LCD_CS_DISABLE();\r
+ while ((SSP_SSP0SR & SSP_SSP0SR_TFE_MASK ) != SSP_SSP0SR_TFE_EMPTY );\r
+ LCD_CS_DISABLE();\r
\r
- // init 8Bit SPI Mode\r
- SSP_SSP0CR0 &= ~SSP_SSP0CR0_DSS_MASK;\r
- SSP_SSP0CR0 |= SSP_SSP0CR0_DSS_8BIT;\r
+ // init 8Bit SPI Mode\r
+ SSP_SSP0CR0 &= ~SSP_SSP0CR0_DSS_MASK;\r
+ SSP_SSP0CR0 |= SSP_SSP0CR0_DSS_8BIT;\r
\r
- return;\r
+ return;\r
}\r
+\r
void lcd_drawstart(void)\r
{\r
- LCD_CS_ENABLE();\r
- uint8_t b_first[2];\r
- uint8_t b_sec[1];\r
- b_first[0] = LCD_REGISTER;\r
- b_first[1] = 0x22;\r
- sspSend(0, b_first, 2);\r
- LCD_CS_DISABLE();\r
+ LCD_CS_ENABLE();\r
+ uint8_t b_first[2];\r
+ uint8_t b_sec[1];\r
+ b_first[0] = LCD_REGISTER;\r
+ b_first[1] = 0x22;\r
+ sspSend(0, b_first, 2);\r
+ LCD_CS_DISABLE();\r
\r
- LCD_CS_ENABLE();\r
- b_sec[0] = LCD_DATA;\r
- sspSend(0, b_sec, 1);\r
+ LCD_CS_ENABLE();\r
+ b_sec[0] = LCD_DATA;\r
+ sspSend(0, b_sec, 1);\r
\r
\r
- // Assign config values to SSP0CR0\r
- // init 16Bit SPI Mode for fast data transmitting\r
- SSP_SSP0CR0 &= ~SSP_SSP0CR0_DSS_MASK;\r
- SSP_SSP0CR0 |= SSP_SSP0CR0_DSS_16BIT;\r
+ // Assign config values to SSP0CR0\r
+ // init 16Bit SPI Mode for fast data transmitting\r
+ SSP_SSP0CR0 &= ~SSP_SSP0CR0_DSS_MASK;\r
+ SSP_SSP0CR0 |= SSP_SSP0CR0_DSS_16BIT;\r
\r
- return;\r
+ return;\r
}\r
\r
-\r
-void lcd_area(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1)\r
+void lcd_area(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)\r
{\r
- y0 = ((320-offset)+ y0) % 320;\r
- y1 = ((320-offset)+ y1) % 320;\r
- lcd_cmd(Column_Address_Start_1, (x0>>0)); //set x0\r
- lcd_cmd(Column_Address_Start_2, (x0>>8)); //set x0\r
- lcd_cmd(Column_Address_End_1 , (x1>>0)); //set x1\r
- lcd_cmd(Column_Address_End_2 , (x1>>8)); //set x1\r
- lcd_cmd(Row_Address_Start_1 , (y0>>0)); //set y0\r
- lcd_cmd(Row_Address_Start_2 , (y0>>8)); //set y0\r
- lcd_cmd(Row_Address_End_1 , (y1>>0)); //set y1\r
- lcd_cmd(Row_Address_End_2 , (y1>>8)); //set y1\r
+ if(hx8347dPOrientation == LCD_ORIENTATION_PORTRAIT)\r
+ {\r
+ y0 = ((320-offset)+ y0) % 320;\r
+ y1 = ((320-offset)+ y1) % 320;\r
+ }\r
+ else\r
+ {\r
+ x0 = ((320-offset)+ x0) % 320;\r
+ x1 = ((320-offset)+ x1) % 320; \r
+ }\r
+ lcd_cmd(Column_Address_Start_1, (x0>>0)); //set x0\r
+ lcd_cmd(Column_Address_Start_2, (x0>>8)); //set x0\r
+ lcd_cmd(Column_Address_End_1 , (x1>>0)); //set x1\r
+ lcd_cmd(Column_Address_End_2 , (x1>>8)); //set x1\r
+ lcd_cmd(Row_Address_Start_1 , (y0>>0)); //set y0\r
+ lcd_cmd(Row_Address_Start_2 , (y0>>8)); //set y0\r
+ lcd_cmd(Row_Address_End_1 , (y1>>0)); //set y1\r
+ lcd_cmd(Row_Address_End_2 , (y1>>8)); //set y1\r
\r
return;\r
}\r
-void lcd_cursor(unsigned int x, unsigned int y)\r
+\r
+void lcd_cursor(uint16_t x, uint16_t y)\r
{\r
lcd_area(x, y, x, y);\r
return;\r
}\r
-void lcd_data(unsigned int c)\r
+\r
+void lcd_data(uint16_t c)\r
{\r
- LCD_CS_ENABLE();\r
- uint8_t b[3];\r
- b[0] = LCD_DATA;\r
- b[1] = c>>8;\r
- b[2] = c;\r
- sspSend(0, b, 3);\r
+ LCD_CS_ENABLE();\r
+ uint8_t b[3];\r
+ b[0] = LCD_DATA;\r
+ b[1] = c>>8;\r
+ b[2] = c;\r
+ sspSend(0, b, 3);\r
\r
- LCD_CS_DISABLE();\r
+ LCD_CS_DISABLE();\r
\r
return;\r
}\r
\r
-\r
void fillRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color)\r
{\r
uint32_t size;\r
/**************************************************************************/\r
void lcdInit(void)\r
{\r
- sspInit(0,0,0);\r
-\r
- gpioSetDir(2, LCD_CS, gpioDirection_Output);\r
- gpioSetDir(2, LCD_RST, gpioDirection_Output);\r
- gpioSetDir(2, LCD_BACK_LIGHT, gpioDirection_Output);\r
-\r
- //reset\r
- LCD_CS_DISABLE();\r
- systickDelay(1);\r
- LCD_RST_ENABLE();\r
- systickDelay(50);\r
- LCD_RST_DISABLE();\r
- systickDelay(50);\r
-\r
- //driving ability\r
- lcd_cmd(Power_Control_Internal_1 , 0x0000);\r
- lcd_cmd(Power_Control_Internal_2 , 0x0020);\r
- lcd_cmd(Source_Control_Internal_1, 0x000C);\r
- lcd_cmd(Source_Control_Internal_2, 0x00C4);\r
- lcd_cmd(Source_OP_Control_Normal , 0x0040);\r
- lcd_cmd(Source_OP_Control_IDLE , 0x0038);\r
- lcd_cmd(0xF1, 0x0001);\r
- lcd_cmd(0xF2, 0x0010);\r
- lcd_cmd(0x27, 0x00A3);\r
-\r
- //power voltage\r
- lcd_cmd(Power_Control_2, 0x001B);\r
- lcd_cmd(Power_Control_1, 0x0001);\r
- lcd_cmd(VCOM_Control_2 , 0x002F);\r
- lcd_cmd(VCOM_Control_3 , 0x0057);\r
-\r
- //VCOM offset\r
- lcd_cmd(VCOM_Control_1, 0x008D); //for flicker adjust\r
-\r
- //power on\r
- lcd_cmd(OSC_Control_1 , 0x0036);\r
- lcd_cmd(OSC_Control_2 , 0x0001); //start osc\r
- lcd_cmd(Display_Mode_Control, 0x0000); //wakeup\r
- lcd_cmd(Power_Control_6 , 0x0088);\r
- systickDelay(5);\r
- lcd_cmd(Power_Control_6, 0x0080);\r
- systickDelay(5);\r
- lcd_cmd(Power_Control_6, 0x0090);\r
- systickDelay(5);\r
- lcd_cmd(Power_Control_6, 0x00D0);\r
- systickDelay(5);\r
-\r
- //color selection\r
- lcd_cmd(COLMOD, 0x0005); //0x0005=65k, 0x0006=262k\r
-\r
- //panel characteristic\r
- lcd_cmd(0x36, 0x0000);\r
-\r
- //display on\r
- lcd_cmd(0x28, 0x0038);\r
- systickDelay(40);\r
- lcd_cmd(0x28, 0x003C);\r
-\r
- lcdSetOrientation(hx8347dPOrientation);\r
- return;\r
+ sspInit(0,0,0);\r
+\r
+ gpioSetDir(2, LCD_CS, gpioDirection_Output);\r
+ gpioSetDir(2, LCD_RST, gpioDirection_Output);\r
+ gpioSetDir(2, LCD_BACK_LIGHT, gpioDirection_Output);\r
+\r
+ //reset\r
+ LCD_CS_DISABLE();\r
+ systickDelay(1);\r
+ LCD_RST_ENABLE();\r
+ systickDelay(50);\r
+ LCD_RST_DISABLE();\r
+ systickDelay(50);\r
+\r
+ //driving ability\r
+ lcd_cmd(Power_Control_Internal_1 , 0x0000);\r
+ lcd_cmd(Power_Control_Internal_2 , 0x0020);\r
+ lcd_cmd(Source_Control_Internal_1, 0x000C);\r
+ lcd_cmd(Source_Control_Internal_2, 0x00C4);\r
+ lcd_cmd(Source_OP_Control_Normal , 0x0040);\r
+ lcd_cmd(Source_OP_Control_IDLE , 0x0038);\r
+ lcd_cmd(0xF1, 0x0001);\r
+ lcd_cmd(0xF2, 0x0010);\r
+ lcd_cmd(0x27, 0x00A3);\r
+\r
+ //power voltage\r
+ lcd_cmd(Power_Control_2, 0x001B);\r
+ lcd_cmd(Power_Control_1, 0x0001);\r
+ lcd_cmd(VCOM_Control_2 , 0x002F);\r
+ lcd_cmd(VCOM_Control_3 , 0x0057);\r
+\r
+ //VCOM offset\r
+ lcd_cmd(VCOM_Control_1, 0x008D); //for flicker adjust\r
+\r
+ //power on\r
+ lcd_cmd(OSC_Control_1 , 0x0036);\r
+ lcd_cmd(OSC_Control_2 , 0x0001); //start osc\r
+ lcd_cmd(Display_Mode_Control, 0x0000); //wakeup\r
+ lcd_cmd(Power_Control_6 , 0x0088);\r
+ systickDelay(5);\r
+ lcd_cmd(Power_Control_6, 0x0080);\r
+ systickDelay(5);\r
+ lcd_cmd(Power_Control_6, 0x0090);\r
+ systickDelay(5);\r
+ lcd_cmd(Power_Control_6, 0x00D0);\r
+ systickDelay(5);\r
+\r
+ //color selection\r
+ lcd_cmd(COLMOD, 0x0005); //0x0005=65k, 0x0006=262k\r
+\r
+ //panel characteristic\r
+ lcd_cmd(0x36, 0x0000);\r
+\r
+ //display on\r
+ lcd_cmd(0x28, 0x0038);\r
+ systickDelay(40);\r
+ lcd_cmd(0x28, 0x003C);\r
+\r
+ lcdSetOrientation(hx8347dPOrientation);\r
+ offset = 0;\r
+ return;\r
}\r
/**************************************************************************/\r
/*!\r
/**************************************************************************/\r
void lcdBacklight(bool state)\r
{\r
- gpioSetValue(2, LCD_BACK_LIGHT, state);\r
+ gpioSetValue(2, LCD_BACK_LIGHT, state);\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
void lcdTest(void)\r
{\r
- lcdFillRGB(COLOR_CYAN);\r
-\r
+ lcdFillRGB(COLOR_CYAN);\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
void lcdFillRGB(uint16_t data)\r
{\r
- lcd_clear(data);\r
+ lcd_clear(data);\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color)\r
{\r
- if((x >= hx8347dProperties.width) ||\r
- (y >= hx8347dProperties.height))\r
- {\r
- return;\r
- }\r
+ if((x >= hx8347dProperties.width) ||\r
+ (y >= hx8347dProperties.height))\r
+ {\r
+ return;\r
+ }\r
\r
- fillRect(x,y,x,y,color);\r
+ fillRect(x,y,x,y,color);\r
\r
- return;\r
+ return;\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
void lcdDrawPixels(uint16_t x, uint16_t y, uint16_t *data, uint32_t len)\r
{\r
- lcd_area(x, y, x + len, y);\r
- int i;\r
- lcd_drawstart();\r
- for(i = 0; i < len; i++)\r
- {\r
-\r
- lcd_draw(*data);\r
- data++;\r
- }\r
- lcd_drawstop();\r
+ lcd_area(x, y, x + len, y);\r
+ int i;\r
+ lcd_drawstart();\r
+ for(i = 0; i < len; i++)\r
+ {\r
+ lcd_draw(*data);\r
+ data++;\r
+ }\r
+ lcd_drawstop();\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color)\r
{\r
+ if (x1 < x0)\r
+ {\r
+ // Switch x1 and x0\r
+ uint16_t x;\r
+ x = x1;\r
+ x1 = x0;\r
+ x0 = x;\r
+ }\r
\r
- if (x1 < x0)\r
- {\r
- // Switch x1 and x0\r
- uint16_t x;\r
- x = x1;\r
- x1 = x0;\r
- x0 = x;\r
- }\r
-\r
- if(x0 >= hx8347dProperties.width)\r
- {\r
- x0 = hx8347dProperties.width-1;\r
- }\r
- if(x1 >= hx8347dProperties.width)\r
- {\r
- x1 = hx8347dProperties.width-1;\r
- }\r
- if(y >= hx8347dProperties.height)\r
- {\r
- y = hx8347dProperties.height-1;\r
- }\r
-\r
- fillRect(x0, y, x1, y, color);\r
+ if(x0 >= hx8347dProperties.width)\r
+ {\r
+ x0 = hx8347dProperties.width-1;\r
+ }\r
+ if(x1 >= hx8347dProperties.width)\r
+ {\r
+ x1 = hx8347dProperties.width-1;\r
+ }\r
+ if(y >= hx8347dProperties.height)\r
+ {\r
+ y = hx8347dProperties.height-1;\r
+ }\r
\r
+ fillRect(x0, y, x1, y, color);\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
void lcdDrawVLine(uint16_t x, uint16_t y0, uint16_t y1, uint16_t color)\r
{\r
+ if (y1 < y0)\r
+ {\r
+ // Switch y1 and y0\r
+ uint16_t y;\r
+ y = y1;\r
+ y1 = y0;\r
+ y0 = y;\r
+ }\r
+\r
+ if(x >= hx8347dProperties.width)\r
+ {\r
+ x = hx8347dProperties.width-1;\r
+ }\r
+\r
+ if(y0 >= hx8347dProperties.height)\r
+ {\r
+ y0 = hx8347dProperties.height-1;\r
+ }\r
+ if(y1 >= hx8347dProperties.height)\r
+ {\r
+ y1 = hx8347dProperties.height-1;\r
+ }\r
\r
- if (y1 < y0)\r
- {\r
- // Switch y1 and y0\r
- uint16_t y;\r
- y = y1;\r
- y1 = y0;\r
- y0 = y;\r
- }\r
-\r
- if(x >= hx8347dProperties.width)\r
- {\r
- x = hx8347dProperties.width-1;\r
- }\r
-\r
- if(y0 >= hx8347dProperties.height)\r
- {\r
- y0 = hx8347dProperties.height-1;\r
- }\r
- if(y1 >= hx8347dProperties.height)\r
- {\r
- y1 = hx8347dProperties.height-1;\r
- }\r
-\r
- fillRect(x, y0, x, y1, color);\r
+ fillRect(x, y0, x, y1, color);\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
uint16_t lcdGetPixel(uint16_t x, uint16_t y)\r
{\r
+ return 0;\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
void lcdSetOrientation(lcdOrientation_t orientation)\r
{\r
- if(orientation == LCD_ORIENTATION_LANDSCAPE)\r
- {\r
- lcd_cmd(0x16, 0x00A8); //MY=1 MX=0 MV=1 ML=0 BGR=1\r
- hx8347dProperties.width = 320;\r
- hx8347dProperties.height = 240;\r
- }\r
- else\r
- {\r
- //lcd_cmd(0x16, 0x0008); //MY=0 MX=0 MV=0 ML=0 BGR=1\r
- lcd_cmd(0x16, 0x00C8); //MY=1 MX=0 MV=1 ML=0 BGR=1\r
- hx8347dProperties.width = 240;\r
- hx8347dProperties.height = 320;\r
- }\r
- hx8347dPOrientation = orientation;\r
- lcd_area(0, 0, (hx8347dProperties.width-1), (hx8347dProperties.height-1));\r
+ if(orientation == LCD_ORIENTATION_LANDSCAPE)\r
+ {\r
+ lcd_cmd(0x16, 0x00A8); //MY=1 MX=0 MV=1 ML=0 BGR=1\r
+ hx8347dProperties.width = 320;\r
+ hx8347dProperties.height = 240;\r
+ }\r
+ else\r
+ {\r
+ //lcd_cmd(0x16, 0x0008); //MY=0 MX=0 MV=0 ML=0 BGR=1\r
+ lcd_cmd(0x16, 0x00C8); //MY=1 MX=0 MV=1 ML=0 BGR=1\r
+ hx8347dProperties.width = 240;\r
+ hx8347dProperties.height = 320;\r
+ }\r
+ hx8347dPOrientation = orientation;\r
+ lcd_area(0, 0, (hx8347dProperties.width-1), (hx8347dProperties.height-1));\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
lcdOrientation_t lcdGetOrientation(void)\r
{\r
- return hx8347dPOrientation;\r
+ return hx8347dPOrientation;\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
uint16_t lcdGetWidth(void)\r
{\r
- return hx8347dProperties.width;\r
+ return hx8347dProperties.width;\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
uint16_t lcdGetHeight(void)\r
{\r
- return hx8347dProperties.height;\r
+ return hx8347dProperties.height;\r
}\r
\r
/**************************************************************************/\r
\r
void lcdScroll(int16_t pixels, uint16_t fillColor)\r
{\r
-\r
- hx8347d_Scroll(0,320,0,(offset + pixels) % 320);\r
- if(hx8347dPOrientation == LCD_ORIENTATION_PORTRAIT)\r
- {\r
- fillRect(0, hx8347dProperties.height-pixels, hx8347dProperties.width, hx8347dProperties.height, fillColor);\r
- }\r
- else\r
- {\r
- fillRect(hx8347dProperties.width-pixels, 0, hx8347dProperties.width, hx8347dProperties.height, fillColor);\r
- }\r
- offset = (offset + pixels) % 320;\r
+ hx8347d_Scroll(0,320,0,(offset + pixels) % 320);\r
+ if(hx8347dPOrientation == LCD_ORIENTATION_PORTRAIT)\r
+ {\r
+ fillRect(0, hx8347dProperties.height-pixels, hx8347dProperties.width, hx8347dProperties.height, fillColor);\r
+ }\r
+ else\r
+ {\r
+ fillRect(hx8347dProperties.width-pixels, 0, hx8347dProperties.width, hx8347dProperties.height, fillColor);\r
+ }\r
+ offset = (offset + pixels) % 320;\r
}\r
/**************************************************************************/\r
/*!\r
/**************************************************************************/\r
void hx8347d_Standby(bool deep)\r
{\r
- displayOffFlow();\r
- lcd_cmd(Power_Control_6 , Power_Control_6_STB);\r
- if(deep)\r
- {\r
- lcd_cmd(Display_Mode_Control,Display_Mode_Control_DP_STB_S);\r
- lcd_cmd(Display_Mode_Control, Display_Mode_Control_DP_STB);\r
- }\r
- lcd_cmd(OSC_Control_2, ~OSC_Control_2_OSC_EN);\r
+ displayOffFlow();\r
+ lcd_cmd(Power_Control_6 , Power_Control_6_STB);\r
+ if(deep)\r
+ {\r
+ lcd_cmd(Display_Mode_Control,Display_Mode_Control_DP_STB_S);\r
+ lcd_cmd(Display_Mode_Control, Display_Mode_Control_DP_STB);\r
+ }\r
+ lcd_cmd(OSC_Control_2, ~OSC_Control_2_OSC_EN);\r
}\r
/**************************************************************************/\r
/*!\r
/**************************************************************************/\r
void hx8347d_Wakeup(bool deep)\r
{\r
- lcd_cmd(OSC_Control_2, OSC_Control_2_OSC_EN);\r
-\r
- if(deep)\r
- {\r
- lcd_cmd(Display_Mode_Control,0x0000);\r
- systickDelay(20);\r
- lcd_cmd(Display_Mode_Control, 0x0000);\r
- }\r
- else\r
- {\r
- systickDelay(5);\r
- }\r
-\r
- lcd_cmd(Power_Control_6, 0x00D0);\r
- displayOnFlow();\r
+ lcd_cmd(OSC_Control_2, OSC_Control_2_OSC_EN);\r
+\r
+ if(deep)\r
+ {\r
+ lcd_cmd(Display_Mode_Control,0x0000);\r
+ systickDelay(20);\r
+ lcd_cmd(Display_Mode_Control, 0x0000);\r
+ }\r
+ else\r
+ {\r
+ systickDelay(5);\r
+ }\r
+\r
+ lcd_cmd(Power_Control_6, 0x00D0);\r
+ displayOnFlow();\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
uint16_t lcdGetControllerID(void)\r
{\r
- return 0x0;\r
+ return 0x0;\r
}\r
\r
/**************************************************************************/\r
/**************************************************************************/\r
lcdProperties_t lcdGetProperties(void)\r
{\r
- return hx8347dProperties;\r
+ return hx8347dProperties;\r
}\r
\r