Merge branch 'config' into development
This commit is contained in:
commit
d00d06efb2
7 changed files with 19 additions and 19 deletions
|
@ -1 +0,0 @@
|
||||||
Subproject commit 7ec406c5af692b9c99ae9ed0c7fb5ba648a0a71e
|
|
|
@ -8,7 +8,7 @@
|
||||||
#define PUMP_COUNT (4)
|
#define PUMP_COUNT (4)
|
||||||
|
|
||||||
static QueueHandle_t gpio_evt_queue = NULL;
|
static QueueHandle_t gpio_evt_queue = NULL;
|
||||||
nvs_handle_t config_handle;
|
extern nvs_handle_t config_handle;
|
||||||
|
|
||||||
extern uint8_t mac[6];
|
extern uint8_t mac[6];
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,8 @@ static int barback_ble_char_access(uint16_t conn_handle, uint16_t attr_handle, s
|
||||||
#define BLE_SERVICE_PUMP_DURATION (0x4350)
|
#define BLE_SERVICE_PUMP_DURATION (0x4350)
|
||||||
|
|
||||||
#define BLE_SERVICE_BARBACK (0x4400)
|
#define BLE_SERVICE_BARBACK (0x4400)
|
||||||
#define CHAR_POUR (BLE_SERVICE_BARBACK + 1)
|
#define CHAR_POUR (BLE_SERVICE_BARBACK + 1) // 0x4401
|
||||||
#define CHAR_BUTTON (BLE_SERVICE_BARBACK + 2)
|
#define CHAR_BUTTON (BLE_SERVICE_BARBACK + 2) // 0x4402
|
||||||
|
|
||||||
static barback_ble_access_t barback_ble_pump_access_enabled = {
|
static barback_ble_access_t barback_ble_pump_access_enabled = {
|
||||||
.read = pumps_get_enabled,
|
.read = pumps_get_enabled,
|
||||||
|
@ -139,7 +139,7 @@ static const struct ble_gatt_svc_def service_defs[] = {
|
||||||
.val_handle = &svc_handle_button,
|
.val_handle = &svc_handle_button,
|
||||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY
|
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY
|
||||||
},
|
},
|
||||||
{ 0 }
|
{ 0 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ 0 } // no more services
|
{ 0 } // no more services
|
||||||
|
@ -466,7 +466,7 @@ void ble_init(char *name) {
|
||||||
|
|
||||||
memset(&callback_handlers, 0, sizeof(event_callback_handle_t) * CONFIG_CACO_MAX_SERVICES);
|
memset(&callback_handlers, 0, sizeof(event_callback_handle_t) * CONFIG_CACO_MAX_SERVICES);
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
//ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init());
|
||||||
|
|
||||||
nimble_port_init();
|
nimble_port_init();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ void console_task(void *args) {
|
||||||
.data_bits = UART_DATA_8_BITS,
|
.data_bits = UART_DATA_8_BITS,
|
||||||
.parity = UART_PARITY_DISABLE,
|
.parity = UART_PARITY_DISABLE,
|
||||||
.stop_bits = UART_STOP_BITS_1,
|
.stop_bits = UART_STOP_BITS_1,
|
||||||
.use_ref_tick = true
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_ERROR_CHECK(uart_param_config(CONFIG_ESP_CONSOLE_UART_NUM, &uart_config));
|
ESP_ERROR_CHECK(uart_param_config(CONFIG_ESP_CONSOLE_UART_NUM, &uart_config));
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
#include "esp_mac.h"
|
||||||
#include "esp_debug_helpers.h"
|
#include "esp_debug_helpers.h"
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
#include "esp_vfs_dev.h"
|
#include "esp_vfs_dev.h"
|
||||||
|
@ -14,11 +15,11 @@
|
||||||
#include "ble.h"
|
#include "ble.h"
|
||||||
#include "user_button.h"
|
#include "user_button.h"
|
||||||
#include "pumps.h"
|
#include "pumps.h"
|
||||||
#include "dfplayermini.h"
|
|
||||||
|
|
||||||
static const char *TAG = "BARBACK";
|
static const char *TAG = "BARBACK";
|
||||||
|
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
|
nvs_handle_t config_handle = {};
|
||||||
|
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
esp_err_t err = nvs_flash_init();
|
esp_err_t err = nvs_flash_init();
|
||||||
|
@ -33,7 +34,7 @@ void app_main(void) {
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
|
printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "config_handle: %d", config_handle);
|
ESP_LOGI(TAG, "config_handle: %d", (int)config_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_efuse_mac_get_default((uint8_t*)&mac);
|
esp_efuse_mac_get_default((uint8_t*)&mac);
|
||||||
|
@ -45,8 +46,6 @@ void app_main(void) {
|
||||||
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
dfplayermini_init();
|
|
||||||
|
|
||||||
user_button_init();
|
user_button_init();
|
||||||
pumps_init();
|
pumps_init();
|
||||||
ble_init(name);
|
ble_init(name);
|
||||||
|
|
11
main/pumps.c
11
main/pumps.c
|
@ -76,7 +76,7 @@ uint8_t pump_disable(int8_t i) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void pump_timer_done(TimerHandle_t timer) {
|
void pump_timer_done(TimerHandle_t timer) {
|
||||||
uint8_t idx = (pcTimerGetTimerName(timer) - 0x48);
|
uint8_t idx = (pcTimerGetName(timer) - 0x48);
|
||||||
ESP_LOGD(TAG, "pump done: %d", idx);
|
ESP_LOGD(TAG, "pump done: %d", idx);
|
||||||
|
|
||||||
running--;
|
running--;
|
||||||
|
@ -86,9 +86,12 @@ void pump_timer_done(TimerHandle_t timer) {
|
||||||
|
|
||||||
void pumps_stop() {
|
void pumps_stop() {
|
||||||
for(uint8_t i = 0; i < PUMPS; i++) {
|
for(uint8_t i = 0; i < PUMPS; i++) {
|
||||||
if(pump_timers[i] != NULL)
|
if(pump_timers[i] != NULL) {
|
||||||
pump_disable(i);
|
pump_disable(i);
|
||||||
xTimerStop(pump_timers[i], 0);
|
xTimerStop(pump_timers[i], 0);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +120,7 @@ uint8_t pumps_init() {
|
||||||
gpio_set_level(pump_gpio_map[i], 0);
|
gpio_set_level(pump_gpio_map[i], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
|
io_conf.intr_type = GPIO_INTR_DISABLE;
|
||||||
io_conf.mode = GPIO_MODE_OUTPUT;
|
io_conf.mode = GPIO_MODE_OUTPUT;
|
||||||
io_conf.pin_bit_mask = GPIO_PUMP_PIN_SEL;
|
io_conf.pin_bit_mask = GPIO_PUMP_PIN_SEL;
|
||||||
io_conf.pull_down_en = 1;
|
io_conf.pull_down_en = 1;
|
||||||
|
@ -126,7 +129,7 @@ uint8_t pumps_init() {
|
||||||
|
|
||||||
// zero out pump enabled, duration
|
// zero out pump enabled, duration
|
||||||
memset(&pumps_enabled, 0, sizeof(uint8_t) * PUMPS);
|
memset(&pumps_enabled, 0, sizeof(uint8_t) * PUMPS);
|
||||||
memset(&pumps_duration, 10, sizeof(uint8_t) * PUMPS);
|
memset(&pumps_duration, 5, sizeof(uint8_t) * PUMPS);
|
||||||
|
|
||||||
size_t size = sizeof(uint8_t) * PUMPS;
|
size_t size = sizeof(uint8_t) * PUMPS;
|
||||||
if(!nvs_get_blob(config_handle, "pumps_duration", &pumps_duration, &size)) {
|
if(!nvs_get_blob(config_handle, "pumps_duration", &pumps_duration, &size)) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "pumps.h"
|
#include "pumps.h"
|
||||||
#include "ble.h"
|
#include "ble.h"
|
||||||
|
|
||||||
#define GPIO_USER_BUTTON (19)
|
#define GPIO_USER_BUTTON (14)
|
||||||
|
|
||||||
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;
|
||||||
|
@ -27,10 +27,10 @@ static void gpio_task(void* arg) {
|
||||||
if(level == last_level) continue;
|
if(level == last_level) continue;
|
||||||
last_level = level;
|
last_level = level;
|
||||||
|
|
||||||
printf("GPIO[%d] intr, val: %d\n", io_num, level);
|
printf("GPIO[%ld] intr, val: %d\n", io_num, level);
|
||||||
|
|
||||||
if(state == 0)
|
if(state == 0)
|
||||||
vTaskDelay(10 / portTICK_RATE_MS);
|
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
pumps_run();
|
pumps_run();
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ static void gpio_task(void* arg) {
|
||||||
void user_button_init() {
|
void user_button_init() {
|
||||||
gpio_config_t io_conf;
|
gpio_config_t io_conf;
|
||||||
|
|
||||||
io_conf.intr_type = GPIO_PIN_INTR_ANYEDGE;
|
io_conf.intr_type = GPIO_INTR_ANYEDGE;
|
||||||
io_conf.mode = GPIO_MODE_INPUT;
|
io_conf.mode = GPIO_MODE_INPUT;
|
||||||
io_conf.pin_bit_mask = (1ULL << GPIO_USER_BUTTON);
|
io_conf.pin_bit_mask = (1ULL << GPIO_USER_BUTTON);
|
||||||
io_conf.pull_down_en = 0;
|
io_conf.pull_down_en = 0;
|
||||||
|
|
Loading…
Reference in a new issue