|
@@ -127,9 +127,9 @@ int main(void) {
|
|
static void lcd_MainScreen(void) {
|
|
static void lcd_MainScreen(void) {
|
|
ST7735_FillScreen(Black);
|
|
ST7735_FillScreen(Black);
|
|
|
|
|
|
- ST7735_WriteString(47, LCD_LINE_2, "Heater", Font_11x18, Yellow, Black);
|
|
|
|
- ST7735_WriteString(52, LCD_LINE_4, "Power", Font_11x18, Yellow, Black);
|
|
|
|
- ST7735_WriteString(25, LCD_LINE_6, "Stabilizer", Font_11x18, Yellow, Black);
|
|
|
|
|
|
+ ST7735_WriteString(X_centered(6, 11), LCD_LINE_2, "Heater", Font_11x18, Yellow, Black);
|
|
|
|
+ ST7735_WriteString(X_centered(5, 11), LCD_LINE_4, "Power", Font_11x18, Yellow, Black);
|
|
|
|
+ ST7735_WriteString(X_centered(10, 11), LCD_LINE_6, "Stabilizer", Font_11x18, Yellow, Black);
|
|
chThdSleepMilliseconds(1000);
|
|
chThdSleepMilliseconds(1000);
|
|
|
|
|
|
/* top info line */
|
|
/* top info line */
|
|
@@ -186,3 +186,19 @@ static void btn4_handler(const button_state_t state) {
|
|
ST7735_WriteString(120, 118, " S ", LiberM_7x10, Silver, Black);
|
|
ST7735_WriteString(120, 118, " S ", LiberM_7x10, Silver, Black);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @brief The function returns the starting X position for text of len characters long,
|
|
|
|
+ * to place it in the center of the display.
|
|
|
|
+ * @param len Number of characters in the text,
|
|
|
|
+ * @param pix Font width in pixels,
|
|
|
|
+ */
|
|
|
|
+static uint8_t X_centered(const uint8_t len, const uint8_t pix) {
|
|
|
|
+ unsigned wdt = ST7735_WIDTH;
|
|
|
|
+ unsigned pl = len * pix;
|
|
|
|
+ if (pl > wdt) {
|
|
|
|
+ return 0;
|
|
|
|
+ } else {
|
|
|
|
+ return (uint8_t)((wdt - pl) / 2);
|
|
|
|
+ }
|
|
|
|
+}
|