Arm Mbed OS support forum

Touch screen help on the STM32F4291-DISC1 board

#include “mbed.h”
#include “TS_DISCO_F429ZI.h”
#include “LCD_DISCO_F429ZI.h”

LCD_DISCO_F429ZI lcd1;
TS_DISCO_F429ZI ts;
TS_StateTypeDef TS_State;

int main()
{
uint16_t x, y;
uint8_t text[30];

 /* ...Code to display initial message omitted ...*/ 
 /* .... Code to initial and test status omitted. ...*/

uint32_t q1color = 0xFFFF00FF; 
lcd1.Clear(q1color);
wait(2); 

sprintf((char*)text, "Max (x,y) = (%d, %d) ", lcd1.GetXSize(), lcd1.GetYSize() ); 
lcd1.DisplayStringAt(0 ,LINE(12),(uint8_t*) &text, RIGHT_MODE);

while(1)
{
ts.GetState(&TS_State);
if (TS_State.TouchDetected)
{
x = TS_State.X;
y = TS_State.Y;

        sprintf((char*)text, "x=%d y=%d ", x, y);
        lcd1.DisplayStringAt(0, LINE(4), (uint8_t *) &text, CENTER_MODE); 
        }
} 

}

Hey here is a code for a simple x,y display. I was wondering how would I be able to make the 4 quadrants on the screen be different colors?

Hello,

The LCD_DISCO_F429ZI.h contains methods for

  • set color - void SetTextColor(uint32_t Color); and colors are defined here line 116+
  • cread filed rectangle - FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);

For inspiration you can use DISCO-F429ZI_LCD_demo and build something like this (I can not verified it because I do not have this hardware. )

      lcd.SetTextColor(LCD_COLOR_BLUE);
      lcd.FillRect(0, 0, lcd1.GetXSize()/2, lcd1.GetYSize()/2);
      wait(0.1);
      lcd.SetTextColor(LCD_COLOR_RED);
      lcd.FillRect(lcd1.GetXSize()/2, 0,  lcd1.GetXSize()/2, lcd1.GetYSize()/2);
      wait(0.1);
      lcd.SetTextColor(LCD_COLOR_GREEN);
      lcd.FillRect(0, lcd1.GetYSize()/2,  lcd1.GetXSize()/2, lcd1.GetYSize()/2);
      wait(0.1);
      lcd.SetTextColor(LCD_COLOR_YELLOW );
      lcd.FillRect(lcd1.GetXSize()/2, lcd1.GetYSize()/2,  lcd1.GetXSize()/2, lcd1.GetYSize()/2);
      wait(0.1);

BR, Jan