all the vienna updates, LEDs, 1/4sec time units, move button
This commit is contained in:
parent
53a9f358fa
commit
e180ce2416
4 changed files with 47 additions and 4 deletions
|
@ -7,7 +7,8 @@
|
||||||
#define PUMPS_ERR_OUT_IDX (1)
|
#define PUMPS_ERR_OUT_IDX (1)
|
||||||
#define GPIO_PUMP_PIN_SEL ((1ULL<<pump_gpio_map[0]) | (1ULL<<pump_gpio_map[1]) | (1ULL<<pump_gpio_map[2]) | (1ULL<<pump_gpio_map[3]));
|
#define GPIO_PUMP_PIN_SEL ((1ULL<<pump_gpio_map[0]) | (1ULL<<pump_gpio_map[1]) | (1ULL<<pump_gpio_map[2]) | (1ULL<<pump_gpio_map[3]));
|
||||||
|
|
||||||
static uint8_t pump_gpio_map[] = { 27, 26, 25, 33 };
|
static uint8_t pump_gpio_map[] = { 12, 13, 2, 4 };
|
||||||
|
extern uint8_t running;
|
||||||
|
|
||||||
void pumps_run();
|
void pumps_run();
|
||||||
void pumps_stop();
|
void pumps_stop();
|
||||||
|
|
44
main/main.c
44
main/main.c
|
@ -10,6 +10,8 @@
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
#include "esp_vfs_dev.h"
|
#include "esp_vfs_dev.h"
|
||||||
|
|
||||||
|
#include "led_strip.h"
|
||||||
|
|
||||||
#include "configulator.h"
|
#include "configulator.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
@ -17,10 +19,39 @@
|
||||||
#include "user_button.h"
|
#include "user_button.h"
|
||||||
#include "pumps.h"
|
#include "pumps.h"
|
||||||
|
|
||||||
|
#define LED_GPIO 14
|
||||||
|
#define LED_COUNT 5
|
||||||
|
|
||||||
static const char *TAG = "BARBACK";
|
static const char *TAG = "BARBACK";
|
||||||
|
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
nvs_handle_t config_handle = {};
|
nvs_handle_t config_handle = {};
|
||||||
|
led_strip_handle_t led_strip;
|
||||||
|
|
||||||
|
void led_init() {
|
||||||
|
led_strip_config_t strip_config = {
|
||||||
|
.strip_gpio_num = LED_GPIO, // The GPIO that connected to the LED strip's data line
|
||||||
|
.max_leds = LED_COUNT, // The number of LEDs in the strip,
|
||||||
|
.led_model = LED_MODEL_WS2812, // LED strip model, it determines the bit timing
|
||||||
|
.color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_GRB, // The color component format is G-R-B
|
||||||
|
.flags = {
|
||||||
|
.invert_out = false, // don't invert the output signal
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// RMT backend specific configuration
|
||||||
|
led_strip_rmt_config_t rmt_config = {
|
||||||
|
.clk_src = RMT_CLK_SRC_DEFAULT, // different clock source can lead to different power consumption
|
||||||
|
.resolution_hz = 10 * 1000 * 1000, // RMT counter clock frequency: 10MHz
|
||||||
|
.mem_block_symbols = 64, // the memory size of each RMT channel, in words (4 bytes)
|
||||||
|
.flags = {
|
||||||
|
.with_dma = false, // DMA feature is available on chips like ESP32-S3/P4
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Create the LED strip object
|
||||||
|
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
|
||||||
|
}
|
||||||
|
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
esp_err_t err = nvs_flash_init();
|
esp_err_t err = nvs_flash_init();
|
||||||
|
@ -71,7 +102,18 @@ void app_main(void) {
|
||||||
|
|
||||||
xTaskCreate(console_task, "console", 4048, NULL, tskIDLE_PRIORITY + 3, NULL);
|
xTaskCreate(console_task, "console", 4048, NULL, tskIDLE_PRIORITY + 3, NULL);
|
||||||
|
|
||||||
|
led_init();
|
||||||
|
|
||||||
|
uint16_t tick = 0;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
uint16_t delay = running > 0 ? 500 / running : 500;
|
||||||
|
vTaskDelay(delay / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
|
uint8_t color = tick % (LED_COUNT * 2) > LED_COUNT ? 0 : 100;
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(led_strip_set_pixel(led_strip, tick % LED_COUNT, 5, 5, color));
|
||||||
|
ESP_ERROR_CHECK(led_strip_refresh(led_strip));
|
||||||
|
tick++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ void pumps_run() {
|
||||||
|
|
||||||
running++;
|
running++;
|
||||||
|
|
||||||
pump_timers[i] = xTimerCreate((const char *)(0x48 + i), (pumps_duration[i] * 1000 / portTICK_PERIOD_MS), pdFALSE, (void*)0, pump_timer_done);
|
pump_timers[i] = xTimerCreate((const char *)(0x48 + i), (pumps_duration[i] * 250 / portTICK_PERIOD_MS), pdFALSE, (void*)0, pump_timer_done);
|
||||||
|
|
||||||
xTimerStart(pump_timers[i], 0);
|
xTimerStart(pump_timers[i], 0);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "pumps.h"
|
#include "pumps.h"
|
||||||
#include "ble.h"
|
#include "ble.h"
|
||||||
|
|
||||||
#define GPIO_USER_BUTTON (14)
|
#define GPIO_USER_BUTTON (19)
|
||||||
|
|
||||||
static void IRAM_ATTR gpio_isr_handler(void* arg) {
|
static void IRAM_ATTR gpio_isr_handler(void* arg) {
|
||||||
uint32_t gpio_num = (uint32_t) arg;
|
uint32_t gpio_num = (uint32_t) arg;
|
||||||
|
|
Loading…
Add table
Reference in a new issue