WIP
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "display.h"
|
||||
#include "font.h"
|
||||
#include "roboto_bold_font.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -89,6 +88,64 @@ void StartDefaultTask(void const * argument);
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/**
|
||||
* @brief Convert a single digit (0-9) to its ASCII character
|
||||
* @param digit: The digit to convert (0-9)
|
||||
* @retval ASCII character '0' through '9'
|
||||
*/
|
||||
static char digit_to_ascii(uint8_t digit)
|
||||
{
|
||||
return (char)('0' + digit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert an unsigned 32-bit integer to a null-terminated string
|
||||
* @param value: The number to convert
|
||||
* @param buffer: Pointer to the output buffer
|
||||
* @param buffer_size: Size of the buffer
|
||||
* @retval None
|
||||
*/
|
||||
static void uint32_to_string(uint32_t value, uint8_t *buffer, uint8_t buffer_size)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
uint8_t digits[10]; // Maximum 10 digits for uint32_t
|
||||
uint8_t digit_count = 0;
|
||||
|
||||
// Handle zero case
|
||||
if (value == 0)
|
||||
{
|
||||
if (buffer_size > 0)
|
||||
{
|
||||
buffer[0] = '0';
|
||||
buffer[1] = '\0';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract digits from right to left
|
||||
while (value > 0 && digit_count < 10)
|
||||
{
|
||||
digits[digit_count] = (uint8_t)(value % 10);
|
||||
value /= 10;
|
||||
digit_count++;
|
||||
}
|
||||
|
||||
// Convert digits to ASCII and store in buffer (reversed)
|
||||
for (i = 0; i < digit_count && i < (buffer_size - 1); i++)
|
||||
{
|
||||
buffer[i] = digit_to_ascii(digits[digit_count - 1 - i]);
|
||||
}
|
||||
|
||||
// Null terminate
|
||||
if (i < buffer_size)
|
||||
{
|
||||
buffer[i] = '\0';
|
||||
}
|
||||
else if (buffer_size > 0)
|
||||
{
|
||||
buffer[buffer_size - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void LCD_Write_Cmd(uint8_t cmd)
|
||||
{
|
||||
@@ -862,16 +919,23 @@ void StartDefaultTask(void const * argument)
|
||||
times_changed = 0;
|
||||
ILI9341_Init();
|
||||
|
||||
uint8_t time_string[20] = {0};
|
||||
DisplayTest(0xFFFF);
|
||||
|
||||
draw_string(framebuffer, &roboto_bold_font, 10, 75, "Number of beans:", 0x0000);
|
||||
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
DisplayTest(0xffff);
|
||||
draw_string(framebuffer, &roboto_bold_font, 25, 25, "Divide Voltage!", 0x0000);
|
||||
osDelay(500);
|
||||
DisplayTest(0x0000);
|
||||
draw_string(framebuffer, &roboto_bold_font, 25, 25, "Divide Voltage!", 0xf800);
|
||||
osDelay(500);
|
||||
uint32_t t = HAL_GetTick() / 100;
|
||||
// Convert milliseconds to string
|
||||
uint32_to_string(t, time_string, sizeof(time_string));
|
||||
DrawBox(25, 0, 40, 80, 0xffff);
|
||||
draw_string(framebuffer, &roboto_bold_font, 25, 25, time_string, 0x0000);
|
||||
DrawBox(25, 100, 40, 150, 0xffff);
|
||||
draw_string(framebuffer, &roboto_bold_large_font, 25, 125, time_string, 0x001f);
|
||||
|
||||
osDelay(100);
|
||||
}
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user