Bence Balint 3 жил өмнө
parent
commit
84c3e40de2

+ 1 - 0
CMakeLists.txt

@@ -25,6 +25,7 @@ idf_component_register(
         "esp_adc_cal"
         "esp_http_client"
         "esp_http_server"
+        "hd44780"
         "nvs_flash"
         "spiffs"
 )

+ 1 - 0
test/CMakeLists.txt

@@ -2,6 +2,7 @@ idf_component_register(
         SRC_DIRS
         "."
         "rtos"
+        "esp-idf-lib"
 
         INCLUDE_DIRS
         "."

+ 67 - 0
test/esp-idf-lib/test_lcd.cpp

@@ -0,0 +1,67 @@
+#include <kbf.h>
+
+#include <hd44780.h>
+
+#include <unity.h>
+#include <esp_task.h>
+#include <esp_task_wdt.h>
+
+static uint32_t get_time_sec() {
+    struct timeval tv{};
+    gettimeofday(&tv, nullptr);
+    return tv.tv_sec;
+}
+
+static const uint8_t char_data[] = {
+        0x04, 0x0e, 0x0e, 0x0e, 0x1f, 0x00, 0x04, 0x00,
+        0x1f, 0x11, 0x0a, 0x04, 0x0a, 0x11, 0x1f, 0x00
+};
+
+[[noreturn]] void lcd_test(void *) {
+    hd44780_t lcd = {
+            .write_cb = nullptr,
+            .pins = {
+                    .rs = GPIO_NUM_32,
+                    .e  = GPIO_NUM_33,
+                    .d4 = GPIO_NUM_25,
+                    .d5 = GPIO_NUM_26,
+                    .d6 = GPIO_NUM_27,
+                    .d7 = GPIO_NUM_13,
+                    .bl = HD44780_NOT_USED
+            },
+            .font = HD44780_FONT_5X8,
+            .lines = 2,
+            .backlight = true,
+    };
+
+    ESP_ERROR_CHECK(hd44780_init(&lcd));
+
+    hd44780_upload_character(&lcd, 0, char_data);
+    hd44780_upload_character(&lcd, 1, char_data + 8);
+
+    hd44780_gotoxy(&lcd, 0, 0);
+    hd44780_puts(&lcd, "\x08 Hello world!");
+    hd44780_gotoxy(&lcd, 0, 1);
+    hd44780_puts(&lcd, "\x09 ");
+
+    char time[16];
+
+    while (true) {
+        hd44780_gotoxy(&lcd, 2, 1);
+
+        snprintf(time, 7, "%u  ", get_time_sec());
+        time[sizeof(time) - 1] = 0;
+
+        hd44780_puts(&lcd, time);
+
+        vTaskDelay(1000 / portTICK_PERIOD_MS);
+    }
+}
+
+[[noreturn]] TEST_CASE("LCD", "[esp-idf-lib]") {
+    xTaskCreate(lcd_test, "lcd_test", configMINIMAL_STACK_SIZE * 3, nullptr, 5, nullptr);
+
+    while (true) {
+        kbf::sleep(1000);
+    }
+}

+ 2 - 0
test_app/CMakeLists.txt

@@ -25,4 +25,6 @@ set(TEST_COMPONENTS "kbf" CACHE STRING "List of components to test")
 
 include($ENV{IDF_PATH}/tools/cmake/project.cmake)
 
+set(EXTRA_COMPONENT_DIRS "../../" "../lib/esp-idf-lib/components/")
+
 project(kbf)

+ 56 - 0
test_app/sdkconfig

@@ -1083,6 +1083,62 @@ CONFIG_WPA_MBEDTLS_CRYPTO=y
 # CONFIG_WPA_WPS_WARS is not set
 # CONFIG_WPA_11KV_SUPPORT is not set
 # end of Supplicant
+
+#
+# Rotary encoders
+#
+CONFIG_RE_MAX=1
+CONFIG_RE_INTERVAL_US=1000
+CONFIG_RE_BTN_DEAD_TIME_US=10000
+CONFIG_RE_BTN_PRESSED_LEVEL_0=y
+# CONFIG_RE_BTN_PRESSED_LEVEL_1 is not set
+CONFIG_RE_BTN_LONG_PRESS_TIME_US=500000
+# end of Rotary encoders
+
+#
+# HMC5883L
+#
+CONFIG_HMC5883L_MEAS_TIMEOUT=6000
+# end of HMC5883L
+
+#
+# I2C
+#
+CONFIG_I2CDEV_TIMEOUT=1000
+# end of I2C
+
+#
+# LED effect
+#
+CONFIG_LED_EFFECT_COLOR_USING_RGB=y
+# CONFIG_LED_EFFECT_COLOR_USING_RGBW is not set
+# end of LED effect
+
+#
+# LED strip
+#
+CONFIG_LED_STRIP_FLUSH_TIMEOUT=1000
+# end of LED strip
+
+#
+# LED strip SPI
+#
+CONFIG_LED_STRIP_SPI_USING_SK9822=y
+CONFIG_LED_STRIP_SPI_MUTEX_TIMEOUT_MS=1
+# end of LED strip SPI
+
+#
+# MCP23x17
+#
+CONFIG_MCP23X17_IFACE_I2C=y
+# CONFIG_MCP23X17_IFACE_SPI is not set
+# end of MCP23x17
+
+#
+# OneWire
+#
+CONFIG_ONEWIRE_CRC8_TABLE=y
+# end of OneWire
 # end of Component config
 
 #