ESP-Miner/main/tasks/user_input_task.c
Benjamin Wilson 199c151c0f
Http-server (#17)
* rename miner to main

* serving out of storage

* axe os

* http server work

* basic stats showing

* update sdkconfig

* SDKCONFIG

* sdk config

* edit page init

* edit pool config

* pool config edit working

* OTA Success

* remove compiled output

* toggle AP mode with boot button

* favicon

* ota website update

* add sdkconfig.ci back

* update readme

* change website build to warning

* Update github workflow to build web dist

* Allow AP mode before STA connection complete

* spacing for johnny :)

* formatting

* Improve connecting to wifi with AP mode

* added working indicator for UI

* formatting

* formatting

* remove redundant sdkconfig in CMakeLists

* vs code format on save workspace settings

---------

Co-authored-by: johnny9 <985648+johnny9@users.noreply.github.com>
2023-08-26 12:21:41 -04:00

27 lines
857 B
C

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "connect.h"
#define BUTTON_BOOT GPIO_NUM_0
static const char * TAG = "user_input";
static bool button_being_pressed = false;
void USER_INPUT_task(void * pvParameters){
gpio_set_direction(BUTTON_BOOT, GPIO_MODE_INPUT);
while(1) {
if (gpio_get_level(BUTTON_BOOT) == 0 && button_being_pressed == false) { // If button is pressed
ESP_LOGI(TAG, "BUTTON PRESSED");
button_being_pressed = true;
toggle_wifi_softap();
} else if (gpio_get_level(BUTTON_BOOT) == 1 && button_being_pressed == true){
button_being_pressed = false;
}
vTaskDelay(30/portTICK_PERIOD_MS); // Add delay so that current task does not starve idle task and trigger watchdog timer
}
}