update some pins & add RE5 blinking if scheduler is enabled

master
Ondřej Hruška 10 months ago
parent f2af71ef7f
commit 88c215393b
  1. 4
      src/main.c
  2. 27
      src/pinout.h
  3. 23
      src/screens/app_gui.c

@ -80,6 +80,8 @@ int __attribute__((noreturn)) main()
bi_decl(bi_1pin_with_name(PIN_RE2, "RE2"));
bi_decl(bi_1pin_with_name(PIN_RE3, "RE3"));
bi_decl(bi_1pin_with_name(PIN_RE4, "RE4"));
bi_decl(bi_1pin_with_name(PIN_RE5, "RE5"));
bi_decl(bi_1pin_with_name(PIN_RE6, "RE6"));
bi_decl(bi_1pin_with_name(PIN_LCD_RS, "LCD RS"));
bi_decl(bi_1pin_with_name(PIN_LCD_E, "LCD CLK"));
bi_decl(bi_1pin_with_name(PIN_LCD_D7, "LCD D7"));
@ -103,6 +105,8 @@ int __attribute__((noreturn)) main()
setup_output(PIN_RE2);
setup_output(PIN_RE3);
setup_output(PIN_RE4);
setup_output(PIN_RE5);
setup_output(PIN_RE6);
/* LCD */
setup_output(PIN_LCD_RS);

@ -6,20 +6,25 @@
#define ZAVLAHA_PINOUT_H
#define PIN_LED PICO_DEFAULT_LED_PIN // 25
#define PIN_RE1 5
#define PIN_RE2 4
#define PIN_RE3 22
#define PIN_RE4 26
#define PIN_RE1 18
#define PIN_RE2 19
#define PIN_RE3 20
#define PIN_RE4 21
#define PIN_RE5 22
#define PIN_RE6 26
#define PIN_MOISTURE 28
#define ADC_NUM_MOISTURE 2 // ADC2
#define PIN_I2C_SDA 16
#define PIN_I2C_SCL 17
#define PIN_LCD_RS 14
#define PIN_LCD_RW 6
#define PIN_LCD_E 15
#define PIN_LCD_D7 21
#define PIN_LCD_D6 20
#define PIN_LCD_D5 19
#define PIN_LCD_D4 18
#define PIN_LCD_RS 6
#define PIN_LCD_RW 7
#define PIN_LCD_E 8
#define PIN_LCD_D4 9
#define PIN_LCD_D5 10
#define PIN_LCD_D6 11
#define PIN_LCD_D7 12
#endif //ZAVLAHA_PINOUT_H

@ -4,11 +4,13 @@
#include <stdbool.h>
#include <string.h>
#include <hardware/gpio.h>
#include "app_gui.h"
#include "lcd/lcdbuf.h"
#include "lcd.h"
#include "app_config.h"
#include "app_io.h"
#include "pinout.h"
struct State s_app = {};
@ -45,6 +47,8 @@ void gui_init()
LcdBuffer_Init(&lcd, CGROM_A00, CGRAM_CZ);
}
static bool blink_state = 0;
void gui_loop_iter(GuiEvent message)
{
uint32_t tickNow = timestamp_ms();
@ -95,6 +99,25 @@ void gui_loop_iter(GuiEvent message)
s_app.screen(GUI_EVENT_SCREEN_TICK_1S);
read_time_and_moisture();
s_app.last_1s_time = tickNow;
// blinking
blink_state = !blink_state;
gpio_put(PIN_LED, blink_state);
// also blink with the relay pin, so we can route that to a indicator light in the lid
// ->
// check if we have schedule enabled & set
bool any_sch = false;
if (app_config.scheduler_enable) {
for (int i = 0; i < SCHEDULE_COUNT; i++) {
if (!app_config.schedules[i].enable) {
continue;
}
any_sch = true;
break;
}
}
gpio_put(PIN_RE5, any_sch && blink_state);
}
// 100ms tick event

Loading…
Cancel
Save