Add lcd_stop_all_gifs(void)
This commit is contained in:
@@ -229,6 +229,13 @@ Call this function before drawing over the GIF.
|
||||
This function should not be called on a GIF that has already been stopped (GIFs with a loop count will stop automatically).
|
||||
It is possible that the handler has been assigned to a new GIF, so it would stop the new GIF instead.
|
||||
|
||||
#### Stopping all GIF animations
|
||||
```c
|
||||
void lcd_stop_all_gifs(void);
|
||||
```
|
||||
This function stops all the GIF animations and frees the memory allocated for the GIF.
|
||||
Call this function before drawing over the GIF.
|
||||
|
||||
#### Checking if a GIF is still running
|
||||
```c
|
||||
bool lcd_gif_is_playing(lcd_gif_t* gif);
|
||||
|
||||
@@ -102,7 +102,7 @@ void lcd_task(void);
|
||||
* @param[in] color Color in which the text will be displayed, see preset colors in defines above
|
||||
* @param[in] font Font size, see defines above in file
|
||||
*/
|
||||
void lcd_display_text(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, sFONT *font);
|
||||
void lcd_display_text(const char* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, sFONT *font);
|
||||
|
||||
/**
|
||||
* @brief Draw BMP image on screen
|
||||
@@ -158,6 +158,14 @@ void lcd_clear_text(void);
|
||||
|
||||
void lcd_clear_images(void);
|
||||
|
||||
/**
|
||||
* @brief LCD stop all GIFs
|
||||
* Stops all playing GIFs on lcd screen
|
||||
*
|
||||
*/
|
||||
|
||||
void lcd_stop_all_gifs(void);
|
||||
|
||||
/**
|
||||
* @brief Draw GIF image on screen from memory
|
||||
* Draw GIF image from memory to the LCD screen at position X, Y
|
||||
|
||||
@@ -82,11 +82,11 @@ void lcd_task(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_display_text(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, sFONT* font) {
|
||||
void lcd_display_text(const char* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, sFONT* font) {
|
||||
BSP_LCD_SelectLayer(1);
|
||||
LOG_INFO(TAG, "Display text: %s @x=%d,y=%d", text, x_pos, y_pos);
|
||||
|
||||
uint16_t tot_length = x_pos + (strlen(text) * font->Width);
|
||||
uint16_t tot_length = x_pos + ((uint16_t)strlen(text) * font->Width);
|
||||
if ((x_pos % font->Width) != 0) {
|
||||
x_pos -= (x_pos % font->Width);
|
||||
}
|
||||
@@ -96,23 +96,23 @@ void lcd_display_text(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t co
|
||||
BSP_LCD_SetFont(font);
|
||||
|
||||
if (tot_length > BSP_LCD_GetXSize()) {
|
||||
for (int i = 0; i < strlen(text); i++) {
|
||||
for (unsigned int i = 0; i < (unsigned int)strlen(text); i++) {
|
||||
if ((x_pos) > BSP_LCD_GetXSize() - (font->Width) * 2) {
|
||||
if (isalpha(text[i - 1]) && isalpha(text[i])) {
|
||||
BSP_LCD_DisplayChar(x_pos, y_pos, '-');
|
||||
BSP_LCD_DisplayChar(x_pos, y_pos, (uint8_t)'-');
|
||||
} else {
|
||||
BSP_LCD_DisplayChar(x_pos, y_pos, text[i]);
|
||||
BSP_LCD_DisplayChar(x_pos, y_pos, (uint8_t)text[i]);
|
||||
}
|
||||
x_pos = 0;
|
||||
y_pos += font->Height;
|
||||
continue;
|
||||
}
|
||||
BSP_LCD_DisplayChar(x_pos, y_pos, text[i]);
|
||||
BSP_LCD_DisplayChar(x_pos, y_pos, (uint8_t)text[i]);
|
||||
x_pos += font->Width;
|
||||
}
|
||||
return;
|
||||
}
|
||||
BSP_LCD_DisplayStringAt(x_pos, y_pos, text, LEFT_MODE);
|
||||
BSP_LCD_DisplayStringAt(x_pos, y_pos, (uint8_t*)text, LEFT_MODE);
|
||||
}
|
||||
|
||||
void lcd_draw_raw_img(const void* p_src, uint32_t x_pos, uint32_t y_pos, uint32_t x_size, uint32_t y_size, uint32_t color_mode) {
|
||||
@@ -179,6 +179,14 @@ void lcd_clear_images(void) {
|
||||
BSP_LCD_Clear(0);
|
||||
}
|
||||
|
||||
void lcd_stop_all_gifs(void) {
|
||||
for (uint8_t i = 0; i < LCD_MAX_GIFS; i++) {
|
||||
if (gifs[i].src != NULL) {
|
||||
lcd_stop_gif(&gifs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lcd_gif_t* lcd_draw_gif(uint8_t* src, size_t size, uint32_t x_pos, uint32_t y_pos) {
|
||||
BSP_LCD_SelectLayer(0);
|
||||
lcd_gif_t* gif;
|
||||
|
||||
Reference in New Issue
Block a user