@@ -180,10 +180,12 @@ void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center)
180180 }
181181}
182182
183- void UI_DrawPixel ( uint8_t x , uint8_t y , bool black )
183+ void UI_DrawPixelBuffer ( uint8_t ( * buffer )[ 128 ], uint8_t x , uint8_t y , bool black )
184184{
185- gFrameBuffer [y /8 ][x ] &= ~(1 << (y %8 ));
186- gFrameBuffer [y /8 ][x ] |= black << (y %8 );
185+ if (black )
186+ buffer [y /8 ][x ] |= 1 << (y %8 );
187+ else
188+ buffer [y /8 ][x ] &= ~(1 << (y %8 ));
187189}
188190
189191static void sort (int16_t * a , int16_t * b )
@@ -195,12 +197,12 @@ static void sort(int16_t *a, int16_t *b)
195197 }
196198}
197199
198- void UI_DrawLine ( int16_t x1 , int16_t y1 , int16_t x2 , int16_t y2 , bool black )
200+ void UI_DrawLineBuffer ( uint8_t ( * buffer )[ 128 ], int16_t x1 , int16_t y1 , int16_t x2 , int16_t y2 , bool black )
199201{
200202 if (x2 == x1 ) {
201203 sort (& y1 , & y2 );
202204 for (int16_t i = y1 ; i <= y2 ; i ++ ) {
203- UI_DrawPixel ( x1 , i , black );
205+ UI_DrawPixelBuffer ( buffer , x1 , i , black );
204206 }
205207 } else {
206208 const int multipl = 1000 ;
@@ -210,17 +212,17 @@ void UI_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
210212 sort (& x1 , & x2 );
211213 for (int i = x1 ; i <= x2 ; i ++ )
212214 {
213- UI_DrawPixel ( i , i * a /multipl + b , black );
215+ UI_DrawPixelBuffer ( buffer , i , i * a /multipl + b , black );
214216 }
215217 }
216218}
217219
218- void UI_DrawRectangle ( int16_t x1 , int16_t y1 , int16_t x2 , int16_t y2 , bool black )
220+ void UI_DrawRectangleBuffer ( uint8_t ( * buffer )[ 128 ], int16_t x1 , int16_t y1 , int16_t x2 , int16_t y2 , bool black )
219221{
220- UI_DrawLine ( x1 ,y1 , x1 ,y2 , black );
221- UI_DrawLine ( x1 ,y1 , x2 ,y1 , black );
222- UI_DrawLine ( x2 ,y1 , x2 ,y2 , black );
223- UI_DrawLine ( x1 ,y2 , x2 ,y2 , black );
222+ UI_DrawLineBuffer ( buffer , x1 ,y1 , x1 ,y2 , black );
223+ UI_DrawLineBuffer ( buffer , x1 ,y1 , x2 ,y1 , black );
224+ UI_DrawLineBuffer ( buffer , x2 ,y1 , x2 ,y2 , black );
225+ UI_DrawLineBuffer ( buffer , x1 ,y2 , x2 ,y2 , black );
224226}
225227
226228void UI_DisplayPopup (const char * string )
@@ -234,13 +236,13 @@ void UI_DisplayPopup(const char *string)
234236 // }
235237
236238 // for(uint8_t x = 10; x < 118; x++) {
237- // UI_DrawPixel (x, 10, true);
238- // UI_DrawPixel (x, 46-9, true);
239+ // UI_DrawPixelBuffer (x, 10, true);
240+ // UI_DrawPixelBuffer (x, 46-9, true);
239241 // }
240242
241243 // for(uint8_t y = 11; y < 37; y++) {
242- // UI_DrawPixel (10, y, true);
243- // UI_DrawPixel (117, y, true);
244+ // UI_DrawPixelBuffer (10, y, true);
245+ // UI_DrawPixelBuffer (117, y, true);
244246 // }
245247 // DrawRectangle(9,9, 118,38, true);
246248 UI_PrintString (string , 9 , 118 , 2 , 8 );
0 commit comments