Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Fixes #41

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@
"sht3x_sensor_device.h": "c",
"scd4x_sensor_device.h": "c"
},
"C_Cpp.errorSquiggles": "disabled"
"C_Cpp.errorSquiggles": "disabled",
"editor.formatOnSave": true
}
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ cmake_minimum_required(VERSION 3.5)
set(SDKCONFIG "${CMAKE_BINARY_DIR}/sdkconfig")

# Sensor 1
#set(BUILD_DIR build-sensor1)
set(SDKCONFIG_DEFAULTS "sdkconfig.defaults;sdkconfig.sensor1")

# Sensor 2
#set(BUILD_DIR build-sensor2)
#set(CMAKE_BINARY_DIR build-sensor2)
#set(SDKCONFIG_DEFAULTS "sdkconfig.defaults;sdkconfig.sensor2")

#idf_build_set_property(BUILD_DIR "build-sensor2")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

#LVGL custom config file setup
Expand Down
2 changes: 1 addition & 1 deletion components/LovyanGFX
Submodule LovyanGFX updated 96 files
+4 −1 .github/ISSUE_TEMPLATE/bug-report--------.md
+1 −0 .github/scripts/SDL.cmake
+121 −0 .github/scripts/esp-idf-versions.php
+8 −19 .github/workflows/ArduinoBuild.yml
+63 −55 .github/workflows/IDFBuild.yml
+4 −6 .github/workflows/PlatformioBuild.yml
+47 −1 .github/workflows/SDLBuild.yml
+1 −0 README.md
+1 −0 examples/HowToUse/2_user_setting/2_user_setting.ino
+2 −2 examples/Sprite/ClockSample/ClockSample.ino
+0 −2 examples/Sprite/MeterSample/MeterSample.ino
+2 −2 examples/Test/build_test/main/main.cpp
+63 −160 examples/Test/build_test/platformio_esp32.ini
+0 −1 examples_for_PC/CMake_SDL/CMakeLists.txt
+26 −14 examples_for_PC/CMake_SDL/CMakeSettings.json
+0 −29 examples_for_PC/CMake_SDL/LGFX_SDL.cpp
+23 −0 examples_for_PC/CMake_SDL/sdl_main.cpp
+1 −1 examples_for_PC/CMake_WASM/CMakeLists.txt
+4 −5 examples_for_PC/CMake_WASM/LGFX_WASM.cpp
+15 −0 examples_for_PC/CMake_WASM/README.md
+79 −0 examples_for_PC/PlatformIO_SDL/README.md
+34 −0 examples_for_PC/PlatformIO_SDL/platformio.ini
+23 −0 examples_for_PC/PlatformIO_SDL/src/sdl_main.cpp
+34 −0 examples_for_PC/PlatformIO_SDL/src/user_code.cpp
+3 −3 library.json
+1 −1 library.properties
+1 −1 src/lgfx/Fonts/IPA/lgfx_font_japan.c
+1 −1 src/lgfx/Fonts/efont/lgfx_efont_cn.c
+1 −1 src/lgfx/Fonts/efont/lgfx_efont_ja.c
+1 −1 src/lgfx/Fonts/efont/lgfx_efont_kr.c
+1 −1 src/lgfx/Fonts/efont/lgfx_efont_tw.c
+1 −0 src/lgfx/boards.hpp
+1 −1 src/lgfx/utility/lgfx_qoi.c
+2 −2 src/lgfx/utility/lgfx_qrcode.c
+6 −6 src/lgfx/utility/lgfx_tjpgd.c
+6 −6 src/lgfx/utility/lgfx_tjpgd.h
+88 −23 src/lgfx/v1/LGFXBase.cpp
+176 −4 src/lgfx/v1/LGFXBase.hpp
+109 −7 src/lgfx/v1/LGFX_Sprite.cpp
+12 −135 src/lgfx/v1/LGFX_Sprite.hpp
+8 −0 src/lgfx/v1/Panel.hpp
+1 −1 src/lgfx/v1/gitTagVersion.h
+22 −165 src/lgfx/v1/lgfx_filesystem_support.hpp
+154 −42 src/lgfx/v1/misc/DataWrapper.hpp
+1 −1 src/lgfx/v1/misc/colortype.hpp
+1 −0 src/lgfx/v1/misc/range.hpp
+18 −10 src/lgfx/v1/panel/Panel_Device.cpp
+3 −3 src/lgfx/v1/panel/Panel_Device.hpp
+1 −1 src/lgfx/v1/panel/Panel_FrameBufferBase.cpp
+1 −1 src/lgfx/v1/panel/Panel_FrameBufferBase.hpp
+6 −7 src/lgfx/v1/panel/Panel_GC9A01.hpp
+1 −1 src/lgfx/v1/panel/Panel_GDEW0154M09.cpp
+118 −0 src/lgfx/v1/panel/Panel_ILI9806.hpp
+77 −45 src/lgfx/v1/panel/Panel_M5HDMI.cpp
+9 −4 src/lgfx/v1/panel/Panel_M5HDMI.hpp
+14,151 −14,736 src/lgfx/v1/panel/Panel_M5HDMI_FS.h
+1 −1 src/lgfx/v1/panel/Panel_RA8875.cpp
+1 −1 src/lgfx/v1/panel/Panel_RA8875.hpp
+10 −5 src/lgfx/v1/panel/Panel_SSD1306.cpp
+3 −0 src/lgfx/v1/panel/Panel_SSD1306.hpp
+8 −5 src/lgfx/v1/platforms/arduino_default/common.cpp
+4 −4 src/lgfx/v1/platforms/common.hpp
+5 −0 src/lgfx/v1/platforms/device.hpp
+31 −32 src/lgfx/v1/platforms/esp32/Bus_SPI.cpp
+1 −1 src/lgfx/v1/platforms/esp32/Bus_SPI.hpp
+31 −6 src/lgfx/v1/platforms/esp32/Light_PWM.cpp
+1 −1 src/lgfx/v1/platforms/esp32/Light_PWM.hpp
+1 −1 src/lgfx/v1/platforms/esp32/Panel_CVBS.cpp
+2 −4 src/lgfx/v1/platforms/esp32/Panel_CVBS.hpp
+280 −89 src/lgfx/v1/platforms/esp32/common.cpp
+107 −80 src/lgfx/v1/platforms/esp32/common.hpp
+14 −8 src/lgfx/v1/platforms/esp32s3/Bus_Parallel16.cpp
+13 −7 src/lgfx/v1/platforms/esp32s3/Bus_Parallel8.cpp
+3 −24 src/lgfx/v1/platforms/esp32s3/Panel_RGB.cpp
+77 −0 src/lgfx/v1/platforms/esp8266/common.hpp
+3 −3 src/lgfx/v1/platforms/rp2040/common.hpp
+78 −40 src/lgfx/v1/platforms/samd21/common.hpp
+48 −47 src/lgfx/v1/platforms/samd51/common.hpp
+58 −0 src/lgfx/v1/platforms/sdl/Bus_I2C.hpp
+300 −519 src/lgfx/v1/platforms/sdl/Panel_sdl.cpp
+51 −34 src/lgfx/v1/platforms/sdl/Panel_sdl.hpp
+4 −4 src/lgfx/v1/platforms/sdl/common.cpp
+11 −2 src/lgfx/v1/platforms/sdl/common.hpp
+29 −45 src/lgfx/v1/platforms/spresense/common.hpp
+35 −19 src/lgfx/v1/touch/Touch_CST816S.cpp
+4 −2 src/lgfx/v1/touch/Touch_CST816S.hpp
+70 −41 src/lgfx/v1_autodetect/LGFX_AutoDetect_ESP32_all.hpp
+4 −4 src/lgfx/v1_autodetect/common.hpp
+1 −0 src/lgfx/v1_init.hpp
+1 −0 src/lgfx_user/LGFX_ESP32_sample.hpp
+96 −0 src/lgfx_user/LGFX_Elecrow_ESP32_Display_DLC35010R.h
+105 −0 src/lgfx_user/LGFX_Elecrow_ESP32_Display_WZ8048C050.h
+105 −0 src/lgfx_user/LGFX_Elecrow_ESP32_Display_WZ8048C070.h
+122 −0 src/lgfx_user/LGFX_Makerfabs_MaTouchESP32S3ParallelTFTwithTouch7.h
+111 −0 src/lgfx_user/LGFX_Sunton_ESP32-8048S050.h
+111 −0 src/lgfx_user/LGFX_Sunton_ESP32-8048S070.h
2 changes: 1 addition & 1 deletion dependencies.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies:
component_hash: null
source:
type: idf
version: 5.1.0
version: 5.1.1
manifest_hash: 9275a596616c0a70cfe5b167d7bb0650aa90eb700c5b2ebe12470c3274692aa7
target: esp32s3
version: 1.0.0
34 changes: 21 additions & 13 deletions main/homekit/homekit_integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,24 @@ void homekit_integration::homekit_task_ftn()
auto iter = chars1_.find(id);
if (iter != chars1_.end())
{
hap_val_t h_value{};
h_value.f = get_sensor_value(id);
hap_char_update_val(iter->second, &h_value);
const auto value = get_sensor_value(id);
if (!std::isnan(value))
{
hap_val_t h_value{};
h_value.f = get_sensor_value(id);
hap_char_update_val(iter->second, &h_value);
}
}

