|
@@ -22,24 +22,9 @@
|
|
|
|
|
|
#include "chprintf.h"
|
|
#include "chprintf.h"
|
|
|
|
|
|
|
|
+#include "main.h"
|
|
#include "st7735.h"
|
|
#include "st7735.h"
|
|
|
|
|
|
-/* Private variables */
|
|
|
|
-
|
|
|
|
-/*
|
|
|
|
- * SPI configuration structure.
|
|
|
|
- * Speed 12 MHz, CPHA=0, CPOL=0, 8bits frames, MSb transmitted first.
|
|
|
|
- * Soft slave select.
|
|
|
|
- */
|
|
|
|
-static const SPIConfig spi1cfg = {
|
|
|
|
- .circular = false,
|
|
|
|
- .slave = false,
|
|
|
|
- .data_cb = NULL,
|
|
|
|
- .error_cb = NULL,
|
|
|
|
- .cr1 = 0U,
|
|
|
|
- .cr2 = 0U
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
/*===========================================================================*/
|
|
/*===========================================================================*/
|
|
/* Generic code. */
|
|
/* Generic code. */
|
|
/*===========================================================================*/
|
|
/*===========================================================================*/
|
|
@@ -89,10 +74,8 @@ int main(void) {
|
|
* LCD
|
|
* LCD
|
|
*/
|
|
*/
|
|
ST7735_Init();
|
|
ST7735_Init();
|
|
- // draw tests
|
|
|
|
- ST7735_FillScreen(Black);
|
|
|
|
- ST7735_FillRectangle(ST7735_XSTART, ST7735_HEIGHT/2, ST7735_WIDTH, 1, Green);
|
|
|
|
- ST7735_FillRectangle(ST7735_WIDTH/2, ST7735_YSTART, 1, ST7735_HEIGHT, Yellow);
|
|
|
|
|
|
+ lcd_MainScreen();
|
|
|
|
+ lcd_ClearMain();
|
|
|
|
|
|
/*
|
|
/*
|
|
* Normal main() thread activity.
|
|
* Normal main() thread activity.
|
|
@@ -101,3 +84,77 @@ int main(void) {
|
|
chThdSleepMilliseconds(500);
|
|
chThdSleepMilliseconds(500);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Private functions
|
|
|
|
+ */
|
|
|
|
+/* numbers for screen 160x128
|
|
|
|
+ * btn1 - 118, 1..38-FontWidh
|
|
|
|
+ * btn2 - 118, 40..78-FontWidh
|
|
|
|
+ * btn3 - 118, 80..118-FontWidh
|
|
|
|
+ * btn4 - 118, 120..158-FontWidh
|
|
|
|
+ *
|
|
|
|
+ * main screen 0,20 .. 159,117
|
|
|
|
+ */
|
|
|
|
+static void lcd_MainScreen(void) {
|
|
|
|
+ ST7735_FillScreen(Black);
|
|
|
|
+
|
|
|
|
+ ST7735_WriteString(47, 48, "Heater", Font_11x18, Yellow, Black);
|
|
|
|
+ ST7735_WriteString(52, 68, "Power", Font_11x18, Yellow, Black);
|
|
|
|
+ ST7735_WriteString(25, 88, "Stabilizer", Font_11x18, Yellow, Black);
|
|
|
|
+ chThdSleepMilliseconds(2000);
|
|
|
|
+
|
|
|
|
+ /* top info line */
|
|
|
|
+ ST7735_FillRectangle(0, 18, ST7735_WIDTH, 1, White);
|
|
|
|
+ ST7735_FillRectangle( 119, 0, 1, 18, White); // separator
|
|
|
|
+
|
|
|
|
+ ST7735_WriteString(0, 0, "Line V", Font_11x18, Red, Black);
|
|
|
|
+ ST7735_WriteString(120, 0, "Heater W", Font_11x18, Red, Black);
|
|
|
|
+
|
|
|
|
+ /* bottom status line */
|
|
|
|
+ ST7735_FillRectangle(0, 117, ST7735_WIDTH, 1, White);
|
|
|
|
+ ST7735_FillRectangle( 39, 117, 1, 11, White); // separator btn1/btn2
|
|
|
|
+ ST7735_FillRectangle( 79, 117, 1, 11, White); // separator btn2/btn3
|
|
|
|
+ ST7735_FillRectangle(119, 117, 1, 11, White); // separator btn3/btn4
|
|
|
|
+
|
|
|
|
+ ST7735_WriteString(0, 118, " + ", LiberM_7x10, Silver, Black);
|
|
|
|
+ ST7735_WriteString(40, 118, " - ", LiberM_7x10, Silver, Black);
|
|
|
|
+ ST7735_WriteString(80, 118, " R ", LiberM_7x10, Silver, Black);
|
|
|
|
+ ST7735_WriteString(120, 118, " S ", LiberM_7x10, Silver, Black);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void lcd_ClearMain(void) {
|
|
|
|
+ ST7735_FillRectangle(0, 20, ST7735_WIDTH, 97, Black);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void btn1_handler(const button_state_t) {
|
|
|
|
+ if (state == BTN_st_Pressed) {
|
|
|
|
+ ST7735_WriteString(0, 118, " + ", LiberM_7x10, Black, Grey);
|
|
|
|
+ chThdSleepMilliseconds(500);
|
|
|
|
+ ST7735_WriteString(0, 118, " + ", LiberM_7x10, Silver, Black);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void btn2_handler(const button_state_t) {
|
|
|
|
+ if (state == BTN_st_Pressed) {
|
|
|
|
+ ST7735_WriteString(40, 118, " - ", LiberM_7x10, Black, Grey);
|
|
|
|
+ chThdSleepMilliseconds(500);
|
|
|
|
+ ST7735_WriteString(40, 118, " - ", LiberM_7x10, Silver, Black);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void btn3_handler(const button_state_t) {
|
|
|
|
+ if (state == BTN_st_Pressed) {
|
|
|
|
+ ST7735_WriteString(80, 118, " R ", LiberM_7x10, Black, Grey);
|
|
|
|
+ chThdSleepMilliseconds(500);
|
|
|
|
+ ST7735_WriteString(80, 118, " R ", LiberM_7x10, Silver, Black);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void btn4_handler(const button_state_t) {
|
|
|
|
+ if (state == BTN_st_Pressed) {
|
|
|
|
+ ST7735_WriteString(120, 118, " S ", LiberM_7x10, Black, Grey);
|
|
|
|
+ chThdSleepMilliseconds(500);
|
|
|
|
+ ST7735_WriteString(120, 118, " S ", LiberM_7x10, Silver, Black);
|
|
|
|
+ }
|
|
|
|
+}
|