diff options
| Commit | 1279d4d473f8a77f7245bf18a8509e9a91c0e1aa (patch) | |
|---|---|---|
| Author | 2024-05-28 17:04:10 +0300 | |
| Committer | 2024-05-28 17:04:10 +0300 | |
| Files | bc7fdb0fef03723382514341e29e1c09e7b734de | |
| uni-projects-1279d4d473f8a77f7245bf18a8509e9a91c0e1aa.tar uni-projects-1279d4d473f8a77f7245bf18a8509e9a91c0e1aa.tar.gz uni-projects-1279d4d473f8a77f7245bf18a8509e9a91c0e1aa.zip | ||
| Parent | 9857d1c5f4ee4fe8da252fefa02a0c417cbdc1df (diff) | |
[iot/goam] Exported many define variables to Kconfig
5 files changed, 51 insertions, 15 deletions
| -rw-r--r-- | Year 3/Internet of things/goam/main/Kconfig.projbuild | 25 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/display.c | 10 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/main.c | 8 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/ptc06.c | 6 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/sdkconfig | 17 |
diff --git a/Year 3/Internet of things/goam/main/Kconfig.projbuild b/Year 3/Internet of things/goam/main/Kconfig.projbuild index eddf308..f2a1231 100644 --- a/Year 3/Internet of things/goam/main/Kconfig.projbuild +++ b/Year 3/Internet of things/goam/main/Kconfig.projbuild @@ -35,4 +35,29 @@ menu "GoAm configurations" range 1 4 default 3 endmenu + menu "Hardware info" + config DISPLAY_COLUMNS + int "Count of columns on the display" + default 128 + config DISPLAY_PAGES + int "Count of pages on the display, generally count of rows / 8" + default 8 + endmenu + menu "Pin configuration" + config BTN_SHOOT_PIN + int "Pin on which the shoot button is connected" + default 13 + config DISPLAY_SCL_PIN + int "Pin to which the display SCL pin is connected" + default 19 + config DISPLAY_SDA_PIN + int "Pin to which the display SDA pin is connected" + default 18 + config CAM_TX_PIN + int "Pin to which the camera TX pin is connected" + default 17 + config CAM_RX_PIN + int "Pin to which the camera RX pin is connected" + default 16 + endmenu endmenu diff --git a/Year 3/Internet of things/goam/main/display.c b/Year 3/Internet of things/goam/main/display.c index a8aeb6c..a1f3cc2 100644 --- a/Year 3/Internet of things/goam/main/display.c +++ b/Year 3/Internet of things/goam/main/display.c @@ -12,22 +12,20 @@ unsigned int min(unsigned int a, unsigned int b) { static const char* TAG = "display"; -#define LAST_PAGE 7 -#define LAST_COL 127 +#define LAST_PAGE (CONFIG_DISPLAY_PAGES - 1) +#define LAST_COL (CONFIG_DISPLAY_COLUMNS - 1) /* * I2C settings */ -#define SCL_IO_PIN 19 -#define SDA_IO_PIN 18 #define MASTER_FREQUENCY CONFIG_I2C_MASTER_FREQUENCY static void i2c_init() { i2c_config_t conf = { .mode = I2C_MODE_MASTER, - .sda_io_num = SDA_IO_PIN, - .scl_io_num = SCL_IO_PIN, + .sda_io_num = CONFIG_DISPLAY_SDA_PIN, + .scl_io_num = CONFIG_DISPLAY_SCL_PIN, .sda_pullup_en = GPIO_PULLUP_ENABLE, .scl_pullup_en = GPIO_PULLUP_ENABLE, .master.clk_speed = 400000, // 400kHz; has to be at least 385kHz diff --git a/Year 3/Internet of things/goam/main/main.c b/Year 3/Internet of things/goam/main/main.c index fe52995..58c1767 100644 --- a/Year 3/Internet of things/goam/main/main.c +++ b/Year 3/Internet of things/goam/main/main.c @@ -164,8 +164,6 @@ void main_stop_timelapse() { * On button press */ -#define BTN_SHOOT_PIN 13 - static void debug_serial_print_image(const char* image, size_t length) { for (int i = 0; i < length; i++) { printf("%d ", image[i]); @@ -198,12 +196,12 @@ static void take_photo() { } static void timelapse_callback(TimerHandle_t timer) { - press_push_button(BTN_SHOOT_PIN); + press_push_button(CONFIG_BTN_SHOOT_PIN); ESP_LOGI(TAG, "Taking timelapse photo"); } void main_force_photo() { - press_push_button(BTN_SHOOT_PIN); + press_push_button(CONFIG_BTN_SHOOT_PIN); } @@ -243,7 +241,7 @@ void app_main(void) // they're in a task or not spiffs_init(); buttons_init(); - add_push_button(BTN_SHOOT_PIN, take_photo); + add_push_button(CONFIG_BTN_SHOOT_PIN, take_photo); display_init(); display_printat(DCHAR_NO_CAMERA, diff --git a/Year 3/Internet of things/goam/main/ptc06.c b/Year 3/Internet of things/goam/main/ptc06.c index 6cc0182..5f29656 100644 --- a/Year 3/Internet of things/goam/main/ptc06.c +++ b/Year 3/Internet of things/goam/main/ptc06.c @@ -50,8 +50,6 @@ static void debug_print(const char* prepend, char* message, size_t size) { */ #define UART_NUM UART_NUM_2 -#define UART_TX 17 -#define UART_RX 16 #define UART_BUFFER_SIZE 16 * 1024 // Setup UART buffered IO with event queue @@ -74,7 +72,7 @@ static void init_uart_interface() { ESP_ERROR_CHECK(uart_param_config(UART_NUM, &uart_config)); // Set UART pins(TX: IO17 (UART2 default), RX: IO16 (UART2 default), RTS: IO18, CTS: IO19) - ESP_ERROR_CHECK(uart_set_pin(UART_NUM, UART_TX, UART_RX, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)); + ESP_ERROR_CHECK(uart_set_pin(UART_NUM, CONFIG_CAM_TX_PIN, CONFIG_CAM_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)); // Install UART driver using an event queue ESP_ERROR_CHECK(uart_driver_install(UART_NUM, UART_BUFFER_SIZE, UART_BUFFER_SIZE, QUEUE_SIZE, &uart_queue, 0)); @@ -301,7 +299,7 @@ void ptc06_init() { /* ptc06_set_resolution(); */ /* ptc06_set_compressibility(); */ - ESP_LOGI(TAG, "Initialized ptc06 successfully. UART tx: %d, rx: %d", UART_TX, UART_RX); + ESP_LOGI(TAG, "Initialized ptc06 successfully. UART tx: %d, rx: %d", CONFIG_CAM_TX_PIN, CONFIG_CAM_RX_PIN); } void ptc06_reset() { diff --git a/Year 3/Internet of things/goam/sdkconfig b/Year 3/Internet of things/goam/sdkconfig index ca57322..2aa008a 100644 --- a/Year 3/Internet of things/goam/sdkconfig +++ b/Year 3/Internet of things/goam/sdkconfig @@ -362,6 +362,23 @@ CONFIG_WIFI_COLUMN=15 CONFIG_DISPLAY_IP_ROW=2 CONFIG_DISPLAY_SSID_ROW=3 # end of Display layout + +# +# Hardware info +# +CONFIG_DISPLAY_COLUMNS=128 +CONFIG_DISPLAY_PAGES=8 +# end of Hardware info + +# +# Pin configuration +# +CONFIG_BTN_SHOOT_PIN=13 +CONFIG_DISPLAY_SCL_PIN=19 +CONFIG_DISPLAY_SDA_PIN=18 +CONFIG_CAM_TX_PIN=17 +CONFIG_CAM_RX_PIN=16 +# end of Pin configuration # end of GoAm configurations # |
