From 02dfa1385e25875659eec20313b8914ccbf60954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gassmann?= Date: Fri, 11 Oct 2024 02:18:54 +0200 Subject: [+] Button module with long / short press and release detection --- main/Kconfig.projbuild | 16 ++++++---------- main/main.c | 22 ++++++++++++++++++---- 2 files changed, 24 insertions(+), 14 deletions(-) (limited to 'main') diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 4ff3093..85eb1ee 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -144,6 +144,12 @@ menu "Configuration of the Nixie Screen" default 3 help Pin number for N3_P3. + + config BUTTON_PIN + int "Pin number for the button" + default 9 + help + Pin number for the button. config ESP_DPP_LISTEN_CHANNEL_LIST string "DPP Listen channel list" @@ -166,14 +172,4 @@ menu "Configuration of the Nixie Screen" default "pool.ntp.org" help Hostname of the main SNTP server. - - choice SNTP_TIME_SYNC_METHOD - prompt "Time synchronization method" - default SNTP_TIME_SYNC_METHOD_IMMED - help - Time synchronization method. - - config SNTP_TIME_SYNC_METHOD_IMMED - bool "update time immediately when received" - endchoice endmenu \ No newline at end of file diff --git a/main/main.c b/main/main.c index 81a51b1..16e1ca6 100644 --- a/main/main.c +++ b/main/main.c @@ -1,11 +1,13 @@ -#include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" #include "screen.h" #include "dpp_wifi.h" #include "time_sntp.h" +#include "button_handler.h" +struct Button* button; struct Screen screen; char t[4]; @@ -25,26 +27,38 @@ void setup_nvs() ESP_ERROR_CHECK(ret); } + void app_main(void) { + printf("Starting up...\n"); + configure_screen(&screen); display(&screen, "aaaa"); printf("Screen Configured!\n"); + setup_nvs(); display(&screen, "0aaa"); printf("NVS Flash Configured!\n"); - launch_dpp(); + + button = (struct Button*)malloc(sizeof(struct Button)); + button->time = 0; + setup_button(button); display(&screen, "00aa"); + printf("User Inputs Configured!\n"); + + launch_dpp(); + display(&screen, "000a"); printf("WiFi Configured!\n"); + set_tz("CET-1CEST,M3.5.0/2,M10.5.0/2"); - display(&screen, "000a"); sync_time(); display(&screen, "0000"); printf("SNTP Configured!\n"); + while(1){ refresh_screen(); - sleep(2); + vTaskDelay(2000 / portTICK_PERIOD_MS); } } \ No newline at end of file -- cgit v1.2.3