scaffolding for steps
This commit is contained in:
parent
bd4548ec90
commit
bb20c66b85
@ -30,7 +30,7 @@ typedef enum {
|
|||||||
kd = 15,
|
kd = 15,
|
||||||
} KeypadKey;
|
} KeypadKey;
|
||||||
|
|
||||||
static const char *_TAG = "bottom_half";
|
static const char *BOTTOM_TAG = "bottom_half";
|
||||||
|
|
||||||
uint16_t keypad_state;
|
uint16_t keypad_state;
|
||||||
uint16_t button_state;
|
uint16_t button_state;
|
||||||
@ -190,7 +190,7 @@ static void poll_bottom_task(void *arg) {
|
|||||||
if (new_data) {
|
if (new_data) {
|
||||||
uint8_t delta = receive_delta();
|
uint8_t delta = receive_delta();
|
||||||
// ESP_LOGI(_TAG, "delta: %d", delta);
|
// ESP_LOGI(_TAG, "delta: %d", delta);
|
||||||
if (delta == 0) ESP_LOGW(_TAG, "delta pin was low, but delta register returned 0");
|
if (delta == 0) ESP_LOGW(BOTTOM_TAG, "delta pin was low, but delta register returned 0");
|
||||||
|
|
||||||
if (delta & (1 << DELTA_BIT_KP)) {
|
if (delta & (1 << DELTA_BIT_KP)) {
|
||||||
receive_keypad();
|
receive_keypad();
|
||||||
|
|||||||
@ -1,12 +1,91 @@
|
|||||||
#ifndef WIRES_HPP
|
#ifndef WIRES_HPP
|
||||||
#define WIRES_HPP
|
#define WIRES_HPP
|
||||||
|
|
||||||
|
#define WIRES_PIN_INTERUPT GPIO_NUM_2
|
||||||
|
#define WIRES_I2C_NUM I2C_NUM_1
|
||||||
|
#define WIRES_I2C_ADDR 125
|
||||||
|
|
||||||
|
static const char *WIRES_TAG = "wires";
|
||||||
|
|
||||||
|
uint8_t wires_states;
|
||||||
|
uint8_t wires_cut;
|
||||||
|
|
||||||
|
static void poll_wires_task(void *arg);
|
||||||
|
|
||||||
void init_wires(void) {
|
void init_wires(void) {
|
||||||
|
i2c_config_t wires_conf = {
|
||||||
|
.mode = I2C_MODE_MASTER,
|
||||||
|
.sda_io_num = GPIO_NUM_41,
|
||||||
|
.scl_io_num = GPIO_NUM_42,
|
||||||
|
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
|
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
|
.master = {
|
||||||
|
.clk_speed = 100000,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(i2c_param_config(WIRES_I2C_NUM, &wires_conf));
|
||||||
|
ESP_ERROR_CHECK(i2c_driver_install(WIRES_I2C_NUM, wires_conf.mode, 0, 0, 0));
|
||||||
|
|
||||||
|
gpio_config_t int_pin_conf = {};
|
||||||
|
// delta_pin_conf.intr_type = GPIO_INTR_LOW_LEVEL;
|
||||||
|
int_pin_conf.mode = GPIO_MODE_INPUT;
|
||||||
|
// GPIO 0
|
||||||
|
int_pin_conf.pin_bit_mask = (1ULL<<WIRES_PIN_INTERUPT);
|
||||||
|
int_pin_conf.pull_up_en = GPIO_PULLUP_ENABLE;
|
||||||
|
gpio_config(&int_pin_conf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void strike(char* reason) {
|
void strike(char* reason) {
|
||||||
|
uint8_t reg = 5;
|
||||||
|
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_to_device(WIRES_I2C_NUM, WIRES_I2C_ADDR, ®, 1, (1000 / portTICK_PERIOD_MS)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// read buffer
|
||||||
|
static uint8_t read_buf[8];
|
||||||
|
|
||||||
|
static uint8_t receive_delta(void) {
|
||||||
|
uint8_t reg = 1;
|
||||||
|
read_buf[0] = 0;
|
||||||
|
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, read_buf, 1, (100 / portTICK_PERIOD_MS)));
|
||||||
|
return read_buf[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void receive_wires(void) {
|
||||||
|
uint8_t reg = 1;
|
||||||
|
read_buf[0] = 0;
|
||||||
|
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, read_buf, 1, (100 / portTICK_PERIOD_MS)));
|
||||||
|
return read_buf[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void receive_button(void) {
|
||||||
|
uint8_t reg = 2;
|
||||||
|
read_buf[0] = 0;
|
||||||
|
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, read_buf, 1, (100 / portTICK_PERIOD_MS)));
|
||||||
|
uint8_t new_button = read_buf[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void poll_wires_task(void *arg) {
|
||||||
|
while (1) {
|
||||||
|
bool new_data = gpio_get_level(WIRES_PIN_INTERUPT) == 0;
|
||||||
|
if (new_data) {
|
||||||
|
if (delta == 0) ESP_LOGW(WIRES_TAG, "int pin was low, but int register returned 0");
|
||||||
|
|
||||||
|
if (delta & (1 << DELTA_BIT_KP)) {
|
||||||
|
receive_keypad();
|
||||||
|
// ESP_LOGI(_TAG, "keypad: %d", keypad_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delta & (1 << DELTA_BIT_BUTTON)) {
|
||||||
|
receive_button();
|
||||||
|
// ESP_LOGI(_TAG, "button: %d", button_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WIRES_HPP */
|
#endif /* WIRES_HPP */
|
||||||
@ -1,6 +1,6 @@
|
|||||||
## IDF Component Manager Manifest File
|
## IDF Component Manager Manifest File
|
||||||
dependencies:
|
dependencies:
|
||||||
iamflinks/i2c_lcd_pcf8574: "^1.0.1"
|
# iamflinks/i2c_lcd_pcf8574: "^1.0.1"
|
||||||
lvgl/lvgl: "^8.1"
|
lvgl/lvgl: "^8.1"
|
||||||
atanisoft/esp_lcd_ili9488: "^1.0.9"
|
atanisoft/esp_lcd_ili9488: "^1.0.9"
|
||||||
## Required IDF version
|
## Required IDF version
|
||||||
|
|||||||
@ -34,7 +34,7 @@ extern "C" void app_main(void) {
|
|||||||
|
|
||||||
init_bottom_half();
|
init_bottom_half();
|
||||||
init_char_lcd();
|
init_char_lcd();
|
||||||
|
init_wires();
|
||||||
|
|
||||||
step0();
|
step0();
|
||||||
step1();
|
step1();
|
||||||
@ -53,11 +53,6 @@ extern "C" void app_main(void) {
|
|||||||
// lv_timer_handler();
|
// lv_timer_handler();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// UART relay
|
|
||||||
xTaskCreate(relay_task, "relay_task", 4096, NULL, 10, NULL);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gpio_reset_pin(GPIO_NUM_41);
|
gpio_reset_pin(GPIO_NUM_41);
|
||||||
gpio_reset_pin(GPIO_NUM_42);
|
gpio_reset_pin(GPIO_NUM_42);
|
||||||
|
|
||||||
@ -99,9 +94,7 @@ extern "C" void app_main(void) {
|
|||||||
ESP_LOGI("main", "wires: %d", read[0]);
|
ESP_LOGI("main", "wires: %d", read[0]);
|
||||||
|
|
||||||
// Issue strike
|
// Issue strike
|
||||||
reg = 5;
|
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_to_device(I2C_NUM_1, 125, ®, 1, (1000 / portTICK_PERIOD_MS)));
|
|
||||||
ESP_LOGI("main", "Strike!");
|
|
||||||
|
|
||||||
// vTaskDelay(pdMS_TO_TICKS(10));
|
// vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
vTaskDelay(pdMS_TO_TICKS(20000));
|
vTaskDelay(pdMS_TO_TICKS(20000));
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef STEP_1_HPP
|
||||||
|
#define STEP_1_HPP
|
||||||
|
|
||||||
|
static const char *STEP1_TAG = "step1";
|
||||||
|
|
||||||
|
void step1(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* STEP_1_HPP */
|
||||||
10
main/steps/step2.hpp
Normal file
10
main/steps/step2.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef STEP_2_HPP
|
||||||
|
#define STEP_2_HPP
|
||||||
|
|
||||||
|
static const char *STEP2_TAG = "step2";
|
||||||
|
|
||||||
|
void step2(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* STEP_2_HPP */
|
||||||
10
main/steps/step3.hpp
Normal file
10
main/steps/step3.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef STEP_3_HPP
|
||||||
|
#define STEP_3_HPP
|
||||||
|
|
||||||
|
static const char *STEP3_TAG = "step3";
|
||||||
|
|
||||||
|
void step3(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* STEP_3_HPP */
|
||||||
10
main/steps/step4.hpp
Normal file
10
main/steps/step4.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef STEP_4_HPP
|
||||||
|
#define STEP_4_HPP
|
||||||
|
|
||||||
|
static const char *STEP4_TAG = "step4";
|
||||||
|
|
||||||
|
void step4(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* STEP_4_HPP */
|
||||||
10
main/steps/step5.hpp
Normal file
10
main/steps/step5.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef STEP_5_HPP
|
||||||
|
#define STEP_5_HPP
|
||||||
|
|
||||||
|
static const char *STEP5_TAG = "step5";
|
||||||
|
|
||||||
|
void step5(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* STEP_5_HPP */
|
||||||
10
main/steps/step6.hpp
Normal file
10
main/steps/step6.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef STEP_6_HPP
|
||||||
|
#define STEP_6_HPP
|
||||||
|
|
||||||
|
static const char *STEP6_TAG = "step6";
|
||||||
|
|
||||||
|
void step6(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* STEP_6_HPP */
|
||||||
Loading…
Reference in New Issue
Block a user