From d345ee75e089cb3629d1cf4383344f02d279594a Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 27 Apr 2012 20:59:49 +0000 Subject: Fix/verify the STM32 LCD in all supported orientations git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4666 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/configs/stm3240g-eval/Kconfig | 22 +++++- nuttx/configs/stm3240g-eval/README.txt | 21 ++++-- nuttx/configs/stm3240g-eval/nsh/defconfig | 5 +- nuttx/configs/stm3240g-eval/nxconsole/defconfig | 5 +- nuttx/configs/stm3240g-eval/ostest/defconfig | 23 +++--- nuttx/configs/stm3240g-eval/src/up_lcd.c | 97 ++++++++++++++++++++----- 6 files changed, 129 insertions(+), 44 deletions(-) (limited to 'nuttx/configs/stm3240g-eval') diff --git a/nuttx/configs/stm3240g-eval/Kconfig b/nuttx/configs/stm3240g-eval/Kconfig index e47bd4121..fbd4f8cbb 100644 --- a/nuttx/configs/stm3240g-eval/Kconfig +++ b/nuttx/configs/stm3240g-eval/Kconfig @@ -30,7 +30,19 @@ config LCD_LANDSCAPE bool "320x240 landscape display" ---help--- Define for 320x240 display "landscape" support. Default is this 320x240 - "landscape" orientation (this setting is informative only... not used). + "landscape" orientation. + + For the STM3240G-EVAL board, the edge opposite from the row of buttons + is used as the top of the display in this orientation. + +config LCD_RLANDSCAPE + bool "320x240 reverse landscape display" + ---help--- + Define for 320x240 display "reverse landscape" support. Default is this 320x240 + "landscape" orientation. + + For the STM3240G-EVAL board, the edge next to the row of buttons + is used as the top of the display in this orientation. config LCD_PORTRAIT bool "240x320 portrait display" @@ -39,6 +51,10 @@ config LCD_PORTRAIT orientation, the STM3210E-EVAL's LCD ribbon cable is at the bottom of the display. Default is 320x240 "landscape" orientation. + In this orientation, the top of the display is to the left + of the buttons (if the board is held so that the buttons are at the + botton of the board). + config LCD_RPORTRAIT bool "240x320 reverse portrait display" ---help--- @@ -46,6 +62,10 @@ config LCD_RPORTRAIT this orientation, the STM3210E-EVAL's LCD ribbon cable is at the top of the display. Default is 320x240 "landscape" orientation. + In this orientation, the top of the display is to the right + of the buttons (if the board is held so that the buttons are at the + botton of the board). + endchoice config LCD_RDSHIFT diff --git a/nuttx/configs/stm3240g-eval/README.txt b/nuttx/configs/stm3240g-eval/README.txt index aa1c330a7..9c0cb5726 100755 --- a/nuttx/configs/stm3240g-eval/README.txt +++ b/nuttx/configs/stm3240g-eval/README.txt @@ -777,22 +777,27 @@ STM3240G-EVAL-specific Configuration Options CONFIG_LCD_LANDSCAPE - Define for 320x240 display "landscape" support. Default is this 320x240 "landscape" orientation - (this setting is informative only... not used). + For the STM3240G-EVAL board, the edge opposite from the row of buttons + is used as the top of the display in this orientation. + CONFIG_LCD_RLANDSCAPE - Define for 320x240 display "reverse + landscape" support. Default is this 320x240 "landscape" + orientation + For the STM3240G-EVAL board, the edge next to the row of buttons + is used as the top of the display in this orientation. CONFIG_LCD_PORTRAIT - Define for 240x320 display "portrait" orientation support. In this orientation, the STM3210E-EVAL's LCD ribbon cable is at the bottom of the display. Default is 320x240 "landscape" orientation. + In this orientation, the top of the display is to the left + of the buttons (if the board is held so that the buttons are at the + botton of the board). CONFIG_LCD_RPORTRAIT - Define for 240x320 display "reverse portrait" orientation support. In this orientation, the STM3210E-EVAL's LCD ribbon cable is at the top of the display. Default is 320x240 "landscape" orientation. - CONFIG_LCD_BACKLIGHT - Define to support a backlight. - CONFIG_LCD_PWM - If CONFIG_STM32_TIM1 is also defined, then an - adjustable backlight will be provided using timer 1 to generate - various pulse widthes. The granularity of the settings is - determined by CONFIG_LCD_MAXPOWER. If CONFIG_LCD_PWM (or - CONFIG_STM32_TIM1) is not defined, then a simple on/off backlight - is provided. + In this orientation, the top of the display is to the right + of the buttons (if the board is held so that the buttons are at the + botton of the board). CONFIG_LCD_RDSHIFT - When reading 16-bit gram data, there appears to be a shift in the returned data. This value fixes the offset. Default 5. diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig index 70eee412f..025bef752 100644 --- a/nuttx/configs/stm3240g-eval/nsh/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh/defconfig @@ -1245,7 +1245,9 @@ CONFIG_NXCONSOLE_CACHESIZE=32 # # CONFIG_LCD_LANDSCAPE - Define for 320x240 display "landscape" # support. Default is this 320x240 "landscape" orientation -# (this setting is informative only... not used). +# CONFIG_LCD_RLANDSCAPE - Define for 320x240 display "reverse +# landscape" support. Default is this 320x240 "landscape" +# orientation # CONFIG_LCD_PORTRAIT - Define for 240x320 display "portrait" # orientation support. In this orientation, the STM3240G-EVAL's # LCD ribbon cable is at the bottom of the display. Default is @@ -1256,6 +1258,7 @@ CONFIG_NXCONSOLE_CACHESIZE=32 # Default is 320x240 "landscape" orientation. # CONFIG_LCD_LANDSCAPE=n +CONFIG_LCD_RLANDSCAPE=n CONFIG_LCD_PORTRAIT=n CONFIG_LCD_RPORTRAIT=y diff --git a/nuttx/configs/stm3240g-eval/nxconsole/defconfig b/nuttx/configs/stm3240g-eval/nxconsole/defconfig index d845c7206..57ca2b972 100644 --- a/nuttx/configs/stm3240g-eval/nxconsole/defconfig +++ b/nuttx/configs/stm3240g-eval/nxconsole/defconfig @@ -1246,6 +1246,9 @@ CONFIG_NXCONSOLE_CACHESIZE=32 # CONFIG_LCD_LANDSCAPE - Define for 320x240 display "landscape" # support. Default is this 320x240 "landscape" orientation # (this setting is informative only... not used). +# CONFIG_LCD_RLANDSCAPE - Define for 320x240 display "reverse +# landscape" support. Default is this 320x240 "landscape" +# orientation # CONFIG_LCD_PORTRAIT - Define for 240x320 display "portrait" # orientation support. In this orientation, the STM3240G-EVAL's # LCD ribbon cable is at the bottom of the display. Default is @@ -1256,10 +1259,10 @@ CONFIG_NXCONSOLE_CACHESIZE=32 # Default is 320x240 "landscape" orientation. # CONFIG_LCD_LANDSCAPE=y +CONFIG_LCD_RLANDSCAPE=n CONFIG_LCD_PORTRAIT=n CONFIG_LCD_RPORTRAIT=n - # # STM3240G-EVAL specific LCD settings # diff --git a/nuttx/configs/stm3240g-eval/ostest/defconfig b/nuttx/configs/stm3240g-eval/ostest/defconfig index b5c384473..a10d2369a 100644 --- a/nuttx/configs/stm3240g-eval/ostest/defconfig +++ b/nuttx/configs/stm3240g-eval/ostest/defconfig @@ -1092,7 +1092,9 @@ CONFIG_NXWIDGETS_DEFAULT_FONTID=5 # # CONFIG_LCD_LANDSCAPE - Define for 320x240 display "landscape" # support. Default is this 320x240 "landscape" orientation -# (this setting is informative only... not used). +# CONFIG_LCD_RLANDSCAPE - Define for 320x240 display "reverse +# landscape" support. Default is this 320x240 "landscape" +# orientation # CONFIG_LCD_PORTRAIT - Define for 240x320 display "portrait" # orientation support. In this orientation, the PT3's # LCD ribbon cable is at the bottom of the display. Default is @@ -1101,22 +1103,17 @@ CONFIG_NXWIDGETS_DEFAULT_FONTID=5 # portrait" orientation support. In this orientation, the # STM3240G-EVAL's LCD ribbon cable is at the top of the display. # Default is 320x240 "landscape" orientation. -# CONFIG_LCD_BACKLIGHT - Define to support a backlight. -# CONFIG_LCD_PWM - If CONFIG_STM32_TIM1 is also defined, then an -# adjustable backlight will be provided using timer 1 to generate -# various pulse widthes. The granularity of the settings is -# determined by CONFIG_LCD_MAXPOWER. If CONFIG_LCD_PWM (or -# CONFIG_STM32_TIM1) is not defined, then a simple on/off backlight -# is provided. # CONFIG_LCD_LANDSCAPE=n +CONFIG_LCD_RLANDSCAPE=n CONFIG_LCD_PORTRAIT=n CONFIG_LCD_RPORTRAIT=y -CONFIG_LCD_BACKLIGHT=y -CONFIG_LCD_PWM=n -CONFIG_STM32_AM240320_DISABLE=y -CONFIG_STM32_SPFD5408B_DISABLE=n -CONFIG_STM32_R61580_DISABLE=n + +# +# STM3240G-EVAL specific LCD settings +# +CONFIG_STM32_ILI9320_DISABLE=n +CONFIG_STM32_ILI9325_DISABLE=n # # Settings for examples/uip diff --git a/nuttx/configs/stm3240g-eval/src/up_lcd.c b/nuttx/configs/stm3240g-eval/src/up_lcd.c index 4ab5c0258..c24e6b0c3 100644 --- a/nuttx/configs/stm3240g-eval/src/up_lcd.c +++ b/nuttx/configs/stm3240g-eval/src/up_lcd.c @@ -93,14 +93,18 @@ /* Check orientation */ #if defined(CONFIG_LCD_PORTRAIT) -# if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RPORTRAIT) +# if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) || defined(CONFIG_LCD_RPORTRAIT) # error "Cannot define both portrait and any other orientations" # endif #elif defined(CONFIG_LCD_RPORTRAIT) -# if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_PORTRAIT) +# if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) # error "Cannot define both rportrait and any other orientations" # endif -#elif !defined(CONFIG_LCD_LANDSCAPE) +#elif defined(CONFIG_LCD_LANDSCAPE) +# ifdef defined(CONFIG_LCD_RLANDSCAPE) +# error "Cannot define both landscape and any other orientations" +# endif +#elif !defined(CONFIG_LCD_RLANDSCAPE) # define CONFIG_LCD_LANDSCAPE 1 #endif @@ -121,7 +125,7 @@ /* Display/Color Properties ***********************************************************/ /* Display Resolution */ -#ifdef CONFIG_LCD_LANDSCAPE +#if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) # define STM3240G_XRES 320 # define STM3240G_YRES 240 #else @@ -585,11 +589,35 @@ static int stm3240g_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu /* Write the run to GRAM. */ #ifdef CONFIG_LCD_LANDSCAPE - /* Convert coordinates -- Which edge of the display is the "top?" Here the edge - * with the simplest conversion is used. + /* Convert coordinates -- Here the edge away from the row of buttons on + * the STM3240G-EVAL is used as the top. + */ + + /* Set the cursor position */ + + stm3240g_setcursor(col, row); + + /* Then write the GRAM data, manually incrementing X */ + + for (i = 0; i < npixels; i++) + { + /* Write the next pixel to this position */ + + stm3240g_setcursor(col, row); + stm3240g_gramselect(); + stm3240g_writegram(*src++); + + /* Increment to next column */ + + col++; + } +#elif defined(CONFIG_LCD_RLANDSCAPE) + /* Convert coordinates -- Here the edge next to the row of buttons on + * the STM3240G-EVAL is used as the top. */ col = (STM3240G_XRES-1) - col; + row = (STM3240G_YRES-1) - row; /* Set the cursor position */ @@ -605,7 +633,12 @@ static int stm3240g_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu stm3240g_writegram(*src++); } #elif defined(CONFIG_LCD_PORTRAIT) - /* Convert coordinates. (Swap row and column. This is done implicitly). */ + /* Convert coordinates. In this configuration, the top of the display is to the left + * of the buttons (if the board is held so that the buttons are at the botton of the + * board). + */ + + col = (STM3240G_XRES-1) - col; /* Then write the GRAM data, manually incrementing Y (which is col) */ @@ -619,14 +652,14 @@ static int stm3240g_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu /* Increment to next column */ - col++; + col--; } #else /* CONFIG_LCD_RPORTRAIT */ - /* Convert coordinates. (Swap row and column. This is done implicitly). - * Which edge of the display is the "top"? + /* Convert coordinates. In this configuration, the top of the display is to the right + * of the buttons (if the board is held so that the buttons are at the botton of the + * board). */ - col = (STM3240G_XRES-1) - col; row = (STM3240G_YRES-1) - row; /* Then write the GRAM data, manually incrementing Y (which is col) */ @@ -641,7 +674,7 @@ static int stm3240g_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu /* Decrement to next column */ - col--; + col++; } #endif return OK; @@ -698,11 +731,30 @@ static int stm3240g_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, /* Read the run from GRAM. */ #ifdef CONFIG_LCD_LANDSCAPE - /* Convert coordinates -- Which edge of the display is the "top?" Here the edge - * with the simplest conversion is used. + /* Convert coordinates -- Here the edge away from the row of buttons on + * the STM3240G-EVAL is used as the top. + */ + + for (i = 0; i < npixels; i++) + { + /* Read the next pixel from this position */ + + stm3240g_setcursor(row, col); + stm3240g_gramselect(); + readsetup(&accum); + *dest++ = readgram(&accum); + + /* Increment to next column */ + + col++; + } +#elif defined(CONFIG_LCD_RLANDSCAPE) + /* Convert coordinates -- Here the edge next to the row of buttons on + * the STM3240G-EVAL is used as the top. */ col = (STM3240G_XRES-1) - col; + row = (STM3240G_YRES-1) - row; /* Set the cursor position */ @@ -723,7 +775,12 @@ static int stm3240g_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, *dest++ = readgram(&accum); } #elif defined(CONFIG_LCD_PORTRAIT) - /* Convert coordinates (Swap row and column. This is done implicitly). */ + /* Convert coordinates. In this configuration, the top of the display is to the left + * of the buttons (if the board is held so that the buttons are at the botton of the + * board). + */ + + col = (STM3240G_XRES-1) - col; /* Then read the GRAM data, manually incrementing Y (which is col) */ @@ -738,14 +795,14 @@ static int stm3240g_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, /* Increment to next column */ - col++; + col--; } #else /* CONFIG_LCD_RPORTRAIT */ - /* Convert coordinates. (Swap row and column. This is done implicitly). - * Whic edge of the display is the "top"? + /* Convert coordinates. In this configuration, the top of the display is to the right + * of the buttons (if the board is held so that the buttons are at the botton of the + * board). */ - col = (STM3240G_XRES-1) - col; row = (STM3240G_YRES-1) - row; /* Then write the GRAM data, manually incrementing Y (which is col) */ @@ -761,7 +818,7 @@ static int stm3240g_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, /* Decrement to next column */ - col--; + col++; } #endif -- cgit v1.2.3