if (id == air_quality_sensor_id)
{
hap_val_t h_value{};
h_value.u = get_air_quality();
hap_char_update_val(air_quality_char, &h_value);
const auto value = get_air_quality();
if (value.has_value())
{
hap_val_t h_value{};
h_value.u = value.value();
hap_char_update_val(air_quality_char, &h_value);
}
}
}
}
Expand Down Expand Up @@ -202,8 +210,9 @@ void homekit_integration::create_sensor_services_and_chars()
service = iter->second;
}

auto sensor_char = hap_char_float_create(const_cast<char *>(definition.get_cha_type_uuid().data()), HAP_CHAR_PERM_PR | HAP_CHAR_PERM_EV,
get_sensor_value(definition.get_sensor()));
const auto sensor_value = get_sensor_value(definition.get_sensor());
auto sensor_char =
hap_char_float_create(const_cast<char *>(definition.get_cha_type_uuid().data()), HAP_CHAR_PERM_PR | HAP_CHAR_PERM_EV, sensor_value);
CHECK_NULL_RESULT(service);

const auto sensor_def = get_sensor_definition(definition.get_sensor());
Expand All @@ -219,7 +228,7 @@ void homekit_integration::create_sensor_services_and_chars()
CHECK_HAP_RESULT(hap_serv_add_char(service, sensor_char));
}

