diff options
| Commit | 3d19daa6677bebd8b28a8cc49421653f9df28f37 (patch) | |
|---|---|---|
| Author | 2024-05-06 14:31:58 +0300 | |
| Committer | 2024-05-06 14:31:58 +0300 | |
| Files | 2aea4ee9c39bfa556d31f482287777d19976c63e | |
| uni-projects-3d19daa6677bebd8b28a8cc49421653f9df28f37.tar uni-projects-3d19daa6677bebd8b28a8cc49421653f9df28f37.tar.gz uni-projects-3d19daa6677bebd8b28a8cc49421653f9df28f37.zip | ||
| Parent | 7a249f6152b4493cf0c51785313d0f1d4755839f (diff) | |
[iot/goam] Rough display initialization
4 files changed, 45 insertions, 0 deletions
| -rw-r--r-- | Year 3/Internet of things/goam/main/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/display.c | 39 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/display.h | 3 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/main.c | 2 |
diff --git a/Year 3/Internet of things/goam/main/CMakeLists.txt b/Year 3/Internet of things/goam/main/CMakeLists.txt index c4fd248..656f4cb 100644 --- a/Year 3/Internet of things/goam/main/CMakeLists.txt +++ b/Year 3/Internet of things/goam/main/CMakeLists.txt @@ -1,4 +1,5 @@ idf_component_register(SRCS "main.c" "ptc06.c" "buttons.c" + "display.c" INCLUDE_DIRS "") diff --git a/Year 3/Internet of things/goam/main/display.c b/Year 3/Internet of things/goam/main/display.c new file mode 100644 index 0000000..7a77910 --- /dev/null +++ b/Year 3/Internet of things/goam/main/display.c @@ -0,0 +1,39 @@ +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#include "driver/i2c.h" +#include "display.h" + +#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_pullup_en = GPIO_PULLUP_ENABLE, + .scl_pullup_en = GPIO_PULLUP_ENABLE, + .master.clk_speed = 400000, // 4kHz; at least 385kHz + }; + i2c_param_config(I2C_NUM_0, &conf); + i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0); + i2c_set_start_timing(I2C_NUM_0, 10, 10); +} + +static void i2c_send() { + i2c_cmd_handle_t i2c_handle = i2c_cmd_link_create(); + ESP_ERROR_CHECK(i2c_master_start(i2c_handle)); + ESP_ERROR_CHECK(i2c_master_write_byte(i2c_handle, 0b01111000, true)); + char data[] = { 0x00, 0x8D, 0x14, 0xAF, 0xA7 }; + ESP_ERROR_CHECK(i2c_master_write(i2c_handle, (const unsigned char*)data, sizeof(data), true)); + ESP_ERROR_CHECK(i2c_master_stop(i2c_handle)); + ESP_ERROR_CHECK(i2c_master_cmd_begin(I2C_NUM_0, i2c_handle, 1000)); + i2c_cmd_link_delete(i2c_handle); +} + +void display_init() { + i2c_init(); + i2c_send(); +} diff --git a/Year 3/Internet of things/goam/main/display.h b/Year 3/Internet of things/goam/main/display.h new file mode 100644 index 0000000..d796bd7 --- /dev/null +++ b/Year 3/Internet of things/goam/main/display.h @@ -0,0 +1,3 @@ +#pragma once + +void display_init(); diff --git a/Year 3/Internet of things/goam/main/main.c b/Year 3/Internet of things/goam/main/main.c index ce87b7b..232bfdc 100644 --- a/Year 3/Internet of things/goam/main/main.c +++ b/Year 3/Internet of things/goam/main/main.c @@ -16,6 +16,7 @@ #include "driver/uart.h" #include "ptc06.h" #include "buttons.h" +#include "display.h" void print_chip_data() { /* Print chip information */ @@ -65,6 +66,7 @@ void app_main(void) buttons_init(); add_push_button(BTN_SHOOT_PIN, take_photo, NULL); + display_init(); for (int i = 0; true; i++) { /* ptc06_reset(); */ |
