summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NxWidgets/ChangeLog.txt8
-rw-r--r--NxWidgets/TODO.txt15
-rw-r--r--NxWidgets/libnxwidgets/include/cgraphicsport.hxx30
-rw-r--r--NxWidgets/libnxwidgets/src/cbuttonarray.cxx18
-rw-r--r--nuttx/configs/stm3240g-eval/src/up_lcd.c192
5 files changed, 143 insertions, 120 deletions
diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt
index 349dbac57..f688f846c 100644
--- a/NxWidgets/ChangeLog.txt
+++ b/NxWidgets/ChangeLog.txt
@@ -144,3 +144,11 @@
example.
* NXWidgets::CNxTkWindow: Back out height adjustment in the getSize()
method. The code was correct as it was before.
+* NXWidgets::CButtonArray and NXWidgets::CGraphicsPort: There is
+ a kludge in there to handle the case where we cannot read the
+ background data because the LCD does not support read operations.
+ In that case, we just use the default background color. However,
+ that doesn't work either for the case where the background color
+ changes when the widget is selected. Thenthe background color
+ in the font is wrong. Fixed in CButtonArrary, but the problem
+ probably exists in other places as well.
diff --git a/NxWidgets/TODO.txt b/NxWidgets/TODO.txt
index edd203210..ebf136798 100644
--- a/NxWidgets/TODO.txt
+++ b/NxWidgets/TODO.txt
@@ -127,3 +127,18 @@ o Platform specific issues
The fixed version is available in SVN but won't be in a released
version until NuttX-6.198 is released.
Priorioty: Low, but really annoying.
+
+ Title: BUGS WHEN CANNOT READ FROM LCD
+ Description: There is a kludge in there to handle the case where we cannot
+ read the background data because the LCD does not support read
+ operations. You cannot read from the STM3240G-EVAL LCD right
+ now (it might be possible, but I have not figured out how yet).
+
+ In that case, we just use the default background color. However,
+ that doesn't work either for the case where the background color
+ changes when the widget is selected. Then the background color
+ in the font is wrong. There is a hack in in CButtonArrary that
+ fixed this problem, but the problem certainly exists in other
+ places as well and begs for a better solution.
+ Status: Open
+ Priority: Medium-Low
diff --git a/NxWidgets/libnxwidgets/include/cgraphicsport.hxx b/NxWidgets/libnxwidgets/include/cgraphicsport.hxx
index 8eea3d689..b9fbc4d41 100644
--- a/NxWidgets/libnxwidgets/include/cgraphicsport.hxx
+++ b/NxWidgets/libnxwidgets/include/cgraphicsport.hxx
@@ -152,6 +152,36 @@ namespace NXWidgets
const nxgl_coord_t getY(void) const;
/**
+ * Get the background color that will be used to fill in the spaces
+ * when rendering fonts. This background color is ONLY used if the
+ * LCD device does not support reading GRAM contents.
+ *
+ * @return. The current background color being used.
+ */
+
+#ifdef CONFIG_NX_WRITEONLY
+ nxgl_mxpixel_t getBackColor(void) const
+ {
+ return m_backColor;
+ }
+#endif
+
+ /**
+ * Set the background color that will be used to fill in the spaces
+ * when rendering fonts. This background color is ONLY used if the
+ * LCD device does not support reading GRAM contents.
+ *
+ * @return. The current background color being used.
+ */
+
+#ifdef CONFIG_NX_WRITEONLY
+ void setBackColor(nxgl_mxpixel_t backColor)
+ {
+ m_backColor = backColor;
+ }
+#endif
+
+ /**
* Draw a pixel into the window.
*
* @param x The window-relative x coordinate of the pixel.
diff --git a/NxWidgets/libnxwidgets/src/cbuttonarray.cxx b/NxWidgets/libnxwidgets/src/cbuttonarray.cxx
index 642a0a562..28f14062b 100644
--- a/NxWidgets/libnxwidgets/src/cbuttonarray.cxx
+++ b/NxWidgets/libnxwidgets/src/cbuttonarray.cxx
@@ -519,9 +519,25 @@ void CButtonArray::drawButton(CGraphicsPort *port, int column, int row, bool use
pos.x = x + alignX;
pos.y = y + alignY;
- // And draw the button text
+ // Set the CGraphicsControl background to match the selected background color.
+ // This is only necessary if we cannot read from the LCD. If we cannot read
+ // from then the font background is set to this background color.
+ // REVISIT: This begs for a more generalized solution.
+
+#ifdef CONFIG_NX_WRITEONLY
+ nxgl_mxpixel_t saveColor = port->getBackColor();
+ port->setBackColor(backColor);
+#endif
+
+ // And draw the button text.
port->drawText(&pos, &rect, getFont(), *text, 0, text->getLength(), textColor);
+
+ // Restore the default background color
+
+#ifdef CONFIG_NX_WRITEONLY
+ port->setBackColor(saveColor);
+#endif
}
/**
diff --git a/nuttx/configs/stm3240g-eval/src/up_lcd.c b/nuttx/configs/stm3240g-eval/src/up_lcd.c
index c781e08dc..e20988075 100644
--- a/nuttx/configs/stm3240g-eval/src/up_lcd.c
+++ b/nuttx/configs/stm3240g-eval/src/up_lcd.c
@@ -64,6 +64,8 @@
#include "stm32_internal.h"
#include "stm3240g-internal.h"
+#if !defined(CONFIG_STM32_ILI9320_DISABLE) || !defined(CONFIG_STM32_ILI9325_DISABLE)
+
/**************************************************************************************
* Pre-processor Definitions
**************************************************************************************/
@@ -705,22 +707,16 @@ static int stm3240g_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
lcdvdbg("row: %d col: %d npixels: %d\n", row, col, npixels);
DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0);
- /* Configure according to the LCD type */
+ /* Configure according to the LCD type. Kind of silly with only one LCD type. */
switch (g_lcddev.type)
{
-#if !defined(CONFIG_STM32_ILI9320_DISABLE)
- case LCD_TYPE_ILI9320:
- readsetup = stm3240g_readnosetup;
- readgram = stm3240g_readnoshift;
- break;
-#endif
-#if !defined(CONFIG_STM32_ILI9325_DISABLE)
- case LCD_TYPE_ILI9325:
+ case LCD_TYPE_ILI9320:
+ case LCD_TYPE_ILI9325:
readsetup = stm3240g_readnosetup;
readgram = stm3240g_readnoshift;
break;
-#endif
+
default: /* Shouldn't happen */
return -ENOSYS;
}
@@ -973,21 +969,42 @@ static inline void stm3240g_lcdinitialize(void)
id = stm3240g_readreg(LCD_REG_0);
lcddbg("LCD ID: %04x\n", id);
- /* Check if the ID is for the STM32_ILI9320 (or ILI9321) & STM32_ILI9325 */
+ /* Check if the ID is for the STM32_ILI9320 (or ILI9321) or STM32_ILI9325 */
-#if !defined(CONFIG_STM32_ILI9320_DISABLE)
- if ((id == ILI9320_ID) || (id == ILI9321_ID))
+#if !defined(CONFIG_STM32_ILI9320_DISABLE) && !defined(CONFIG_STM32_ILI9325_DISABLE)
+ if (id == ILI9320_ID || id == ILI9321_ID || id == ILI9325_ID)
+#elif !defined(CONFIG_STM32_ILI9320_DISABLE) && defined(CONFIG_STM32_ILI9325_DISABLE)
+ if (id == ILI9320_ID || id == ILI9321_ID)
+#else /* if defined(CONFIG_STM32_ILI9320_DISABLE) && !defined(CONFIG_STM32_ILI9325_DISABLE)) */
+ if (id == ILI9325_ID)
+#endif
{
- g_lcddev.type = LCD_TYPE_ILI9320;
+ /* Save the LCD type (not actually used at for anything important) */
+
+#if !defined(CONFIG_STM32_ILI9320_DISABLE)
+# if !defined(CONFIG_STM32_ILI9325_DISABLE)
+ if (id == ILI9325_ID)
+ {
+ g_lcddev.type = LCD_TYPE_ILI9325;
+ }
+ else
+# endif
+ {
+ g_lcddev.type = LCD_TYPE_ILI9320;
+ stm3240g_writereg(LCD_REG_229, 0x8000); /* Set the internal vcore voltage */
+ }
+#else /* if !defined(CONFIG_STM32_ILI9325_DISABLE) */
+ g_lcddev.type = LCD_TYPE_ILI9325;
+#endif
lcddbg("LCD type: %d\n", g_lcddev.type);
/* Start Initial Sequence */
- stm3240g_writereg(LCD_REG_229, 0x8000); /* Set the internal vcore voltage */
stm3240g_writereg(LCD_REG_0, 0x0001); /* Start internal OSC. */
stm3240g_writereg(LCD_REG_1, 0x0100); /* Set SS and SM bit */
stm3240g_writereg(LCD_REG_2, 0x0700); /* Set 1 line inversion */
stm3240g_writereg(LCD_REG_3, 0x1030); /* Set GRAM write direction and BGR=1. */
+ //stm3240g_writereg(LCD_REG_3, 0x1018); /* Set GRAM write direction and BGR=1. */
stm3240g_writereg(LCD_REG_4, 0x0000); /* Resize register */
stm3240g_writereg(LCD_REG_8, 0x0202); /* Set the back porch and front porch */
stm3240g_writereg(LCD_REG_9, 0x0000); /* Set non-display area refresh cycle ISC[3:0] */
@@ -1018,19 +1035,45 @@ static inline void stm3240g_lcdinitialize(void)
stm3240g_writereg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */
stm3240g_writereg(LCD_REG_33, 0x0000); /* GRAM Vertical Address */
- /* Adjust the Gamma Curve */
-
- stm3240g_writereg(LCD_REG_48, 0x0006);
- stm3240g_writereg(LCD_REG_49, 0x0101);
- stm3240g_writereg(LCD_REG_50, 0x0003);
- stm3240g_writereg(LCD_REG_53, 0x0106);
- stm3240g_writereg(LCD_REG_54, 0x0b02);
- stm3240g_writereg(LCD_REG_55, 0x0302);
- stm3240g_writereg(LCD_REG_56, 0x0707);
- stm3240g_writereg(LCD_REG_57, 0x0007);
- stm3240g_writereg(LCD_REG_60, 0x0600);
- stm3240g_writereg(LCD_REG_61, 0x020b);
-
+ /* Adjust the Gamma Curve (ILI9320/1) */
+
+#if !defined(CONFIG_STM32_ILI9320_DISABLE)
+# if !defined(CONFIG_STM32_ILI9325_DISABLE)
+ if (g_lcddev.type == LCD_TYPE_ILI9320)
+# endif
+ {
+ stm3240g_writereg(LCD_REG_48, 0x0006);
+ stm3240g_writereg(LCD_REG_49, 0x0101);
+ stm3240g_writereg(LCD_REG_50, 0x0003);
+ stm3240g_writereg(LCD_REG_53, 0x0106);
+ stm3240g_writereg(LCD_REG_54, 0x0b02);
+ stm3240g_writereg(LCD_REG_55, 0x0302);
+ stm3240g_writereg(LCD_REG_56, 0x0707);
+ stm3240g_writereg(LCD_REG_57, 0x0007);
+ stm3240g_writereg(LCD_REG_60, 0x0600);
+ stm3240g_writereg(LCD_REG_61, 0x020b);
+ }
+#endif
+ /* Adjust the Gamma Curve (ILI9325) */
+
+#if !defined(CONFIG_STM32_ILI9325_DISABLE)
+# if !defined(CONFIG_STM32_ILI9320_DISABLE)
+ else
+# endif
+ {
+ stm3240g_writereg(LCD_REG_48, 0x0007);
+ stm3240g_writereg(LCD_REG_49, 0x0302);
+ stm3240g_writereg(LCD_REG_50, 0x0105);
+ stm3240g_writereg(LCD_REG_53, 0x0206);
+ stm3240g_writereg(LCD_REG_54, 0x0808);
+ stm3240g_writereg(LCD_REG_55, 0x0206);
+ stm3240g_writereg(LCD_REG_56, 0x0504);
+ stm3240g_writereg(LCD_REG_57, 0x0007);
+ stm3240g_writereg(LCD_REG_60, 0x0105);
+ stm3240g_writereg(LCD_REG_61, 0x0808);
+ }
+#endif
+
/* Set GRAM area */
stm3240g_writereg(LCD_REG_80, 0x0000); /* Horizontal GRAM Start Address */
@@ -1038,6 +1081,7 @@ static inline void stm3240g_lcdinitialize(void)
stm3240g_writereg(LCD_REG_82, 0x0000); /* Vertical GRAM Start Address */
stm3240g_writereg(LCD_REG_83, 0x013f); /* Vertical GRAM End Address */
stm3240g_writereg(LCD_REG_96, 0x2700); /* Gate Scan Line */
+ //stm3240g_writereg(LCD_REG_96, 0xa700); /* Gate Scan Line(GS=1, scan direction is G320~G1) */
stm3240g_writereg(LCD_REG_97, 0x0001); /* NDL,VLE, REV */
stm3240g_writereg(LCD_REG_106, 0x0000); /* Set scrolling line */
@@ -1069,97 +1113,6 @@ static inline void stm3240g_lcdinitialize(void)
stm3240g_writereg(LCD_REG_7, 0); /* Display off */
}
else
-#endif
-#if !defined(CONFIG_STM32_ILI9325_DISABLE)
- if (id == ILI9325_ID)
- {
- g_lcddev.type = LCD_TYPE_ILI9325;
- lcddbg("LCD type: %d\n", g_lcddev.type);
-
- /* Start Initial Sequence */
-
- stm3240g_writereg(LCD_REG_0, 0x0001); /* Start internal OSC. */
- stm3240g_writereg(LCD_REG_1, 0x0100); /* Set SS and SM bit */
- stm3240g_writereg(LCD_REG_2, 0x0700); /* Set 1 line inversion */
- stm3240g_writereg(LCD_REG_3, 0x1018); /* Set GRAM write direction and BGR=1. */
- stm3240g_writereg(LCD_REG_4, 0x0000); /* Resize register */
- stm3240g_writereg(LCD_REG_8, 0x0202); /* Set the back porch and front porch */
- stm3240g_writereg(LCD_REG_9, 0x0000); /* Set non-display area refresh cycle ISC[3:0] */
- stm3240g_writereg(LCD_REG_10, 0x0000); /* FMARK function */
- stm3240g_writereg(LCD_REG_12, 0x0000); /* RGB interface setting */
- stm3240g_writereg(LCD_REG_13, 0x0000); /* Frame marker Position */
- stm3240g_writereg(LCD_REG_15, 0x0000); /* RGB interface polarity */
-
- /* Power On sequence */
-
- stm3240g_writereg(LCD_REG_16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
- stm3240g_writereg(LCD_REG_17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
- stm3240g_writereg(LCD_REG_18, 0x0000); /* VREG1OUT voltage */
- stm3240g_writereg(LCD_REG_19, 0x0000); /* VDV[4:0] for VCOM amplitude */
- up_mdelay(200); /* Dis-charge capacitor power voltage (200ms) */
- stm3240g_writereg(LCD_REG_16, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
- stm3240g_writereg(LCD_REG_17, 0x0137); /* DC1[2:0], DC0[2:0], VC[2:0] */
- up_mdelay(50); /* Delay 50 ms */
- stm3240g_writereg(LCD_REG_18, 0x0139); /* VREG1OUT voltage */
- up_mdelay(50); /* Delay 50 ms */
- stm3240g_writereg(LCD_REG_19, 0x1d00); /* VDV[4:0] for VCOM amplitude */
- stm3240g_writereg(LCD_REG_41, 0x0013); /* VCM[4:0] for VCOMH */
- up_mdelay(50); /* Delay 50 ms */
- stm3240g_writereg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */
- stm3240g_writereg(LCD_REG_33, 0x0000); /* GRAM Vertical Address */
-
- /* Adjust the Gamma Curve (ILI9325) */
-
- stm3240g_writereg(LCD_REG_48, 0x0007);
- stm3240g_writereg(LCD_REG_49, 0x0302);
- stm3240g_writereg(LCD_REG_50, 0x0105);
- stm3240g_writereg(LCD_REG_53, 0x0206);
- stm3240g_writereg(LCD_REG_54, 0x0808);
- stm3240g_writereg(LCD_REG_55, 0x0206);
- stm3240g_writereg(LCD_REG_56, 0x0504);
- stm3240g_writereg(LCD_REG_57, 0x0007);
- stm3240g_writereg(LCD_REG_60, 0x0105);
- stm3240g_writereg(LCD_REG_61, 0x0808);
-
- /* Set GRAM area */
-
- stm3240g_writereg(LCD_REG_80, 0x0000); /* Horizontal GRAM Start Address */
- stm3240g_writereg(LCD_REG_81, 0x00EF); /* Horizontal GRAM End Address */
- stm3240g_writereg(LCD_REG_82, 0x0000); /* Vertical GRAM Start Address */
- stm3240g_writereg(LCD_REG_83, 0x013F); /* Vertical GRAM End Address */
-
- stm3240g_writereg(LCD_REG_96, 0xA700); /* Gate Scan Line(GS=1, scan direction is G320~G1) */
- stm3240g_writereg(LCD_REG_97, 0x0001); /* NDL,VLE, REV */
- stm3240g_writereg(LCD_REG_106, 0x0000); /* set scrolling line */
-
- /* Partial Display Control */
-
- stm3240g_writereg(LCD_REG_128, 0x0000);
- stm3240g_writereg(LCD_REG_129, 0x0000);
- stm3240g_writereg(LCD_REG_130, 0x0000);
- stm3240g_writereg(LCD_REG_131, 0x0000);
- stm3240g_writereg(LCD_REG_132, 0x0000);
- stm3240g_writereg(LCD_REG_133, 0x0000);
-
- /* Panel Control */
-
- stm3240g_writereg(LCD_REG_144, 0x0010);
- stm3240g_writereg(LCD_REG_146, 0x0000);
- stm3240g_writereg(LCD_REG_147, 0x0003);
- stm3240g_writereg(LCD_REG_149, 0x0110);
- stm3240g_writereg(LCD_REG_151, 0x0000);
- stm3240g_writereg(LCD_REG_152, 0x0000);
-
- /* set GRAM write direction and BGR = 1 */
- /* I/D=00 (Horizontal : increment, Vertical : decrement) */
- /* AM=1 (address is updated in vertical writing direction) */
-
- stm3240g_writereg(LCD_REG_3, 0x1018);
-
- stm3240g_writereg(LCD_REG_7, 0x0); /* display off */
- }
- else
-#endif
{
lcddbg("Unsupported LCD type\n");
}
@@ -1254,3 +1207,4 @@ void stm3240g_lcdclear(uint16_t color)
}
}
+#endif /* !CONFIG_STM32_ILI9320_DISABLE || !CONFIG_STM32_ILI9325_DISABLE */