Vladimir N. Shilov il y a 1 an
Parent
commit
c374175d81
2 fichiers modifiés avec 23 ajouts et 16 suppressions
  1. 4 4
      board/board.h
  2. 19 12
      main.c

+ 4 - 4
board/board.h

@@ -59,10 +59,10 @@
 #define LINE_RAZGON_OFF	  PAL_LINE(GPIOA, 3U)
 
 /* Buttons */
-#define LINE_BTN_4	  PAL_LINE(GPIOA, 8U)
-#define LINE_BTN_3    PAL_LINE(GPIOB, 15U)
-#define LINE_BTN_2    PAL_LINE(GPIOB, 14U)
-#define LINE_BTN_1    PAL_LINE(GPIOB, 13U)
+#define LINE_BTN_3	  PAL_LINE(GPIOA, 8U)
+#define LINE_BTN_4    PAL_LINE(GPIOB, 15U)
+#define LINE_BTN_1    PAL_LINE(GPIOB, 14U)
+#define LINE_BTN_2    PAL_LINE(GPIOB, 13U)
 #define LINE_BTN_G    PAL_LINE(GPIOB, 12U)
 
 #define BTNS_ON			  palClearLine(LINE_BTN_G)

+ 19 - 12
main.c

@@ -70,11 +70,18 @@ int main(void) {
    */
   chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
 
+  /*
+   * Buttons
+   */
+  buttons_Init(bha);
+  BTNS_ON;
+
   /*
    * LCD
    */
   ST7735_Init();
   lcd_MainScreen();
+  chThdSleepMilliseconds(2000);
   lcd_ClearMain();
 
   /*
@@ -99,17 +106,17 @@ int main(void) {
 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);
+  ST7735_WriteString(47, 38, "Heater", Font_11x18, Yellow, Black);
+  ST7735_WriteString(52, 58, "Power", Font_11x18, Yellow, Black);
+  ST7735_WriteString(25, 78, "Stabilizer", Font_11x18, Yellow, Black);
+  chThdSleepMilliseconds(1000);
 
   /* top info line */
-  ST7735_FillRectangle(0, 18, ST7735_WIDTH, 1, White);
-  ST7735_FillRectangle( 119, 0, 1, 18, White); // separator
+  ST7735_FillRectangle(0, 19, ST7735_WIDTH, 1, White);
+  ST7735_FillRectangle( 79, 0, 1, 19, White); // separator
 
-  ST7735_WriteString(0, 0, "Line V", Font_11x18, Red, Black);
-  ST7735_WriteString(120, 0, "Heater W", Font_11x18, Red, Black);
+  ST7735_WriteString(0, 0, " .... V", Font_11x18, Red, Black);
+  ST7735_WriteString(80, 0, " .... W", Font_11x18, Red, Black);
 
   /* bottom status line */
   ST7735_FillRectangle(0, 117, ST7735_WIDTH, 1, White);
@@ -127,7 +134,7 @@ static void lcd_ClearMain(void) {
   ST7735_FillRectangle(0, 20, ST7735_WIDTH, 97, Black);
 }
 
-static void btn1_handler(const button_state_t) {
+static void btn1_handler(const button_state_t state) {
   if (state == BTN_st_Pressed) {
     ST7735_WriteString(0, 118, "  +  ", LiberM_7x10, Black, Grey);
     chThdSleepMilliseconds(500);
@@ -135,7 +142,7 @@ static void btn1_handler(const button_state_t) {
   }
 }
 
-static void btn2_handler(const button_state_t) {
+static void btn2_handler(const button_state_t state) {
   if (state == BTN_st_Pressed) {
     ST7735_WriteString(40, 118, "  -  ", LiberM_7x10, Black, Grey);
     chThdSleepMilliseconds(500);
@@ -143,7 +150,7 @@ static void btn2_handler(const button_state_t) {
   }
 }
 
-static void btn3_handler(const button_state_t) {
+static void btn3_handler(const button_state_t state) {
   if (state == BTN_st_Pressed) {
     ST7735_WriteString(80, 118, "  R  ", LiberM_7x10, Black, Grey);
     chThdSleepMilliseconds(500);
@@ -151,7 +158,7 @@ static void btn3_handler(const button_state_t) {
   }
 }
 
-static void btn4_handler(const button_state_t) {
+static void btn4_handler(const button_state_t state) {
   if (state == BTN_st_Pressed) {
     ST7735_WriteString(120, 118, "  S  ", LiberM_7x10, Black, Grey);
     chThdSleepMilliseconds(500);