Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: SignalProcessLab DigitalSignalAlgorithm_Lab DigitalSignal_Lab
RK043FN48H.cpp
00001 // 00002 // RK043FN48H.h - DISCO_F746NG display 00003 // 00004 00005 #include "RK043FN48H.h" 00006 00007 static Layer _selectedLayer = Foreground; 00008 00009 RK043FN48H::RK043FN48H() 00010 { 00011 BSP_LCD_Init(); 00012 00013 FbBackgroundStartAdress = LCD_FB_START_ADDRESS; 00014 FbForegroundStartAdress = LCD_FB_START_ADDRESS+(BSP_LCD_GetXSize()*BSP_LCD_GetYSize()*4); 00015 00016 BSP_LCD_LayerDefaultInit(0, FbBackgroundStartAdress); 00017 BSP_LCD_LayerDefaultInit(1, FbForegroundStartAdress); 00018 00019 BSP_LCD_DisplayOn(); 00020 00021 actualDrawProp[0].TextColor = LCD_COLOR_WHITE; 00022 actualDrawProp[0].BackColor = LCD_COLOR_BLACK; 00023 actualDrawProp[0].pFont = &Font16; // &LCD_DEFAULT_FONT 00024 //_selectedFont[0] = GrFont(Courier16); 00025 00026 actualDrawProp[1].TextColor = LCD_COLOR_WHITE & ALPHA_MASK; 00027 actualDrawProp[1].BackColor = LCD_COLOR_BLACK & ALPHA_MASK; 00028 actualDrawProp[1].pFont = &Font16; // &LCD_DEFAULT_FONT 00029 //_selectedFont[1] = GrFont(Courier16); 00030 00031 // Initialize layer 0 properties 00032 SetActiveLayer(Background); 00033 SetBackgroundColor(actualDrawProp[0].BackColor); 00034 Clear(); 00035 SetForegroundColor(actualDrawProp[0].TextColor); 00036 BSP_LCD_SetFont(&Font16); 00037 00038 // Initialize layer 1 properties 00039 SetActiveLayer(Foreground); 00040 SetBackgroundColor(actualDrawProp[1].BackColor); 00041 Clear(); 00042 SetForegroundColor(actualDrawProp[1].TextColor); 00043 BSP_LCD_SetFont(&Font16); 00044 00045 // Set layers transparency 00046 SetLayersTransparency(0xFF, 0xFF); 00047 SetLayersVisibility(true, true); 00048 00049 /* 00050 _cursorPos[Background].X = 0; 00051 _cursorPos[Background].Y = 0; 00052 _cursorPos[Foreground].X = 0; 00053 _cursorPos[Foreground].Y = 0; 00054 */ 00055 } 00056 00057 00058 RK043FN48H::~RK043FN48H() 00059 { 00060 BSP_LCD_DeInit(); 00061 } 00062 00063 00064 void RK043FN48H::Clear() 00065 { 00066 BSP_LCD_Clear(actualDrawProp[_selectedLayer].BackColor); 00067 } 00068 00069 00070 void RK043FN48H::Clear(uint32_t color) 00071 { 00072 BSP_LCD_Clear(color); 00073 } 00074 00075 00076 void RK043FN48H::ClearLayer(Layer layer, uint32_t color) 00077 { 00078 Layer oldLayer = GetActiveLayer(); 00079 00080 SetActiveLayer(layer); 00081 Clear(color); 00082 SetActiveLayer(oldLayer); 00083 } 00084 00085 00086 void RK043FN48H::SetBackgroundColor(uint32_t color) 00087 { 00088 actualDrawProp[_selectedLayer].BackColor = color; 00089 BSP_LCD_SetBackColor(actualDrawProp[_selectedLayer].BackColor); 00090 } 00091 00092 00093 void RK043FN48H::SetForegroundColor(uint32_t color) 00094 { 00095 actualDrawProp[_selectedLayer].TextColor = color; 00096 BSP_LCD_SetTextColor(actualDrawProp[_selectedLayer].TextColor); 00097 } 00098 00099 00100 void RK043FN48H::SetDrawColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) 00101 { 00102 // Calculate display pixel value for selected color 00103 uint32_t color = red << 16 | green << 8 | blue | alpha << 24; 00104 SetForegroundColor(color); 00105 } 00106 00107 uint32_t RK043FN48H::GetDrawColor() 00108 { 00109 return actualDrawProp[_selectedLayer].TextColor; 00110 } 00111 00112 00113 void RK043FN48H::DrawPoint(int posX, int posY, uint32_t colorMask) 00114 { 00115 if( posX >= 0 && posX < DisplayWidth() && posY >=0 && posY < DisplayHeight()) { 00116 BSP_LCD_DrawPixel(posX, posY, colorMask); 00117 } 00118 } 00119 00120 00121 //void RK043FN48H::DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) 00122 //{ 00123 // BSP_LCD_DrawLine(x1, y1, x2, y2); 00124 //} 00125 00126 00127 void RK043FN48H::CopyBitmap(Layer layer, uint8_t * bitmap, uint32_t width, uint32_t height, uint32_t rgbGolorCode) 00128 { 00129 // Check size 00130 if(width > DisplayWidth() || height > DisplayHeight()) 00131 return; 00132 00133 ClearLayer(layer, 0x00000000); 00134 00135 uint16_t maxCol = width / 8; // 60 columns 00136 if ((width % 8) != 0) 00137 { 00138 maxCol++; 00139 } 00140 00141 for (int y = 0; y < height; y++) { 00142 for (int col = 0; col < maxCol; col++) { 00143 uint8_t shift = bitmap[y*maxCol + col]; 00144 for (int pos = 0; pos < 8; pos++) { 00145 int x = (col << 3) + pos; // x = col * 8 + pos 00146 if (x >= width) 00147 break; 00148 00149 if(shift & 1 << pos) 00150 { 00151 DrawPoint(x, y, rgbGolorCode); 00152 } 00153 } 00154 } 00155 } 00156 } 00157 00158 00159 uint16_t RK043FN48H::DisplayWidth() 00160 { 00161 return BSP_LCD_GetXSize(); 00162 } 00163 00164 00165 uint16_t RK043FN48H::DisplayHeight() 00166 { 00167 return BSP_LCD_GetYSize(); 00168 } 00169 00170 00171 void RK043FN48H::SetActiveLayer(Layer layer) 00172 { 00173 _selectedLayer = layer; 00174 00175 BSP_LCD_SelectLayer((uint32_t)layer); 00176 } 00177 00178 00179 Layer RK043FN48H::GetActiveLayer() 00180 { 00181 return _selectedLayer; 00182 } 00183 00184 00185 void RK043FN48H::SetLayersTransparency( uint8_t background, uint8_t foreground) 00186 { 00187 BSP_LCD_SetTransparency(0, background); 00188 BSP_LCD_SetTransparency(1, foreground); 00189 } 00190 00191 00192 void RK043FN48H::SetLayersVisibility( bool background, bool foreground) 00193 { 00194 BSP_LCD_SetLayerVisible(0, background ? ENABLE : DISABLE); 00195 BSP_LCD_SetLayerVisible(1, foreground ? ENABLE : DISABLE); 00196 } 00197 00198 00199 00200 //New Function 00201 //Add date: 25/08/2019 00202 00203 void RK043FN48H::DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) 00204 { 00205 BSP_LCD_DrawHLine(Xpos, Ypos, Length); 00206 } 00207 00208 void RK043FN48H::DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) 00209 { 00210 BSP_LCD_DrawVLine(Xpos, Ypos, Length); 00211 } 00212 00213 void RK043FN48H::DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) 00214 { 00215 BSP_LCD_DrawLine(x1, y1, x2, y2); 00216 } 00217 00218 void RK043FN48H::DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) 00219 { 00220 BSP_LCD_DrawRect(Xpos, Ypos, Width, Height); 00221 } 00222 00223 void RK043FN48H::DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) 00224 { 00225 BSP_LCD_DrawCircle(Xpos, Ypos, Radius); 00226 } 00227 00228 void RK043FN48H::DrawPolygon(pPoint Points, uint16_t PointCount) 00229 { 00230 BSP_LCD_DrawPolygon(Points, PointCount); 00231 } 00232 00233 void RK043FN48H::DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius) 00234 { 00235 BSP_LCD_DrawEllipse(Xpos, Ypos, XRadius, YRadius); 00236 } 00237 00238 void RK043FN48H::DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp) 00239 { 00240 BSP_LCD_DrawBitmap(Xpos, Ypos, pbmp); 00241 } 00242 00243 void RK043FN48H::FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) 00244 { 00245 BSP_LCD_FillRect(Xpos, Ypos, Width, Height); 00246 } 00247 00248 void RK043FN48H::FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) 00249 { 00250 BSP_LCD_FillCircle(Xpos, Ypos, Radius); 00251 } 00252 00253 void RK043FN48H::FillPolygon(pPoint Points, uint16_t PointCount) 00254 { 00255 BSP_LCD_FillPolygon(Points, PointCount); 00256 } 00257 00258 void RK043FN48H::FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius) 00259 { 00260 BSP_LCD_FillEllipse(Xpos, Ypos, XRadius, YRadius); 00261 } 00262 00263 void RK043FN48H::SetTextColor(uint32_t Color) 00264 { 00265 BSP_LCD_SetTextColor(Color); 00266 } 00267 00268 uint32_t RK043FN48H::GetTextColor(void) 00269 { 00270 return BSP_LCD_GetTextColor(); 00271 } 00272 00273 void RK043FN48H::SetBackColor(uint32_t Color) 00274 { 00275 BSP_LCD_SetBackColor(Color); 00276 } 00277 00278 uint32_t RK043FN48H::GetBackColor(void) 00279 { 00280 return BSP_LCD_GetBackColor(); 00281 } 00282 00283 void RK043FN48H::SetFont(sFONT *fonts) 00284 { 00285 BSP_LCD_SetFont(fonts); 00286 } 00287 00288 sFONT *RK043FN48H::GetFont(void) 00289 { 00290 return BSP_LCD_GetFont(); 00291 } 00292 00293 uint32_t RK043FN48H::ReadPixel(uint16_t Xpos, uint16_t Ypos) 00294 { 00295 return BSP_LCD_ReadPixel(Xpos, Ypos); 00296 } 00297 00298 void RK043FN48H::DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t pixel) 00299 { 00300 BSP_LCD_DrawPixel(Xpos, Ypos, pixel); 00301 } 00302 00303 00304 void RK043FN48H::ClearStringLine(uint32_t Line) 00305 { 00306 BSP_LCD_ClearStringLine(Line); 00307 } 00308 00309 void RK043FN48H::DisplayStringAtLine(uint16_t Line, uint8_t *ptr) 00310 { 00311 BSP_LCD_DisplayStringAtLine(Line, ptr); 00312 } 00313 00314 void RK043FN48H::DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode) 00315 { 00316 BSP_LCD_DisplayStringAt(Xpos, Ypos, Text, Mode); 00317 } 00318 00319 void RK043FN48H::DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) 00320 { 00321 BSP_LCD_DisplayChar(Xpos, Ypos, Ascii); 00322 } 00323
Generated on Sat Jul 23 2022 05:49:00 by
1.7.2