air_quality_char = hap_char_air_quality_create(get_air_quality());
air_quality_char = hap_char_air_quality_create(get_air_quality().value_or(0));
CHECK_NULL_RESULT(air_quality_char);
static_assert(homekit_definitions[0].get_sensor() == air_quality_sensor_id);
CHECK_HAP_RESULT(hap_serv_add_char(services_[homekit_definitions[0].get_service_type_uuid()], air_quality_char));
Expand All @@ -230,19 +239,18 @@ void homekit_integration::create_sensor_services_and_chars()
}
}

uint8_t homekit_integration::get_air_quality()
std::optional<uint8_t> homekit_integration::get_air_quality()
{
const auto value = homekit_integration::get_instance().hardware_.get_sensor(air_quality_sensor_id).get_value();

if (!std::isnan(value))
if (std::isnan(value))
{
return 0; // unknown
return std::nullopt;
}
else
{
const auto sensor_def = get_sensor_definition(air_quality_sensor_id);
auto level = sensor_def.calculate_level(value);

return static_cast<uint8_t>(level);
}
}
Expand Down
3 changes: 2 additions & 1 deletion main/homekit/homekit_integration.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "util/task_wrapper.h"
#include <hap.h>
#include <map>
#include <optional>

class config;
class hardware;
Expand Down Expand Up @@ -58,7 +59,7 @@ class homekit_integration : public esp32::singleton<homekit_integration>
void generate_password();
static int sensor_read(hap_char_t *hc, hap_status_t *status_code, void *serv_priv, void *read_priv);
float get_sensor_value(sensor_id_index index);
static uint8_t get_air_quality();
static std::optional<uint8_t> get_air_quality();

constexpr static uint32_t task_notify_restarting_bit = BIT(total_sensors + 1);
};
Loading