A wrapper Class library for using the touch LCD on the DISCO-F469NI Development board. The class uses the existing BSP class created by Team ST.

Dependencies:   BSP_DISCO_F469NI LCD_DISCO_F469NI TS_DISCO_F469NI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DISCOF469LCD.cpp Source File

DISCOF469LCD.cpp

00001 #include "DISCOF469LCD.h"
00002 #include "mbed.h"
00003 
00004 /* ***************************************** Public Functions ***************************************** */
00005 
00006 DISCOF469LCD::DISCOF469LCD(void) {
00007     //mTouches=0;
00008     ts.Init(lcd.GetXSize(), lcd.GetYSize());
00009     Clear(LCD_BLACK);
00010 }
00011 
00012 void DISCOF469LCD::Clear(uint32_t Color) {
00013     lcd.Clear(Color);
00014 }
00015 
00016 void DISCOF469LCD::DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code)
00017 {
00018     lcd.DrawPixel(Xpos, Ypos, RGB_Code);
00019 }
00020 
00021 uint32_t DISCOF469LCD::ReadPixel(uint16_t Xpos, uint16_t Ypos)
00022 {
00023     return(lcd.ReadPixel(Xpos, Ypos));
00024 }
00025 
00026 void DISCOF469LCD::DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t Color)
00027 {
00028     lcd.SetTextColor(Color);
00029     lcd.DrawLine(x1, y1, x2, y2);
00030 }
00031 
00032 void DISCOF469LCD::DrawRectangle(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height, uint32_t Color)
00033 {
00034     lcd.SetTextColor(Color);
00035     lcd.DrawRect(Xpos, Ypos, Width, Height);
00036 }
00037 
00038 void DISCOF469LCD::FillRectangle(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height, uint32_t Color)
00039 {
00040     lcd.SetTextColor(Color);
00041     lcd.FillRect(Xpos, Ypos, Width, Height);
00042 }
00043 
00044 void DISCOF469LCD::DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius, uint32_t Color)
00045 {
00046     lcd.SetTextColor(Color);
00047     lcd.DrawCircle(Xpos, Ypos, Radius);
00048 }
00049 
00050 void DISCOF469LCD::FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius, uint32_t Color)
00051 {
00052     lcd.SetTextColor(Color);
00053     lcd.FillCircle(Xpos, Ypos, Radius);
00054 }
00055 
00056 void DISCOF469LCD::DrawEllipse(uint16_t Xpos, uint16_t Ypos, uint16_t XRadius, uint16_t YRadius, uint32_t Color)
00057 {
00058     lcd.SetTextColor(Color);
00059     lcd.DrawEllipse(Xpos, Ypos, XRadius, YRadius);
00060 }
00061 
00062 
00063 void DISCOF469LCD::FillEllipse(uint16_t Xpos, uint16_t Ypos, uint16_t XRadius, uint16_t YRadius, uint32_t Color)
00064 {
00065     lcd.SetTextColor(Color);
00066     lcd.FillEllipse(Xpos, Ypos, XRadius, YRadius);
00067 }
00068 
00069 void DISCOF469LCD::DrawStringAtXY(uint16_t Xpos, uint16_t Ypos, uint8_t FontSize, uint32_t TextColor, uint32_t BackColor, char *Text)
00070 {
00071     switch(FontSize)
00072     {
00073         case 0:    BSP_LCD_SetFont(&Font8); break;
00074         case 1:    BSP_LCD_SetFont(&Font12); break; 
00075         case 2:    BSP_LCD_SetFont(&Font16); break; 
00076         case 3:    BSP_LCD_SetFont(&Font20); break;
00077         case 4:    BSP_LCD_SetFont(&Font24); break;
00078         default:   BSP_LCD_SetFont(&Font8); 
00079     }
00080     lcd.SetBackColor(BackColor);
00081     lcd.SetTextColor(TextColor);
00082     lcd.DisplayStringAt(Xpos, Ypos, (uint8_t *)Text, LEFT_MODE);
00083 }
00084 
00085 void DISCOF469LCD::DrawStringAtLine(uint16_t Line, uint8_t FontSize, uint32_t TextColor, uint32_t BackColor, uint8_t Mode, char *Text)
00086 {
00087     switch(FontSize)
00088     {
00089         case 0:    BSP_LCD_SetFont(&Font8); break;
00090         case 1:    BSP_LCD_SetFont(&Font12); break; 
00091         case 2:    BSP_LCD_SetFont(&Font16); break; 
00092         case 3:    BSP_LCD_SetFont(&Font20); break;
00093         case 4:    BSP_LCD_SetFont(&Font24); break;
00094         default:   BSP_LCD_SetFont(&Font8); 
00095     }
00096     lcd.SetBackColor(BackColor);
00097     lcd.SetTextColor(TextColor);
00098     switch(Mode)
00099     {
00100         case 0:    lcd.DisplayStringAt(0, LINE(Line), (uint8_t *)Text, LEFT_MODE); break;
00101         case 1:    lcd.DisplayStringAt(0, LINE(Line), (uint8_t *)Text, CENTER_MODE); break;
00102         case 2:    lcd.DisplayStringAt(0, LINE(Line), (uint8_t *)Text, RIGHT_MODE); break;
00103         default:    lcd.DisplayStringAt(0, LINE(Line), (uint8_t *)Text, LEFT_MODE);
00104     }
00105     
00106 }
00107 
00108 uint8_t DISCOF469LCD::Touches(void)
00109 {
00110     TS_StateTypeDef TS_State;
00111     
00112     ts.GetState(&TS_State);
00113     return TS_State.touchDetected;
00114 }
00115 
00116 void DISCOF469LCD::GetTouch1(uint16_t *x, uint16_t *y)
00117 {
00118     TS_StateTypeDef TS_State;
00119     
00120     ts.GetState(&TS_State);
00121     *x = TS_State.touchX[0];
00122     *y = TS_State.touchY[0];
00123 }
00124 
00125 void DISCOF469LCD::GetTouch2(uint16_t *x, uint16_t *y)
00126 {
00127     TS_StateTypeDef TS_State;
00128     
00129     ts.GetState(&TS_State);
00130     *x = TS_State.touchX[1];
00131     *y = TS_State.touchY[1];
00132 }
00133 
00134 /* ***************************************** Private Functions ***************************************** */