Merge remote-tracking branch 'origin/vienna_wtf' into development
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Morgan 'ARR\!' Allen 2025-07-31 12:22:53 -07:00
commit 1bdfc64972
3 changed files with 45 additions and 2 deletions

View file

@ -7,8 +7,8 @@
#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]));
// Pins with Weak Pull-Downs 2, 4, 12, 13
static uint8_t pump_gpio_map[] = { 12, 13, 2, 4 };
extern uint8_t running;
void pumps_run();
void pumps_stop();

View file

@ -10,6 +10,8 @@
#include "nvs_flash.h"
#include "esp_vfs_dev.h"
#include "led_strip.h"
#include "configulator.h"
#include "main.h"
#include "console.h"
@ -17,10 +19,39 @@
#include "user_button.h"
#include "pumps.h"
#define LED_GPIO 14
#define LED_COUNT 5
static const char *TAG = "BARBACK";
uint8_t mac[6];
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) {
// init pump IO immediately to limit run away pumps in case power is on
@ -74,7 +105,18 @@ void app_main(void) {
xTaskCreate(console_task, "console", 4048, NULL, tskIDLE_PRIORITY + 3, NULL);
led_init();
uint16_t tick = 0;
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++;
}
}

View file

@ -101,6 +101,7 @@ void pumps_run() {
running++;
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);
pumps_set_enabled(i, 1);