├── spiffs_storage ├── config.json ├── favicon.ico ├── index.html ├── global.css ├── settings.json └── ota.html ├── components ├── lib8tion │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ ├── LICENSE │ └── lib8tion.c ├── color │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ ├── LICENSE │ └── hsv.h ├── noise │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ └── LICENSE ├── aht │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ └── LICENSE ├── scd4x │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ └── LICENSE ├── bmp180 │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ └── LICENSE ├── bmp280 │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ └── LICENSE ├── si7021 │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ └── LICENSE ├── esp_idf_lib_helpers │ ├── CMakeLists.txt │ ├── component.mk │ ├── .eil.yml │ ├── ets_sys.h │ ├── LICENSE │ └── esp_idf_lib_helpers.h ├── framebuffer │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ ├── fbanimation.h │ └── fbanimation.c ├── button │ ├── component.mk │ ├── .eil.yml │ ├── CMakeLists.txt │ ├── Kconfig │ ├── LICENSE │ └── button.h ├── i2cdev │ ├── component.mk │ ├── CMakeLists.txt │ ├── Kconfig │ ├── .eil.yml │ └── LICENSE └── dht │ ├── component.mk │ ├── CMakeLists.txt │ ├── .eil.yml │ ├── LICENSE │ └── dht.h ├── main ├── utils │ ├── common.c │ ├── send_data.h │ ├── json.h │ ├── spiffs.h │ ├── utils.h │ ├── utils.c │ ├── nvs.h │ ├── bus.h │ ├── bus.c │ ├── common.h │ ├── json.c │ └── spiffs.c ├── wifi │ ├── mqtt.h │ ├── wifi.h │ ├── webserver.h │ ├── embed.h │ ├── api.h │ └── webserver.c ├── modules │ ├── sensors │ │ ├── gpioOUT │ │ │ └── sensor_gpioOUT.h │ │ ├── dht │ │ │ ├── sensor_dht.h │ │ │ ├── info.json │ │ │ └── sensor_dht.c │ │ ├── gpioIN │ │ │ ├── sensor_gpioin.h │ │ │ ├── sensor_gpioin.c │ │ │ └── info.json │ │ ├── siht │ │ │ ├── sensor_siht.h │ │ │ ├── info.json │ │ │ └── sensor_siht.c │ │ ├── aht │ │ │ └── sensor_aht.h │ │ ├── bmp280 │ │ │ └── sensor_bmp280.h │ │ ├── scd4x │ │ │ ├── sensor_scd4x.h │ │ │ └── info.json │ │ ├── ds18b20 │ │ │ ├── sensor_ds18b20.h │ │ │ └── info.json │ │ └── _example │ │ │ ├── sensor_example.h │ │ │ ├── info.json │ │ │ └── sensor_example.c │ ├── exec │ │ └── led_light │ │ │ ├── led_light.h │ │ │ ├── crc16.h │ │ │ ├── light.h │ │ │ ├── led_light.c │ │ │ └── crc16.c │ ├── virtual │ │ ├── battery │ │ │ ├── battery.h │ │ │ └── info.json │ │ └── deepsleep │ │ │ ├── deepsleep.h │ │ │ └── info.json │ └── sensor_init.h ├── effects │ ├── lamp.h │ ├── input.h │ ├── matrix.h │ ├── wheel.h │ ├── rainbow.h │ ├── sparkles.h │ ├── lava.h │ ├── rain.h │ ├── whirls.h │ ├── dunes.h │ ├── hoop.h │ ├── relax.h │ ├── flower.h │ ├── diagonals.h │ ├── peacock.h │ ├── water.h │ ├── crazybees.h │ ├── dna.h │ ├── spaceships.h │ ├── sun.h │ ├── plasma_waves.h │ ├── fireflies.h │ ├── fire.h │ ├── rays.h │ ├── octopus.h │ ├── holiday.h │ ├── nuclear.h │ ├── twister.h │ ├── polar_lights.h │ ├── metaballs.h │ ├── surface.h │ ├── tunnel.h │ ├── lamp.c │ ├── waterfall.h │ ├── sparkles.c │ ├── hoop.c │ ├── peacock.c │ ├── flower.c │ ├── diagonals.c │ ├── rain.c │ ├── relax.c │ ├── water.c │ ├── fire.c │ ├── dunes.c │ ├── wheel.c │ ├── effect.h │ ├── rainbow.c │ ├── lava.c │ ├── tunnel.c │ ├── whirls.c │ ├── sun.c │ ├── polar_lights.c │ ├── dna.c │ ├── rays.c │ ├── config.h │ ├── octopus.c │ ├── crazybees.c │ ├── nuclear.c │ ├── metaballs.c │ ├── holiday.c │ ├── spaceships.c │ ├── twister.c │ ├── plasma_waves.c │ ├── input.c │ ├── palettes.c │ └── matrix.c ├── idf_component.yml ├── CMakeLists.txt ├── settings.h └── zigbee │ └── zigbee_init.h ├── sdkconfig.defaults ├── README.md ├── .gitmodules ├── CMakeLists.txt ├── .astylerc ├── partitions_2mb.csv ├── partitions_4mb.csv ├── partitions.csv ├── partitions_8mb.csv ├── .vscode ├── c_cpp_properties.json └── settings.json ├── .gitignore ├── LICENSE └── dependencies.lock /spiffs_storage/config.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /components/lib8tion/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | -------------------------------------------------------------------------------- /main/utils/common.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | const char *TAG = APP_NAME; 4 | -------------------------------------------------------------------------------- /sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_SOC_RMT_SUPPORTED=y 2 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -------------------------------------------------------------------------------- /main/utils/send_data.h: -------------------------------------------------------------------------------- 1 | void send_data(uint16_t sensor_val, int param_ep, char *cluster); -------------------------------------------------------------------------------- /components/color/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | COMPONENT_DEPENDS = lib8tion -------------------------------------------------------------------------------- /components/noise/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | COMPONENT_DEPENDS = lib8tion -------------------------------------------------------------------------------- /spiffs_storage/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyzroe/MEEF/main/spiffs_storage/favicon.ico -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Online zigbee firmware builder for ESP32 https://meef.ru/ Telegram https://t.me/live_control 2 | 3 | -------------------------------------------------------------------------------- /components/aht/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | COMPONENT_DEPENDS = i2cdev log esp_idf_lib_helpers 3 | -------------------------------------------------------------------------------- /components/scd4x/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | COMPONENT_DEPENDS = i2cdev log esp_idf_lib_helpers 3 | -------------------------------------------------------------------------------- /components/bmp180/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | COMPONENT_DEPENDS = i2cdev log esp_idf_lib_helpers 3 | -------------------------------------------------------------------------------- /components/bmp280/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | COMPONENT_DEPENDS = i2cdev log esp_idf_lib_helpers 3 | -------------------------------------------------------------------------------- /components/si7021/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | COMPONENT_DEPENDS = i2cdev log esp_idf_lib_helpers 3 | -------------------------------------------------------------------------------- /components/esp_idf_lib_helpers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register( 2 | INCLUDE_DIRS . 3 | REQUIRES freertos 4 | ) 5 | -------------------------------------------------------------------------------- /main/utils/json.h: -------------------------------------------------------------------------------- 1 | char *config_getString(char *key); 2 | int *config_getInt(char *key); 3 | bool *config_getBool(char *key); 4 | -------------------------------------------------------------------------------- /main/wifi/mqtt.h: -------------------------------------------------------------------------------- 1 | esp_err_t mqtt_app_start(void); 2 | void publis_status_mqtt(const char *topic, int EP, const char *deviceData); -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libs/esp-idf-lib"] 2 | path = libs/esp-idf-lib 3 | url = https://github.com/UncleRus/esp-idf-lib.git 4 | -------------------------------------------------------------------------------- /main/modules/sensors/gpioOUT/sensor_gpioOUT.h: -------------------------------------------------------------------------------- 1 | #include "cJSON.h" 2 | void sensor_gpioOUT(cJSON *sensor_json, int zigbee_init); 3 | -------------------------------------------------------------------------------- /components/noise/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register( 2 | SRCS noise.c 3 | INCLUDE_DIRS . 4 | REQUIRES lib8tion 5 | ) 6 | -------------------------------------------------------------------------------- /main/modules/exec/led_light/led_light.h: -------------------------------------------------------------------------------- 1 | void led_light(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); 2 | -------------------------------------------------------------------------------- /main/modules/sensors/dht/sensor_dht.h: -------------------------------------------------------------------------------- 1 | void sensor_dht(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); 2 | -------------------------------------------------------------------------------- /main/modules/sensors/gpioIN/sensor_gpioin.h: -------------------------------------------------------------------------------- 1 | void gpioin(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); 2 | -------------------------------------------------------------------------------- /main/modules/sensors/siht/sensor_siht.h: -------------------------------------------------------------------------------- 1 | void sensor_siht(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); -------------------------------------------------------------------------------- /main/modules/sensors/aht/sensor_aht.h: -------------------------------------------------------------------------------- 1 | 2 | void sensor_aht(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); 3 | -------------------------------------------------------------------------------- /main/modules/sensors/bmp280/sensor_bmp280.h: -------------------------------------------------------------------------------- 1 | void sensor_bmp280(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); -------------------------------------------------------------------------------- /main/modules/sensors/scd4x/sensor_scd4x.h: -------------------------------------------------------------------------------- 1 | void sensor_scd4x(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); 2 | -------------------------------------------------------------------------------- /main/modules/virtual/battery/battery.h: -------------------------------------------------------------------------------- 1 | void cluster_battery(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); 2 | -------------------------------------------------------------------------------- /components/aht/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register( 2 | SRCS aht.c 3 | INCLUDE_DIRS . 4 | REQUIRES i2cdev log esp_idf_lib_helpers 5 | ) 6 | -------------------------------------------------------------------------------- /main/modules/sensors/ds18b20/sensor_ds18b20.h: -------------------------------------------------------------------------------- 1 | void sensor_ds18b20(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); 2 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(PROJECT_VER 0.0.6) 4 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 5 | project(MEEF) 6 | -------------------------------------------------------------------------------- /components/framebuffer/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | COMPONENT_SRCDIRS = . led_effects 3 | COMPONENT_DEPENDS = log color lib8tion noise 4 | -------------------------------------------------------------------------------- /components/scd4x/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register( 2 | SRCS scd4x.c 3 | INCLUDE_DIRS . 4 | REQUIRES i2cdev log esp_idf_lib_helpers 5 | ) 6 | -------------------------------------------------------------------------------- /components/bmp180/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register( 2 | SRCS bmp180.c 3 | INCLUDE_DIRS . 4 | REQUIRES i2cdev log esp_idf_lib_helpers 5 | ) 6 | -------------------------------------------------------------------------------- /components/bmp280/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register( 2 | SRCS bmp280.c 3 | INCLUDE_DIRS . 4 | REQUIRES i2cdev log esp_idf_lib_helpers 5 | ) 6 | -------------------------------------------------------------------------------- /components/si7021/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register( 2 | SRCS si7021.c 3 | INCLUDE_DIRS . 4 | REQUIRES i2cdev log esp_idf_lib_helpers 5 | ) 6 | -------------------------------------------------------------------------------- /main/modules/sensors/_example/sensor_example.h: -------------------------------------------------------------------------------- 1 | 2 | void sensor_example(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); 3 | -------------------------------------------------------------------------------- /main/modules/exec/led_light/crc16.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC_H 2 | #define CRC_H 3 | 4 | #include 5 | 6 | uint16_t crc16(uint8_t *data, uint16_t length); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /components/framebuffer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register( 2 | SRCS framebuffer.c 3 | fbanimation.c 4 | INCLUDE_DIRS . 5 | REQUIRES log color 6 | ) 7 | -------------------------------------------------------------------------------- /components/button/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | 3 | ifdef CONFIG_IDF_TARGET_ESP8266 4 | COMPONENT_DEPENDS = esp8266 5 | else 6 | COMPONENT_DEPENDS = driver 7 | endif 8 | -------------------------------------------------------------------------------- /main/utils/spiffs.h: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | esp_err_t mount_storage(const char *base_path); 3 | void writeJSONtoFile(char fileName, char *json_data); 4 | void deleteFile(const char *fileName); -------------------------------------------------------------------------------- /main/wifi/wifi.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_WIFI_H_ 2 | #define MEEF_WIFI_H_ 3 | 4 | #include "../utils/common.h" 5 | #include 6 | 7 | esp_err_t wifi_init(); 8 | 9 | #endif /* MEEF_WIFI_H_ */ 10 | -------------------------------------------------------------------------------- /components/esp_idf_lib_helpers/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | 3 | ifdef CONFIG_IDF_TARGET_ESP8266 4 | COMPONENT_DEPENDS = esp8266 freertos 5 | else 6 | COMPONENT_DEPENDS = freertos 7 | endif 8 | 9 | -------------------------------------------------------------------------------- /main/wifi/webserver.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_WEBSERVER_H_ 2 | #define MEEF_WEBSERVER_H_ 3 | 4 | #include "../utils/common.h" 5 | #include 6 | 7 | esp_err_t webserver_restart(); 8 | 9 | #endif /* MEEF_WEBSERVER_H_ */ 10 | -------------------------------------------------------------------------------- /components/i2cdev/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | 3 | ifdef CONFIG_IDF_TARGET_ESP8266 4 | COMPONENT_DEPENDS = esp8266 freertos esp_idf_lib_helpers 5 | else 6 | COMPONENT_DEPENDS = driver freertos esp_idf_lib_helpers 7 | endif 8 | -------------------------------------------------------------------------------- /components/dht/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS = . 2 | 3 | ifdef CONFIG_IDF_TARGET_ESP8266 4 | COMPONENT_DEPENDS = esp8266 freertos log esp_idf_lib_helpers 5 | else 6 | COMPONENT_DEPENDS = driver freertos log esp_idf_lib_helpers 7 | endif 8 | -------------------------------------------------------------------------------- /main/utils/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_UTILS_H_ 2 | #define MEEF_UTILS_H_ 3 | 4 | int map(int x, int in_min, int in_max, int out_min, int out_max); 5 | 6 | float mapf(float x, float in_min, float in_max, float out_min, float out_max); 7 | 8 | #endif /* MEEF_UTILS_H_ */ 9 | -------------------------------------------------------------------------------- /.astylerc: -------------------------------------------------------------------------------- 1 | --style=bsd 2 | --indent=spaces=4 3 | --attach-extern-c 4 | --indent-classes 5 | --indent-switches 6 | --indent-cases 7 | --indent-col1-comments 8 | --min-conditional-indent=0 9 | --pad-oper 10 | --pad-header 11 | --align-pointer=name 12 | --lineend=linux 13 | -------------------------------------------------------------------------------- /main/wifi/embed.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_EMBED_H_ 2 | #define MEEF_EMBED_H_ 3 | 4 | #define DECLARE_EMBED(name) extern const char embed_##name[] asm("_binary_"#name"_start") 5 | 6 | DECLARE_EMBED(jquery_js); 7 | DECLARE_EMBED(styles_css); 8 | DECLARE_EMBED(index_html); 9 | 10 | #endif /* MEEF_EMBED_H_ */ 11 | -------------------------------------------------------------------------------- /components/dht/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${IDF_TARGET} STREQUAL esp8266) 2 | set(req esp8266 freertos log esp_idf_lib_helpers) 3 | else() 4 | set(req driver freertos log esp_idf_lib_helpers) 5 | endif() 6 | 7 | idf_component_register( 8 | SRCS dht.c 9 | INCLUDE_DIRS . 10 | REQUIRES ${req} 11 | ) 12 | -------------------------------------------------------------------------------- /components/i2cdev/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${IDF_TARGET} STREQUAL esp8266) 2 | set(req esp8266 freertos esp_idf_lib_helpers) 3 | else() 4 | set(req driver freertos esp_idf_lib_helpers) 5 | endif() 6 | 7 | idf_component_register( 8 | SRCS i2cdev.c 9 | INCLUDE_DIRS . 10 | REQUIRES ${req} 11 | ) 12 | -------------------------------------------------------------------------------- /components/lib8tion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${IDF_VERSION_MAJOR} STREQUAL 4 AND ${IDF_VERSION_MINOR} STREQUAL 1 AND ${IDF_VERSION_PATCH} STREQUAL 3) 2 | set(req) 3 | else() 4 | set(req esp_timer) 5 | endif() 6 | 7 | idf_component_register( 8 | INCLUDE_DIRS . 9 | SRCS lib8tion.c 10 | REQUIRES ${req} 11 | ) 12 | -------------------------------------------------------------------------------- /main/effects/lamp.h: -------------------------------------------------------------------------------- 1 | #ifndef __EFFECTS_LAMP_H__ 2 | #define __EFFECTS_LAMP_H__ 3 | 4 | #include "effect.h" 5 | 6 | extern EFFECT_PARAMS(lamp, 3); 7 | 8 | esp_err_t effect_lamp_run(framebuffer_t *fb); 9 | 10 | #define DESCR_EFFECT_LAMP DECL_EFFECT_SHORT(lamp, "Color lamp") 11 | 12 | #endif /* __EFFECTS_LAMP_H__ */ 13 | -------------------------------------------------------------------------------- /main/effects/input.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_INPUT_H_ 2 | #define MEEF_INPUT_H_ 3 | 4 | #include "../utils/common.h" 5 | 6 | enum 7 | { 8 | INPUT_BTN_MAIN = 0, 9 | INPUT_BTN_RESET, 10 | INPUT_BTN_UP, 11 | INPUT_BTN_DOWN, 12 | 13 | INPUT_BTN_MAX 14 | }; 15 | 16 | esp_err_t input_init(); 17 | 18 | #endif /* MEEF_INPUT_H_ */ 19 | -------------------------------------------------------------------------------- /main/modules/virtual/deepsleep/deepsleep.h: -------------------------------------------------------------------------------- 1 | #define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ 2 | #define ED_AGING_TIMEOUT ESP_ZB_ED_AGING_TIMEOUT_64MIN 3 | #define ED_KEEP_ALIVE 4000 /* 4000 millisecond */ 4 | void deep_sleep(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams); 5 | -------------------------------------------------------------------------------- /main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | # espressif/button: "^3.0.0" 4 | espressif/esp-zboss-lib: "~1.3.2" 5 | espressif/esp-zigbee-lib: "~1.3.2" 6 | espressif/led_strip: ">=2.0.0" 7 | espressif/ds18b20: "^0.1.1" 8 | espressif/onewire_bus: "^1.0.1" 9 | ## Required IDF version 10 | idf: 11 | version: ">=5.3" 12 | -------------------------------------------------------------------------------- /main/effects/matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef __EFFECTS_MATRIX_H__ 2 | #define __EFFECTS_MATRIX_H__ 3 | 4 | // FIXME: need to rewrite completely 5 | 6 | #include "effect.h" 7 | 8 | extern EFFECT_PARAMS(matrix, 1); 9 | 10 | esp_err_t effect_matrix_run(framebuffer_t *fb); 11 | 12 | #define DESCR_EFFECT_MATRIX DECL_EFFECT_SHORT(matrix, "Matrix") 13 | 14 | #endif /* __EFFECTS_MATRIX_H__ */ 15 | -------------------------------------------------------------------------------- /main/effects/wheel.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Radiant wheel effect 3 | */ 4 | #ifndef __EFFECTS_WHEEL_H__ 5 | #define __EFFECTS_WHEEL_H__ 6 | 7 | #include "effect.h" 8 | 9 | extern EFFECT_PARAMS(wheel, 6); 10 | 11 | esp_err_t effect_wheel_run(framebuffer_t *fb); 12 | 13 | #define DESCR_EFFECT_WHEEL DECL_EFFECT_SHORT(wheel, "Radiant wheel") 14 | 15 | #endif /* __EFFECTS_WHEEL_H__ */ 16 | -------------------------------------------------------------------------------- /components/button/.eil.yml: -------------------------------------------------------------------------------- 1 | name: button 2 | description: HW timer-based driver for GPIO buttons 3 | version: 1.0.0 4 | groups: 5 | - input 6 | code_owners: 7 | - UncleRus 8 | depends: 9 | - driver 10 | thread_safe: yes 11 | targets: 12 | - esp32 13 | - esp8266 14 | - esp32s2 15 | - esp32c3 16 | license: MIT 17 | copyrights: 18 | - name: UncleRus 19 | year: 2021 20 | -------------------------------------------------------------------------------- /main/effects/rainbow.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple rainbow effect 3 | */ 4 | #ifndef __EFFECTS_RAINBOW_H__ 5 | #define __EFFECTS_RAINBOW_H__ 6 | 7 | #include "effect.h" 8 | 9 | extern EFFECT_PARAMS(rainbow, 3); 10 | 11 | esp_err_t effect_rainbow_run(framebuffer_t *fb); 12 | 13 | #define DESCR_EFFECT_RAINBOW DECL_EFFECT_SHORT(rainbow, "Rainbow") 14 | 15 | #endif /* __EFFECTS_RAINBOW_H__ */ 16 | -------------------------------------------------------------------------------- /main/utils/utils.c: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | int map(int x, int in_min, int in_max, int out_min, int out_max) 4 | { 5 | return (out_max - out_min) * (x - in_min) / (in_max - in_min) + out_min; 6 | } 7 | 8 | float mapf(float x, float in_min, float in_max, float out_min, float out_max) 9 | { 10 | return (out_max - out_min) * (x - in_min) / (in_max - in_min) + out_min; 11 | } 12 | -------------------------------------------------------------------------------- /main/effects/sparkles.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Colored sparkles effect 3 | */ 4 | #ifndef __EFFECTS_SPARKLES_H__ 5 | #define __EFFECTS_SPARKLES_H__ 6 | 7 | #include "effect.h" 8 | 9 | extern EFFECT_PARAMS(sparkles, 2); 10 | 11 | esp_err_t effect_sparkles_run(framebuffer_t *fb); 12 | 13 | #define DESCR_EFFECT_SPARKLES DECL_EFFECT_SHORT(sparkles, "Sparkles") 14 | 15 | #endif /* __EFFECTS_SPARKLES_H__ */ 16 | -------------------------------------------------------------------------------- /main/effects/lava.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Perlin noise effect 3 | * 4 | * Author: Chuck Sommerville 5 | */ 6 | #ifndef __EFFECTS_LAVA_H__ 7 | #define __EFFECTS_LAVA_H__ 8 | 9 | #include "effect.h" 10 | 11 | extern EFFECT_PARAMS(lava, 4); 12 | 13 | esp_err_t effect_lava_run(framebuffer_t *fb); 14 | 15 | #define DESCR_EFFECT_LAVA DECL_EFFECT_SHORT(lava, "Lava") 16 | 17 | #endif /* __EFFECTS_LAVA_H__ */ 18 | -------------------------------------------------------------------------------- /components/button/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${IDF_TARGET} STREQUAL esp8266) 2 | set(req esp8266 esp_timer) 3 | elseif(${IDF_VERSION_MAJOR} STREQUAL 4 AND ${IDF_VERSION_MINOR} STREQUAL 1 AND ${IDF_VERSION_PATCH} STREQUAL 3) 4 | set(req driver) 5 | else() 6 | set(req driver esp_timer) 7 | endif() 8 | 9 | idf_component_register( 10 | SRCS button.c 11 | INCLUDE_DIRS . 12 | REQUIRES ${req} 13 | ) 14 | -------------------------------------------------------------------------------- /main/effects/rain.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Rain effect by Shaitan 3 | */ 4 | #ifndef __EFFECTS_RAIN_H__ 5 | #define __EFFECTS_RAIN_H__ 6 | 7 | #include "effect.h" 8 | 9 | extern EFFECT_PARAMS(rain, 4); 10 | 11 | esp_err_t effect_rain_prepare(framebuffer_t *fb); 12 | 13 | esp_err_t effect_rain_run(framebuffer_t *fb); 14 | 15 | #define DESCR_EFFECT_RAIN DECL_EFFECT_FULL(rain, "Rain") 16 | 17 | #endif /* __EFFECTS_RAIN_H__ */ 18 | -------------------------------------------------------------------------------- /components/color/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${IDF_VERSION_MAJOR} STREQUAL 4 AND ${IDF_VERSION_MINOR} STREQUAL 1 AND ${IDF_VERSION_PATCH} STREQUAL 3) 2 | message("Not including esp_timer in color") 3 | set(req lib8tion) 4 | else() 5 | message("Including esp_timer in color") 6 | set(req lib8tion) 7 | endif() 8 | 9 | idf_component_register( 10 | SRCS color.c 11 | INCLUDE_DIRS . 12 | REQUIRES ${req} 13 | ) 14 | -------------------------------------------------------------------------------- /main/effects/whirls.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Whirls effect by SottNick 3 | */ 4 | #ifndef __EFFECTS_WHIRLS_H__ 5 | #define __EFFECTS_WHIRLS_H__ 6 | 7 | #include "effect.h" 8 | 9 | extern EFFECT_PARAMS(whirls, 5); 10 | 11 | esp_err_t effect_whirls_prepare(framebuffer_t *fb); 12 | 13 | esp_err_t effect_whirls_run(framebuffer_t *fb); 14 | 15 | #define DESCR_EFFECT_WHIRLS DECL_EFFECT_FULL(whirls, "Whirls") 16 | 17 | #endif /* __EFFECTS_WHIRLS_H__ */ 18 | -------------------------------------------------------------------------------- /main/effects/dunes.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Colored dunes (AA lines) 3 | * 4 | * Author: costyn (https://wokwi.com/projects/284541784463245837) 5 | */ 6 | #ifndef __EFFECTS_DUNES_H__ 7 | #define __EFFECTS_DUNES_H__ 8 | 9 | #include "effect.h" 10 | 11 | extern EFFECT_PARAMS(dunes, 2); 12 | 13 | esp_err_t effect_dunes_run(framebuffer_t *fb); 14 | 15 | #define DESCR_EFFECT_DUNES DECL_EFFECT_SHORT(dunes, "Colored dunes") 16 | 17 | #endif /* __EFFECTS_DUNES_H__ */ 18 | -------------------------------------------------------------------------------- /main/effects/hoop.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Color hoop 3 | * 4 | * https://wokwi.com/arduino/projects/297414039372300810 5 | * 6 | * max framebuffer size 256x256 7 | */ 8 | #ifndef __EFFECTS_HOOP_H__ 9 | #define __EFFECTS_HOOP_H__ 10 | 11 | #include "effect.h" 12 | 13 | extern EFFECT_PARAMS(hoop, 1); 14 | 15 | esp_err_t effect_hoop_run(framebuffer_t *fb); 16 | 17 | #define DESCR_EFFECT_HOOP DECL_EFFECT_SHORT(hoop, "Hoop") 18 | 19 | #endif /* __EFFECTS_HOOP_H__ */ 20 | -------------------------------------------------------------------------------- /spiffs_storage/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | project MEEF 0.0.6 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /components/aht/.eil.yml: -------------------------------------------------------------------------------- 1 | name: aht 2 | description: Driver for AHT10/AHT15/AHT20 temperature and humidity sensor 3 | version: 1.0.0 4 | groups: 5 | - temperature 6 | - humidity 7 | code_owners: 8 | - UncleRus 9 | depends: 10 | - i2cdev 11 | - log 12 | - esp_idf_lib_helpers 13 | thread_safe: yes 14 | targets: 15 | - esp32 16 | - esp8266 17 | - esp32s2 18 | - esp32c3 19 | license: BSD-3 20 | copyrights: 21 | - name: UncleRus 22 | year: 2021 23 | -------------------------------------------------------------------------------- /main/effects/relax.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Light soft color change 3 | * 4 | * Author: Julia Uss 5 | */ 6 | #ifndef __EFFECTS_RELAX_H__ 7 | #define __EFFECTS_RELAX_H__ 8 | 9 | #include "effect.h" 10 | 11 | extern EFFECT_PARAMS(relax, 4); 12 | 13 | esp_err_t effect_relax_prepare(framebuffer_t *fb); 14 | 15 | esp_err_t effect_relax_run(framebuffer_t *fb); 16 | 17 | #define DESCR_EFFECT_RELAX DECL_EFFECT_FULL(relax, "Relax") 18 | 19 | #endif /* __EFFECTS_RELAX_H__ */ 20 | -------------------------------------------------------------------------------- /main/effects/flower.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Flower effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | */ 6 | #ifndef __EFFECTS_FLOWER_H__ 7 | #define __EFFECTS_FLOWER_H__ 8 | 9 | #include "effect.h" 10 | 11 | extern EFFECT_PARAMS(flower, 2); 12 | 13 | esp_err_t effect_flower_run(framebuffer_t *fb); 14 | 15 | #define DESCR_EFFECT_FLOWER DECL_EFFECT_SHORT(flower, "Flower") 16 | 17 | #endif /* __EFFECTS_FLOWER_H__ */ 18 | -------------------------------------------------------------------------------- /main/modules/exec/led_light/light.h: -------------------------------------------------------------------------------- 1 | #ifndef LIGHT_H 2 | #define LIGHT_H 3 | 4 | #include 5 | 6 | typedef struct light_data_s 7 | { 8 | uint8_t status; 9 | uint8_t level; 10 | uint8_t color_h; 11 | uint8_t color_s; 12 | uint16_t color_x; 13 | uint16_t color_y; 14 | uint8_t color_mode; 15 | uint16_t crc; 16 | } light_data_t; 17 | 18 | void light_init(light_data_t *data, int pin); 19 | void light_update(); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /components/i2cdev/Kconfig: -------------------------------------------------------------------------------- 1 | menu "I2C" 2 | 3 | config I2CDEV_TIMEOUT 4 | int "I2C transaction timeout, milliseconds" 5 | default 1000 6 | range 10 5000 7 | 8 | config I2CDEV_NOLOCK 9 | bool "Disable the use of mutexes" 10 | default n 11 | help 12 | Attention! After enabling this option, all I2C device 13 | drivers will become non-thread safe. 14 | Use this option if you need to access your I2C devices 15 | from interrupt handlers. 16 | 17 | endmenu -------------------------------------------------------------------------------- /partitions_2mb.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, , 600K, 6 | zb_storage, data, fat, , 16K, 7 | zb_fct, data, fat, , 1K, 8 | ota_0, app, ota_0, , 600K, 9 | storage, data, spiffs, , 128K, -------------------------------------------------------------------------------- /components/scd4x/.eil.yml: -------------------------------------------------------------------------------- 1 | name: scd4x 2 | description: Driver for SCD40/SCD41 miniature CO₂ sensor 3 | version: 1.0.0 4 | groups: 5 | - gas 6 | - air-quality 7 | code_owners: UncleRus 8 | depends: 9 | - i2cdev 10 | - log 11 | - esp_idf_lib_helpers 12 | thread_safe: yes 13 | targets: 14 | - esp32 15 | - esp8266 16 | - esp32s2 17 | - esp32c3 18 | license: BSD-3 19 | copyrights: 20 | - name: UncleRus 21 | year: 2021 22 | - name: Sensirion 23 | year: 2021 24 | -------------------------------------------------------------------------------- /components/bmp180/.eil.yml: -------------------------------------------------------------------------------- 1 | name: bmp180 2 | description: Driver for BMP180 digital pressure sensor 3 | version: 1.0.0 4 | groups: 5 | - pressure 6 | - temperature 7 | code_owners: 8 | - UncleRus 9 | depends: 10 | - i2cdev 11 | - log 12 | - esp_idf_lib_helpers 13 | thread_safe: yes 14 | targets: 15 | - esp32 16 | - esp8266 17 | - esp32s2 18 | - esp32c3 19 | license: MIT 20 | copyrights: 21 | - name: FrankB 22 | year: 2015 23 | - name: UncleRus 24 | year: 2018 25 | -------------------------------------------------------------------------------- /main/effects/diagonals.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Diagonal movements effect by SottNick 3 | */ 4 | #ifndef __EFFECTS_DIAGONALS_H__ 5 | #define __EFFECTS_DIAGONALS_H__ 6 | 7 | #include "effect.h" 8 | 9 | extern EFFECT_PARAMS(diagonals, 1); 10 | 11 | esp_err_t effect_diagonals_prepare(framebuffer_t *fb); 12 | 13 | esp_err_t effect_diagonals_run(framebuffer_t *fb); 14 | 15 | #define DESCR_EFFECT_DIAGONALS DECL_EFFECT_FULL(diagonals, "Diagonal movements") 16 | 17 | #endif /* __EFFECTS_DIAGONALS_H__ */ 18 | -------------------------------------------------------------------------------- /main/effects/peacock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Peacock (sin plasma) effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | */ 6 | #ifndef __EFFECTS_PEACOCK_H__ 7 | #define __EFFECTS_PEACOCK_H__ 8 | 9 | #include "effect.h" 10 | 11 | extern EFFECT_PARAMS(peacock, 3); 12 | 13 | esp_err_t effect_peacock_run(framebuffer_t *fb); 14 | 15 | #define DESCR_EFFECT_PEACOCK DECL_EFFECT_SHORT(peacock, "Peacock tail") 16 | 17 | #endif /* __EFFECTS_PEACOCK_H__ */ 18 | -------------------------------------------------------------------------------- /main/effects/water.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Water surface effect 3 | * 4 | * https://wokwi.com/arduino/projects/287787908971102732 5 | */ 6 | #ifndef __EFFECTS_WATER_H__ 7 | #define __EFFECTS_WATER_H__ 8 | 9 | #include "effect.h" 10 | 11 | extern EFFECT_PARAMS(water, 3); 12 | 13 | esp_err_t effect_water_prepare(framebuffer_t *fb); 14 | 15 | esp_err_t effect_water_run(framebuffer_t *fb); 16 | 17 | #define DESCR_EFFECT_WATER DECL_EFFECT_FULL(water, "Water") 18 | 19 | #endif /* __EFFECTS_WATER_H__ */ 20 | -------------------------------------------------------------------------------- /components/bmp280/.eil.yml: -------------------------------------------------------------------------------- 1 | name: bmp280 2 | description: Driver for BMP280/BME280 digital pressure sensor 3 | version: 1.0.0 4 | groups: 5 | - pressure 6 | - temperature 7 | code_owners: 8 | - UncleRus 9 | depends: 10 | - i2cdev 11 | - log 12 | - esp_idf_lib_helpers 13 | thread_safe: yes 14 | targets: 15 | - esp32 16 | - esp8266 17 | - esp32s2 18 | - esp32c3 19 | license: MIT 20 | copyrights: 21 | - name: sheinz 22 | year: 2016 23 | - name: UncleRus 24 | year: 2018 25 | -------------------------------------------------------------------------------- /main/effects/crazybees.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Crazy Bees effect 3 | * 4 | * Author: Stepko 5 | */ 6 | #ifndef __EFFECTS_CRAZYBEES_H__ 7 | #define __EFFECTS_CRAZYBEES_H__ 8 | 9 | #include "effect.h" 10 | 11 | extern EFFECT_PARAMS(crazybees, 3); 12 | 13 | esp_err_t effect_crazybees_prepare(framebuffer_t *fb); 14 | 15 | esp_err_t effect_crazybees_run(framebuffer_t *fb); 16 | 17 | #define DESCR_EFFECT_CRAZYBEES DECL_EFFECT_FULL(crazybees, "Crazy bees") 18 | 19 | #endif /* __LED_EFFECTS_CRAZYBEES_H__ */ 20 | -------------------------------------------------------------------------------- /components/noise/.eil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | components: 3 | - name: noise 4 | description: Noise generation functions 5 | group: common 6 | groups: [] 7 | code_owners: UncleRus 8 | depends: 9 | - lib8tion 10 | thread_safe: N/A 11 | targets: 12 | - name: esp32 13 | - name: esp8266 14 | - name: esp32s2 15 | - name: esp32c3 16 | licenses: 17 | - name: MIT 18 | copyrights: 19 | - author: 20 | name: FastLED 21 | year: 2013 22 | -------------------------------------------------------------------------------- /components/si7021/.eil.yml: -------------------------------------------------------------------------------- 1 | name: si7021 2 | description: Driver for Si7013/Si7020/Si7021/HTU2xD/SHT2x and compatible temperature and humidity sensors 3 | version: 1.0.1 4 | groups: 5 | - temperature 6 | - humidity 7 | code_owners: UncleRus 8 | depends: 9 | - i2cdev 10 | - log 11 | - esp_idf_lib_helpers 12 | thread_safe: yes 13 | targets: 14 | - esp32 15 | - esp32c3 16 | - esp8266 17 | - esp32s2 18 | - esp32c3 19 | license: BSD-3 20 | copyrights: 21 | - name: UncleRus 22 | year: 2019 23 | -------------------------------------------------------------------------------- /main/effects/dna.h: -------------------------------------------------------------------------------- 1 | /** 2 | * DNA helix effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | * 6 | * Max supported framebuffer size is 256x256 7 | */ 8 | #ifndef __EFFECTS_DNA_H__ 9 | #define __EFFECTS_DNA_H__ 10 | 11 | #include "effect.h" 12 | 13 | extern EFFECT_PARAMS(dna, 3); 14 | 15 | esp_err_t effect_dna_run(framebuffer_t *fb); 16 | 17 | #define DESCR_EFFECT_DNA DECL_EFFECT_SHORT(dna, "DNA helix") 18 | 19 | #endif /* __EFFECTS_DNA_H__ */ 20 | -------------------------------------------------------------------------------- /main/effects/spaceships.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Flight of spaceships effect 3 | * 4 | * Author: stepko 5 | * https://wokwi.com/projects/289609636203463176 6 | */ 7 | #ifndef __EFFECTS_SPACESHIPS_H__ 8 | #define __EFFECTS_SPACESHIPS_H__ 9 | 10 | #include "effect.h" 11 | 12 | extern EFFECT_PARAMS(spaceships, 2); 13 | 14 | esp_err_t effect_spaceships_run(framebuffer_t *fb); 15 | 16 | #define DESCR_EFFECT_SPACESHIPS DECL_EFFECT_SHORT(spaceships, "Flight of spaceships") 17 | 18 | #endif /* __EFFECTS_SPACESHIPS_H__ */ 19 | -------------------------------------------------------------------------------- /components/framebuffer/.eil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | components: 3 | - name: framebuffer 4 | description: RGB framebuffer component 5 | group: common 6 | groups: [] 7 | code_owners: UncleRus 8 | depends: 9 | - name: log 10 | - name: color 11 | thread_safe: N/A 12 | targets: 13 | - name: esp32 14 | - name: esp32s2 15 | - name: esp32c3 16 | licenses: 17 | - name: MIT 18 | copyrights: 19 | - author: 20 | name: UncleRus 21 | year: 2021 22 | -------------------------------------------------------------------------------- /main/effects/sun.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Sun radiation effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | */ 6 | #ifndef __EFFECTS_SUN_H__ 7 | #define __EFFECTS_SUN_H__ 8 | 9 | #include "effect.h" 10 | 11 | extern EFFECT_PARAMS(sun, 2); 12 | 13 | esp_err_t effect_sun_prepare(framebuffer_t *fb); 14 | 15 | esp_err_t effect_sun_run(framebuffer_t *fb); 16 | 17 | #define DESCR_EFFECT_SUN DECL_EFFECT_FULL(sun, "Sun radiation") 18 | 19 | #endif /* __EFFECTS_SUN_H__ */ 20 | -------------------------------------------------------------------------------- /components/lib8tion/.eil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | components: 3 | - name: lib8tion 4 | description: Math functions specifically designed for LED programming 5 | group: common 6 | groups: [] 7 | code_owners: UncleRus 8 | depends: [] 9 | thread_safe: N/A 10 | targets: 11 | - name: esp32 12 | - name: esp8266 13 | - name: esp32s2 14 | - name: esp32c3 15 | licenses: 16 | - name: MIT 17 | copyrights: 18 | - author: 19 | name: FastLED 20 | year: 2013 21 | -------------------------------------------------------------------------------- /components/color/.eil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | components: 3 | - name: color 4 | description: | 5 | Common library for RGB and HSV colors 6 | group: common 7 | groups: [] 8 | code_owners: 9 | - name: UncleRus 10 | depends: 11 | - name: lib8tion 12 | thread_safe: N/A 13 | targets: 14 | - name: esp32 15 | - name: esp8266 16 | - name: esp32s2 17 | - name: esp32c3 18 | licenses: 19 | - name: MIT 20 | copyrights: 21 | - name: FastLED 22 | year: 2013 23 | -------------------------------------------------------------------------------- /components/dht/.eil.yml: -------------------------------------------------------------------------------- 1 | name: dht 2 | description: Driver for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321), Itead Si7021 3 | version: 1.1.0 4 | groups: 5 | - humidity 6 | - temperature 7 | code_owners: 8 | - UncleRus 9 | depends: 10 | - log 11 | - esp_idf_lib_helpers 12 | - freertos 13 | - driver 14 | thread_safe: no 15 | targets: 16 | - esp32 17 | - esp8266 18 | - esp32s2 19 | - esp32c3 20 | license: BSD-3 21 | copyrights: 22 | - name: UncleRus 23 | year: 2018 24 | - name: jsuiker 25 | year: 2016 26 | -------------------------------------------------------------------------------- /main/effects/plasma_waves.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Plasma waves effect 3 | * 4 | * Author: Edmund "Skorn" Horn 5 | */ 6 | #ifndef __EFFECTS_PLASMA_WAVES_H__ 7 | #define __EFFECTS_PLASMA_WAVES_H__ 8 | 9 | #include "effect.h" 10 | 11 | extern EFFECT_PARAMS(plasma_waves, 1); 12 | 13 | esp_err_t effect_plasma_waves_prepare(framebuffer_t *fb); 14 | 15 | esp_err_t effect_plasma_waves_run(framebuffer_t *fb); 16 | 17 | #define DESCR_EFFECT_PLASMA_WAVES DECL_EFFECT_FULL(plasma_waves, "Plasma waves") 18 | 19 | #endif /* __EFFECTS_PLASMA_WAVES_H__ */ 20 | -------------------------------------------------------------------------------- /main/effects/fireflies.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Fireflies (wind) effect 3 | * 4 | * Author: stepko 5 | * https://wokwi.com/projects/289974688028819977 6 | */ 7 | #ifndef __EFFECTS_FIREFLIES_H__ 8 | #define __EFFECTS_FIREFLIES_H__ 9 | 10 | #include "effect.h" 11 | 12 | extern EFFECT_PARAMS(fireflies, 4); 13 | 14 | esp_err_t effect_fireflies_prepare(framebuffer_t *fb); 15 | 16 | esp_err_t effect_fireflies_run(framebuffer_t *fb); 17 | 18 | #define DESCR_EFFECT_FIREFLIES DECL_EFFECT_FULL(fireflies, "Fireflies") 19 | 20 | #endif /* __EFFECTS_FIREFLIES_H__ */ 21 | -------------------------------------------------------------------------------- /partitions_4mb.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap 3 | nvs, data, nvs, , 0x6000, 4 | otadata, data, ota, , 0x2000, 5 | phy_init, data, phy, , 0x1000, 6 | zb_storage, data, fat, , 16K, 7 | zb_fct, data, fat, , 1K, 8 | ota_0, app, ota_0, , 1700K, 9 | ota_1, app, ota_1, , 1700K, 10 | storage, data, spiffs, , 500K, 11 | 12 | -------------------------------------------------------------------------------- /partitions.csv: -------------------------------------------------------------------------------- 1 | # ESP-IDF Partition Table 2 | # Name, Type, SubType, Offset, Size, Flags 3 | #nvs, data, nvs, 0x9000, 0x6000 4 | #phy_init, data, phy, 0xf000, 0x1000 5 | #factory, app, factory, 0x10000, 3M 6 | 7 | nvs, data, nvs, 0x9000, 0x4000 8 | otadata, data, ota, 0xd000, 0x2000 9 | phy_init, data, phy, 0xf000, 0x1000 10 | factory, app, factory, 0x10000, 0x150000 11 | ota_0, app, ota_0, , 0x150000 12 | #nvs_key, data, nvs_keys, , 0x1000 13 | storage, data, spiffs, , 200K, 14 | -------------------------------------------------------------------------------- /partitions_8mb.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap 3 | nvs, data, nvs, , 0x6000, 4 | otadata, data, ota, , 0x2000, 5 | phy_init, data, phy, , 0x1000, 6 | zb_storage, data, fat, , 16K, 7 | zb_fct, data, fat, , 1K, 8 | ota_0, app, ota_0, , 3000K, 9 | ota_1, app, ota_1, , 3000K, 10 | storage, data, spiffs, , 2000K, 11 | 12 | -------------------------------------------------------------------------------- /main/effects/fire.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Fire effect based on Perlin noise 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | * 6 | * https://pastebin.com/jSSVSRi6 7 | */ 8 | #ifndef __EFFECTS_FIRE_H__ 9 | #define __EFFECTS_FIRE_H__ 10 | 11 | #include "effect.h" 12 | 13 | extern EFFECT_PARAMS(fire, 2); 14 | 15 | esp_err_t effect_fire_prepare(framebuffer_t *fb); 16 | 17 | esp_err_t effect_fire_run(framebuffer_t *fb); 18 | 19 | #define DESCR_EFFECT_FIRE DECL_EFFECT_FULL(fire, "Fire") 20 | 21 | #endif /* __EFFECTS_FIRE_H__ */ 22 | -------------------------------------------------------------------------------- /main/effects/rays.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Colored rays effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | * https://editor.soulmatelights.com/gallery/819-colored-bursts 6 | * 7 | * Max supported framebuffer size is 256x256 8 | */ 9 | #ifndef __EFFECTS_RAYS_H__ 10 | #define __EFFECTS_RAYS_H__ 11 | 12 | #include "effect.h" 13 | 14 | extern EFFECT_PARAMS(rays, 3); 15 | 16 | esp_err_t effect_rays_run(framebuffer_t *fb); 17 | 18 | #define DESCR_EFFECT_RAYS DECL_EFFECT_SHORT(rays, "Rays") 19 | 20 | #endif /* __EFFECTS_RAYS_H__ */ 21 | -------------------------------------------------------------------------------- /components/esp_idf_lib_helpers/.eil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | components: 3 | - name: esp_idf_lib_helpers 4 | description: | 5 | Common support library for esp-idf-lib 6 | group: common 7 | groups: [] 8 | code_owners: 9 | - name: UncleRus 10 | - name: trombik 11 | depends: 12 | - name: freertos 13 | thread_safe: N/A 14 | targets: 15 | - name: esp32 16 | - name: esp8266 17 | - name: esp32s2 18 | - name: esp32c3 19 | licenses: 20 | - name: ISC 21 | copyrights: 22 | - name: trombik 23 | year: 2019 24 | -------------------------------------------------------------------------------- /main/effects/octopus.h: -------------------------------------------------------------------------------- 1 | /** 2 | * "Octopus" 3 | * 4 | * Author: Stepko 5 | * https://editor.soulmatelights.com/gallery/671-octopus 6 | * 7 | * Note: only even-sized framebuffers are supported 8 | */ 9 | #ifndef __EFFECTS_OCTOPUS_H__ 10 | #define __EFFECTS_OCTOPUS_H__ 11 | 12 | #include "effect.h" 13 | 14 | extern EFFECT_PARAMS(octopus, 3); 15 | 16 | esp_err_t effect_octopus_prepare(framebuffer_t *fb); 17 | 18 | esp_err_t effect_octopus_run(framebuffer_t *fb); 19 | 20 | #define DESCR_EFFECT_OCTOPUS DECL_EFFECT_FULL(octopus, "Octopus") 21 | 22 | #endif /* __EFFECTS_OCTOPUS_H__ */ 23 | -------------------------------------------------------------------------------- /components/i2cdev/.eil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | components: 3 | - name: i2cdev 4 | description: | 5 | ESP-IDF I2C master thread-safe utilities 6 | group: common 7 | groups: [] 8 | code_owners: 9 | - name: UncleRus 10 | depends: 11 | - name: driver 12 | - name: freertos 13 | - name: esp_idf_lib_helpers 14 | thread_safe: yes 15 | targets: 16 | - name: esp32 17 | - name: esp8266 18 | - name: esp32s2 19 | - name: esp32c3 20 | licenses: 21 | - name: MIT 22 | copyrights: 23 | - name: UncleRus 24 | year: 2018 25 | -------------------------------------------------------------------------------- /main/effects/holiday.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Holiday lights 3 | * 4 | * Author: stepko 5 | * 6 | * https://wokwi.com/arduino/projects/287698321325163021 7 | */ 8 | #ifndef __EFFECTS_HOLIDAY_H__ 9 | #define __EFFECTS_HOLIDAY_H__ 10 | 11 | #include "effect.h" 12 | 13 | extern EFFECT_PARAMS(holiday, 2); 14 | 15 | enum { 16 | HOLIDAY_WAVE = 0, 17 | HOLIDAY_RADAR, 18 | HOLIDAY_SPARKS, 19 | HOLIDAY_TREE, 20 | }; 21 | 22 | esp_err_t effect_holiday_run(framebuffer_t *fb); 23 | 24 | #define DESCR_EFFECT_HOLIDAY DECL_EFFECT_SHORT(holiday, "Holiday lights") 25 | 26 | #endif /* __EFFECTS_HOLIDAY_H__ */ 27 | -------------------------------------------------------------------------------- /main/effects/nuclear.h: -------------------------------------------------------------------------------- 1 | /** 2 | * "Nuclear Noise" 3 | * 4 | * Author: Stepko 5 | * https://editor.soulmatelights.com/gallery/1569-radialnuclearnoise 6 | * 7 | * Note: only even-sized framebuffers are supported 8 | */ 9 | #ifndef __EFFECTS_NUCLEAR_H__ 10 | #define __EFFECTS_NUCLEAR_H__ 11 | 12 | #include "effect.h" 13 | 14 | extern EFFECT_PARAMS(nuclear, 1); 15 | 16 | esp_err_t effect_nuclear_prepare(framebuffer_t *fb); 17 | 18 | esp_err_t effect_nuclear_run(framebuffer_t *fb); 19 | 20 | #define DESCR_EFFECT_NUCLEAR DECL_EFFECT_FULL(nuclear, "Nuclear Noise") 21 | 22 | #endif /* __EFFECTS_NUCLEAR_H__ */ 23 | -------------------------------------------------------------------------------- /main/effects/twister.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Oldschool twister demo effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | * 6 | * https://wokwi.com/arduino/projects/297732081748804105 7 | * 8 | * Max supported framebuffer size is 256x256 9 | */ 10 | #ifndef __EFFECTS_TWISTER_H__ 11 | #define __EFFECTS_TWISTER_H__ 12 | 13 | #include "effect.h" 14 | 15 | extern EFFECT_PARAMS(twister, 3); 16 | 17 | esp_err_t effect_twister_run(framebuffer_t *fb); 18 | 19 | #define DESCR_EFFECT_TWISTER DECL_EFFECT_SHORT(twister, "Twister") 20 | 21 | #endif /* __EFFECTS_TWISTER_H__ */ 22 | -------------------------------------------------------------------------------- /components/button/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Button" 2 | 3 | config BUTTON_MAX 4 | int "Maximum number of buttons" 5 | range 1 10 6 | default 5 7 | 8 | config BUTTON_POLL_TIMEOUT 9 | int "Poll timeout, ms" 10 | range 1 1000 11 | default 10 12 | 13 | config BUTTON_LONG_PRESS_TIMEOUT 14 | int "Timeout of long press, ms" 15 | range 100 10000 16 | default 1000 17 | 18 | config BUTTON_AUTOREPEAT_TIMEOUT 19 | int "Timeout before autorepeat, ms" 20 | range 100 10000 21 | default 500 22 | 23 | config BUTTON_AUTOREPEAT_INTERVAL 24 | int "Autorepeat interval, ms" 25 | range 100 10000 26 | default 250 27 | 28 | endmenu -------------------------------------------------------------------------------- /main/effects/polar_lights.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Polar lights effect 3 | * 4 | * Author: Kostyantyn Matviyevskyy kostyamat 05.02.2021 5 | * 6 | * https://editor.soulmatelights.com/gallery/762-polar-lights 7 | */ 8 | #ifndef __EFFECTS_POLAR_LIGHTS_H__ 9 | #define __EFFECTS_POLAR_LIGHTS_H__ 10 | 11 | #include "effect.h" 12 | 13 | extern EFFECT_PARAMS(polar_lights, 4); 14 | 15 | esp_err_t effect_polar_lights_prepare(framebuffer_t *fb); 16 | 17 | esp_err_t effect_polar_lights_run(framebuffer_t *fb); 18 | 19 | #define DESCR_EFFECT_POLAR_LIGHTS DECL_EFFECT_FULL(polar_lights, "Polar lights") 20 | 21 | #endif /* __EFFECTS_POLAR_LIGHTS_H__ */ 22 | -------------------------------------------------------------------------------- /main/effects/metaballs.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Metaballs effect 3 | * 4 | * Author: Yaroslaw Turbin 02.09.2020 (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | * 6 | * https://wokwi.com/arduino/libraries/FastLED/Metaballs 7 | */ 8 | #ifndef __EFFECTS_METABALLS_H__ 9 | #define __EFFECTS_METABALLS_H__ 10 | 11 | #include "effect.h" 12 | 13 | extern EFFECT_PARAMS(metaballs, 2); 14 | 15 | esp_err_t effect_metaballs_prepare(framebuffer_t *fb); 16 | 17 | esp_err_t effect_metaballs_run(framebuffer_t *fb); 18 | 19 | #define DESCR_EFFECT_METABALLS DECL_EFFECT_FULL(metaballs, "Metaballs") 20 | 21 | #endif /* __EFFECTS_METABALLS_H__ */ 22 | -------------------------------------------------------------------------------- /main/modules/sensor_init.h: -------------------------------------------------------------------------------- 1 | /* Объявляется структура передаваемых параметров */ 2 | typedef struct 3 | { 4 | int param_pin; 5 | int param_pin_SCL; 6 | int param_pin_SDA; 7 | int param_I2C_GND; 8 | char *param_I2C_ADDRESS; 9 | int param_ep; 10 | int param_int; 11 | int param_index; 12 | char *param_addr; 13 | int param_saveState; 14 | char *param_cluster; 15 | char *param_id; 16 | char *param_sensor_type; 17 | int param_before_sleep; 18 | int param_sleep_length; 19 | int param_before_long_sleep; 20 | int param_long_sleep_length; 21 | } TaskParameters; 22 | void sensor_init(void); 23 | -------------------------------------------------------------------------------- /main/effects/surface.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_SURFACE_H_ 2 | #define MEEF_SURFACE_H_ 3 | 4 | #include "../utils/common.h" 5 | 6 | esp_err_t surface_init(); 7 | 8 | esp_err_t surface_prepare_effect(size_t effect); 9 | 10 | bool surface_is_playing(); 11 | 12 | esp_err_t surface_pause(); 13 | 14 | esp_err_t surface_stop(); 15 | 16 | esp_err_t surface_play(); 17 | 18 | esp_err_t surface_set_effect(size_t num); 19 | 20 | esp_err_t surface_next_effect(); 21 | 22 | esp_err_t surface_set_brightness(uint8_t val); 23 | 24 | esp_err_t surface_increment_brightness(int8_t val); 25 | 26 | esp_err_t surface_set_fps(uint8_t val); 27 | 28 | #endif /* MEEF_SURFACE_H_ */ 29 | -------------------------------------------------------------------------------- /main/effects/tunnel.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Tunnel effect 3 | * 4 | * Original Lua/TIC-80 source was live-coded in 25 minutes by exoticorn during a 256-byte battle 5 | * at outlinedemoparty.nl 2021-05-15 6 | * 7 | * Author: exoticorn, Ported by: sutarobosu (https://wokwi.com/projects/332710874737279572) 8 | */ 9 | #ifndef __EFFECTS_TUNNEL_H__ 10 | #define __EFFECTS_TUNNEL_H__ 11 | 12 | #include "effect.h" 13 | 14 | extern EFFECT_PARAMS(tunnel, 1); 15 | 16 | esp_err_t effect_tunnel_prepare(framebuffer_t *fb); 17 | 18 | esp_err_t effect_tunnel_run(framebuffer_t *fb); 19 | 20 | #define DESCR_EFFECT_TUNNEL DECL_EFFECT_FULL(tunnel, "Tunnel") 21 | 22 | #endif /* __EFFECTS_TUNNEL_H__ */ 23 | -------------------------------------------------------------------------------- /main/effects/lamp.c: -------------------------------------------------------------------------------- 1 | #include "effects/lamp.h" 2 | 3 | #define P_RED 0 4 | #define P_GREEN 1 5 | #define P_BLUE 2 6 | 7 | // 2500 K by default 8 | EFFECT_PARAMS(lamp, 3) = { 9 | DECL_PARAM_RANGE(P_RED, "Red", 0, 255, 255), 10 | DECL_PARAM_RANGE(P_GREEN, "Green", 0, 255, 159), 11 | DECL_PARAM_RANGE(P_BLUE, "Blue", 0, 255, 70), 12 | }; 13 | 14 | esp_err_t effect_lamp_run(framebuffer_t *fb) 15 | { 16 | CHECK(fb_begin(fb)); 17 | 18 | rgb_t color = { .r = PARAM_VAL(lamp, P_RED), .g = PARAM_VAL(lamp, P_GREEN), .b = PARAM_VAL(lamp, P_BLUE) }; 19 | 20 | for (size_t i = 0; i < fb->height * fb->width; i++) 21 | fb->data[i] = color; 22 | 23 | return fb_end(fb); 24 | } 25 | -------------------------------------------------------------------------------- /components/esp_idf_lib_helpers/ets_sys.h: -------------------------------------------------------------------------------- 1 | #if CONFIG_IDF_TARGET_ESP32 2 | #include 3 | #elif CONFIG_IDF_TARGET_ESP32C2 4 | #include 5 | #elif CONFIG_IDF_TARGET_ESP32C3 6 | #include 7 | #elif CONFIG_IDF_TARGET_ESP32C6 8 | #include 9 | #elif CONFIG_IDF_TARGET_ESP32H2 10 | #include 11 | #elif CONFIG_IDF_TARGET_ESP32H4 12 | #include 13 | #elif CONFIG_IDF_TARGET_ESP32S2 14 | #include 15 | #elif CONFIG_IDF_TARGET_ESP32S3 16 | #include 17 | #elif CONFIG_IDF_TARGET_ESP8266 18 | #include 19 | #else 20 | #error "ets_sys: Unknown target" 21 | #endif 22 | -------------------------------------------------------------------------------- /main/utils/nvs.h: -------------------------------------------------------------------------------- 1 | #include "cJSON.h" 2 | #include 3 | typedef struct nvs_data_s 4 | { 5 | uint8_t status; 6 | uint8_t level; 7 | uint8_t color_h; 8 | uint8_t color_s; 9 | uint16_t color_x; 10 | uint16_t color_y; 11 | uint8_t color_mode; 12 | uint16_t crc; 13 | 14 | } nvs_data_t; 15 | esp_err_t readIntFromNVS(const char *nvs_key, int32_t *value); 16 | esp_err_t saveIntToNVS(const char *nvs_key, int32_t value); 17 | esp_err_t saveBlobToNVS(const char *nvs_key, nvs_data_t *data); 18 | esp_err_t readBlobNVS(const char *nvs_key, nvs_data_t *data); 19 | esp_err_t EraseKeyNVS(const char *nvs_key); 20 | // esp_err_t save_key_value(char *key, char *value); 21 | // esp_err_t load_key_value(char *key, char *value, size_t size) -------------------------------------------------------------------------------- /main/modules/exec/led_light/led_light.c: -------------------------------------------------------------------------------- 1 | #include "freertos/FreeRTOS.h" 2 | #include "freertos/task.h" 3 | #include "esp_log.h" 4 | #include "esp_err.h" 5 | #include "string.h" 6 | // #include "driver/gpio.h" 7 | #include "../../../utils/send_data.h" 8 | #include "../../sensor_init.h" 9 | #include "led_light.h" 10 | #include "light.h" 11 | 12 | static const char *TAG = "led_light"; 13 | 14 | void led_light(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams) 15 | { 16 | TaskParameters *params = (TaskParameters *)taskParams; 17 | int param_pin = params->param_pin; 18 | light_data_t light_data; 19 | light_init(&light_data, param_pin); 20 | ESP_LOGW(TAG, "Task: %s created. Cluster: %s EP: %d", sensor, cluster, param_pin); 21 | } 22 | -------------------------------------------------------------------------------- /main/utils/bus.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_BUS_H_ 2 | #define MEEF_BUS_H_ 3 | 4 | #include "common.h" 5 | 6 | typedef enum 7 | { 8 | EVENT_NETWORK_UP = 0, 9 | EVENT_NETWORK_DOWN, 10 | EVENT_BUTTON_PRESSED, 11 | EVENT_BUTTON_PRESSED_LONG, 12 | EVENT_BUTTON_RELEASED, 13 | EVENT_BUTTON_CLICKED, 14 | EVENT_TIMER, 15 | EVENT_ZIGBEE_UP, 16 | EVENT_ZIGBEE_DOWN, 17 | EVENT_ZIGBEE_START, 18 | EVENT_ZIGBEE_CAN_SLEEP 19 | } event_type_t; 20 | 21 | typedef struct 22 | { 23 | event_type_t type; 24 | uint8_t data[BUS_EVENT_DATA_SIZE]; 25 | } event_t; 26 | 27 | esp_err_t bus_init(); 28 | 29 | esp_err_t bus_send_event(event_type_t type, void *data, size_t size); 30 | 31 | esp_err_t bus_receive_event(event_t *e, size_t timeout_ms); 32 | 33 | #endif /* MEEF_BUS_H_ */ 34 | -------------------------------------------------------------------------------- /components/esp_idf_lib_helpers/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Tomoyuki Sakurai 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Windows", 5 | "cStandard": "c11", 6 | "cppStandard": "c++17", 7 | "includePath": [ 8 | "${config:idf.espIdfPath}/components/**", 9 | "${workspaceFolder}/**" 10 | ], 11 | "browse": { 12 | "path": [ 13 | "${config:idf.espIdfPath}/components" 14 | ], 15 | "limitSymbolsToIncludedHeaders": false 16 | }, 17 | "compileCommands": "${workspaceFolder}/build/compile_commands.json", 18 | "compilerPath": "${config:idf.toolsPathWin}\\tools\\riscv32-esp-elf\\esp-12.2.0_20230208\\riscv32-esp-elf\\bin\\riscv32-esp-elf-gcc.exe" 19 | } 20 | ], 21 | "version": 4 22 | } 23 | -------------------------------------------------------------------------------- /main/effects/waterfall.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Waterfall/Fire effect 3 | * 4 | * Parameters: 5 | * - hue: Basic hue for waterfall palette. Ignored when mode = WATERFALL_FIRE 6 | * - cooling: How much does the air cool as it rises. Less cooling = taller flames, 7 | * more cooling = shorter flames. Suggested range 20-100. 8 | * - sparking: Chance (out of 255) that a new spark will light up. Suggested range 50-200. 9 | * 10 | * Recommended parameters for fire mode: cooling = 90, sparking = 80 11 | */ 12 | #ifndef __EFFECTS_WATERFALL_H__ 13 | #define __EFFECTS_WATERFALL_H__ 14 | 15 | #include "effect.h" 16 | 17 | extern EFFECT_PARAMS(waterfall, 4); 18 | 19 | esp_err_t effect_waterfall_prepare(framebuffer_t *fb); 20 | 21 | esp_err_t effect_waterfall_run(framebuffer_t *fb); 22 | 23 | #define DESCR_EFFECT_WATERFALL DECL_EFFECT_FULL(waterfall, "Waterfall") 24 | 25 | #endif /* __EFFECTS_WATERFALL_H__ */ 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | *.swp 54 | 55 | build/ 56 | !spiffs_storage/build/ 57 | !*.csv 58 | 59 | sdkconfig.old 60 | /.cproject 61 | /.project 62 | /.settings/ 63 | /.pydevproject 64 | /__garbage__ 65 | /sdkconfig.unclerus 66 | /.vscode/ 67 | /.idea/ 68 | /cmake-build-debug/ 69 | /managed_components -------------------------------------------------------------------------------- /main/effects/sparkles.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Colored sparkles effect 3 | */ 4 | #include "effects/sparkles.h" 5 | 6 | #include 7 | 8 | #define P_COUNT 0 9 | #define P_FADEOUT 1 10 | 11 | EFFECT_PARAMS(sparkles, 2) = { 12 | DECL_PARAM_RANGE(P_COUNT, "Number of sparkles", 1, 50, 10), 13 | DECL_PARAM_RANGE(P_FADEOUT, "Fadeout speed", 10, 150, 80), 14 | }; 15 | 16 | esp_err_t effect_sparkles_run(framebuffer_t *fb) 17 | { 18 | CHECK(fb_begin(fb)); 19 | 20 | fb_blur2d(fb, 8); 21 | for (uint8_t i = 0; i < PARAM_VAL(sparkles, P_COUNT); i++) 22 | { 23 | uint16_t x = random16_to(fb->width); 24 | uint16_t y = random16_to(fb->height); 25 | 26 | rgb_t c; 27 | fb_get_pixel_rgb(fb, x, y, &c); 28 | if (rgb_luma(c) < 5) 29 | fb_set_pixel_hsv(fb, x, y, hsv_from_values(random8(), 255, 255)); 30 | } 31 | fb_fade(fb, PARAM_VAL(sparkles, P_FADEOUT)); 32 | 33 | return fb_end(fb); 34 | } 35 | -------------------------------------------------------------------------------- /main/modules/virtual/deepsleep/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "menuSection": "virtual", 3 | "configItem": [ 4 | { 5 | "name": "deepsleep", 6 | "sensor": "deepsleep", 7 | "id": "deepsleep", 8 | "int": 60, 9 | "pin": 2, 10 | "clusters": [ 11 | "deepsleep" 12 | ], 13 | "EP": 1, 14 | "descr": "ESP deep sleep" 15 | } 16 | ], 17 | "about": { 18 | "authorName": "AVAKS", 19 | "authorContact": "https://t.me/avaks", 20 | "authorGit": "https://github.com/avaksru", 21 | "specialThanks": "", 22 | "moduleName": "deepsleep", 23 | "moduleVersion": "1.0", 24 | "title": "deepsleep", 25 | "moduleDesc": "deepsleep", 26 | "retInfo": "", 27 | "propInfo": {} 28 | }, 29 | "defActive": true, 30 | "usedLibs": { 31 | "esp32_C6": [], 32 | "esp32_H2": [] 33 | } 34 | } -------------------------------------------------------------------------------- /main/effects/hoop.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Color hoop 3 | * 4 | * https://wokwi.com/arduino/projects/297414039372300810 5 | * 6 | * max framebuffer size 256x256 7 | */ 8 | #include "effects/hoop.h" 9 | 10 | #include 11 | #include 12 | 13 | #define P_SPEED 0 14 | 15 | EFFECT_PARAMS(hoop, 1) = { 16 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 50, 15), 17 | }; 18 | 19 | static uint32_t m = 0; 20 | 21 | esp_err_t effect_hoop_run(framebuffer_t *fb) 22 | { 23 | CHECK(fb_begin(fb)); 24 | 25 | m += PARAM_VAL(hoop, P_SPEED); 26 | uint8_t t = m / 15; 27 | uint8_t u = t * 2; 28 | 29 | uint8_t div_x = 256 / fb->width; 30 | uint8_t div_y = 256 / fb->height; 31 | if (!div_x) div_x = 1; 32 | if (!div_y) div_y = 1; 33 | 34 | for (size_t i = 0; i < fb->width / 4 * 3; i++) 35 | fb_set_pixel_hsv(fb, sin8(t + i * 20) / div_x, sin8(u + i * 20) / div_y, hsv_from_values(i * 19, 255, 255)); 36 | 37 | fb_blur2d(fb, 32); 38 | 39 | return fb_end(fb); 40 | } 41 | -------------------------------------------------------------------------------- /main/modules/virtual/battery/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "menuSection": "virtual", 3 | "configItem": [ 4 | { 5 | "name": "cluster_battery", 6 | "sensor": "battery", 7 | "id": "battery", 8 | "int": 60, 9 | "pin": 2, 10 | "clusters": [ 11 | "battery" 12 | ], 13 | "EP": 1, 14 | "descr": "cluster Батарейного питания" 15 | } 16 | ], 17 | "about": { 18 | "authorName": "AVAKS", 19 | "authorContact": "https://t.me/avaks", 20 | "authorGit": "https://github.com/avaksru", 21 | "specialThanks": "", 22 | "moduleName": "cluster_battery", 23 | "moduleVersion": "1.0", 24 | "title": "cluster Батарейного питания", 25 | "moduleDesc": "cluster Батарейного питания", 26 | "retInfo": "", 27 | "propInfo": {} 28 | }, 29 | "defActive": true, 30 | "usedLibs": { 31 | "esp32_C6": [], 32 | "esp32_H2": [] 33 | } 34 | } -------------------------------------------------------------------------------- /main/modules/sensors/ds18b20/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "menuSection": "sensors", 3 | "configItem": [ 4 | { 5 | "name": "ds18x20", 6 | "sensor": "ds18x20", 7 | "id": "sensor", 8 | "int": 60, 9 | "pin": 2, 10 | "clusters": [ 11 | "ds18x20" 12 | ], 13 | "EP": 1, 14 | "descr": "Пример сенсора" 15 | } 16 | ], 17 | "about": { 18 | "authorName": "AVAKS", 19 | "authorContact": "https://t.me/avaks", 20 | "authorGit": "https://github.com/avaksru", 21 | "specialThanks": "", 22 | "moduleName": "GPIO IN", 23 | "moduleVersion": "1.0", 24 | "title": "ds18x20", 25 | "moduleDesc": "ds18x20", 26 | "retInfo": "", 27 | "propInfo": { 28 | "pin": "Укажите GPIO номер пина", 29 | "int": "Интервал опроса датчика" 30 | } 31 | }, 32 | "defActive": true, 33 | "usedLibs": { 34 | "esp32_C6": [], 35 | "esp32_H2": [] 36 | } 37 | } -------------------------------------------------------------------------------- /main/modules/sensors/_example/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "menuSection": "sensors", 3 | "configItem": [ 4 | { 5 | "name": "sensor_example", 6 | "sensor": "sensor_example", 7 | "id": "sensor", 8 | "int": 60, 9 | "pin": 2, 10 | "clusters": [ 11 | "sensor_example" 12 | ], 13 | "EP": 1, 14 | "descr": "Пример сенсора" 15 | } 16 | ], 17 | "about": { 18 | "authorName": "AVAKS", 19 | "authorContact": "https://t.me/avaks", 20 | "authorGit": "https://github.com/avaksru", 21 | "specialThanks": "", 22 | "moduleName": "GPIO IN", 23 | "moduleVersion": "1.0", 24 | "title": "Пример сенсора", 25 | "moduleDesc": "Образец для добавления своего датчика / сенсора", 26 | "retInfo": "", 27 | "propInfo": { 28 | "pin": "Укажите GPIO номер пина", 29 | "int": "Интервал опроса датчика" 30 | } 31 | }, 32 | "defActive": true, 33 | "usedLibs": { 34 | "esp32_C6": [], 35 | "esp32_H2": [] 36 | } 37 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Copyright (c) 2021 Ruslan V. Uss 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /components/button/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Ruslan V. Uss 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /components/color/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 FastLED 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /components/lib8tion/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 FastLED 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /components/noise/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 FastLED 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /spiffs_storage/global.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | position: relative; 3 | width: 100%; 4 | height: 100%; 5 | } 6 | 7 | body { 8 | color: #333; 9 | margin: 0; 10 | padding: 8px; 11 | box-sizing: border-box; 12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; 13 | } 14 | 15 | a { 16 | color: rgb(0,100,200); 17 | text-decoration: none; 18 | } 19 | 20 | a:hover { 21 | text-decoration: underline; 22 | } 23 | 24 | a:visited { 25 | color: rgb(0,80,160); 26 | } 27 | 28 | label { 29 | display: block; 30 | } 31 | 32 | input, button, select, textarea { 33 | font-family: inherit; 34 | font-size: inherit; 35 | -webkit-padding: 0.4em 0; 36 | padding: 0.4em; 37 | margin: 0 0 0.5em 0; 38 | box-sizing: border-box; 39 | border: 1px solid #ccc; 40 | border-radius: 2px; 41 | } 42 | 43 | input:disabled { 44 | color: #ccc; 45 | } 46 | 47 | button { 48 | color: #333; 49 | background-color: #f4f4f4; 50 | outline: none; 51 | } 52 | 53 | button:disabled { 54 | color: #999; 55 | } 56 | 57 | button:not(:disabled):active { 58 | background-color: #ddd; 59 | } 60 | 61 | button:focus { 62 | border-color: #666; 63 | } 64 | -------------------------------------------------------------------------------- /components/i2cdev/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Ruslan V. Uss (https://github.com/UncleRus) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /main/effects/peacock.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Peacock (sin plasma) effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | */ 6 | #include "effects/peacock.h" 7 | 8 | #include 9 | 10 | #define P_SPEED 0 11 | #define P_SCALE 1 12 | #define P_SATURATION 2 13 | 14 | EFFECT_PARAMS(peacock, 3) = { 15 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 255, 200), 16 | DECL_PARAM_RANGE(P_SCALE, "Scale", 1, 10, 4), 17 | DECL_PARAM_RANGE(P_SATURATION, "Saturation", 0, 255, 255), 18 | }; 19 | 20 | esp_err_t effect_peacock_run(framebuffer_t *fb) 21 | { 22 | CHECK(fb_begin(fb)); 23 | 24 | float t = (float)(esp_timer_get_time() / 1000) / (1000.0f - PARAM_VAL(peacock, P_SPEED) * 4); 25 | 26 | for (size_t x = 0; x < fb->width; x++) 27 | for (size_t y = 0; y < fb->height; y++) 28 | { 29 | uint8_t hue = sin8(x * 8 + sin8(x * PARAM_VAL(peacock, P_SCALE) + t * 6)) / 2 30 | + sin8(y * 8 + sin8(y * PARAM_VAL(peacock, P_SCALE) + t * 7) / 2); 31 | fb_set_pixel_hsv(fb, x, y, hsv_from_values(hue, PARAM_VAL(peacock, P_SATURATION), 255)); 32 | } 33 | 34 | return fb_end(fb); 35 | } 36 | -------------------------------------------------------------------------------- /main/utils/bus.c: -------------------------------------------------------------------------------- 1 | #include "bus.h" 2 | #include 3 | 4 | static QueueHandle_t bus; 5 | 6 | esp_err_t bus_init() 7 | { 8 | bus = xQueueCreate(BUS_QUEUE_LEN, sizeof(event_t)); 9 | if (!bus) 10 | { 11 | ESP_LOGE(TAG, "Cannot create bus queue"); 12 | return ESP_ERR_NO_MEM; 13 | } 14 | 15 | return ESP_OK; 16 | } 17 | 18 | esp_err_t bus_send_event(event_type_t type, void *data, size_t size) 19 | { 20 | if (size > BUS_EVENT_DATA_SIZE) 21 | { 22 | ESP_LOGE(TAG, "Event data size too big: %d", size); 23 | return ESP_ERR_NO_MEM; 24 | } 25 | 26 | event_t e; 27 | e.type = type; 28 | if (data && size) 29 | memcpy(e.data, data, size); 30 | 31 | if (xQueueSend(bus, &e, pdMS_TO_TICKS(BUS_TIMEOUT_MS)) != pdPASS) 32 | { 33 | ESP_LOGE(TAG, "Timeout while sending event with type %d", type); 34 | return ESP_ERR_TIMEOUT; 35 | } 36 | 37 | return ESP_OK; 38 | } 39 | 40 | esp_err_t bus_receive_event(event_t *e, size_t timeout_ms) 41 | { 42 | CHECK_ARG(e); 43 | 44 | if (xQueueReceive(bus, e, pdMS_TO_TICKS(timeout_ms)) != pdPASS) 45 | return ESP_ERR_TIMEOUT; 46 | 47 | return ESP_OK; 48 | } 49 | -------------------------------------------------------------------------------- /components/bmp180/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Frank Bargstedt 4 | Copyright (c) 2018 Ruslan V. Uss 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /components/bmp280/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 sheinz (https://github.com/sheinz) 4 | Copyright (c) 2018 Ruslan V. Uss (https://github.com/UncleRus) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /components/lib8tion/lib8tion.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2013 FastLED 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | #include "lib8tion.h" 25 | 26 | uint16_t rand16seed; 27 | -------------------------------------------------------------------------------- /spiffs_storage/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "device": { 3 | "devicename": "zigbee DIY" 4 | }, 5 | "wifi": { 6 | "mode": 1, 7 | "wifi_present": true, 8 | "wifi_enabled": true, 9 | "ip": { 10 | "dhcp": true, 11 | "ip": "192.168.4.1", 12 | "staip": "", 13 | "netmask": "255.255.255.0", 14 | "gateway": "192.168.4.1", 15 | "dns": "192.168.4.1" 16 | }, 17 | "ap": { 18 | "ssid": "MEEF", 19 | "channel": 6, 20 | "password": "" 21 | }, 22 | "sta": { 23 | "ssid": "perenio", 24 | "password": "4455667788" 25 | } 26 | }, 27 | "zigbee": { 28 | "zigbee_present": true, 29 | "zigbee_enabled": false, 30 | "modelname": "zigbee DIY", 31 | "manufactuer": "MEEF", 32 | "manufactuer_id": "0x1001", 33 | "zigbee_router": false, 34 | "zigbee_dc_power": true, 35 | "zigbee_light_sleep": false 36 | }, 37 | "mqtt": { 38 | "mqtt_enabled": false, 39 | "mqtt_conected": false, 40 | "server": "", 41 | "port": 1082320940, 42 | "prefx": "", 43 | "user": "", 44 | "password": "", 45 | "path": "" 46 | } 47 | } -------------------------------------------------------------------------------- /main/effects/flower.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Flower effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | */ 6 | #include "effects/flower.h" 7 | 8 | #include 9 | #include 10 | 11 | #define P_SPEED 0 12 | #define P_DIAMETER 1 13 | 14 | EFFECT_PARAMS(flower, 2) = { 15 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 255, 100), 16 | DECL_PARAM_RANGE(P_DIAMETER, "Diameter", 50, 150, 128), 17 | }; 18 | 19 | static uint32_t last_update_ms = 0; 20 | static float counter = 0; 21 | static float angle = 1; 22 | 23 | esp_err_t effect_flower_run(framebuffer_t *fb) 24 | { 25 | CHECK(fb_begin(fb)); 26 | 27 | uint32_t time_ms = esp_timer_get_time() / 1000; 28 | if ((time_ms - last_update_ms) > 80000 / PARAM_VAL(flower, P_SPEED)) 29 | { 30 | last_update_ms = time_ms; 31 | angle += 0.1; 32 | } 33 | 34 | float n = triwave8(counter) * 2.2f; 35 | float a = n * angle; 36 | float r = PARAM_VAL(flower, P_DIAMETER) / 255.0f * sqrt16(n); 37 | float x = r * cosf(a) + (float)fb->width / 2.0f; 38 | float y = r * sinf(a) + (float)fb->height / 2.0f; 39 | 40 | fb_set_pixelf_hsv(fb, x, y, hsv_from_values(time_ms >> 1, 250, 255)); 41 | 42 | fb_fade(fb, PARAM_VAL(flower, P_SPEED) / 10); 43 | counter += PARAM_VAL(flower, P_SPEED) / 100.0f; 44 | 45 | return fb_end(fb); 46 | } 47 | -------------------------------------------------------------------------------- /main/modules/sensors/dht/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "menuSection": "sensors", 3 | "configItem": [ 4 | { 5 | "name": "DHT (temperature humidity)", 6 | "sensor": "DHT", 7 | "id": "dht", 8 | "int": 60, 9 | "pin": 15, 10 | "clusters": [ 11 | "temperature", 12 | "humidity" 13 | ], 14 | "sensor_type": "AM2301", 15 | "EP": 1, 16 | "descr": "Датчик температуры / влажности" 17 | } 18 | ], 19 | "about": { 20 | "authorName": "AVAKS", 21 | "authorContact": "https://t.me/avaks", 22 | "authorGit": "https://github.com/avaksru", 23 | "specialThanks": "", 24 | "moduleName": "DHT", 25 | "moduleVersion": "1.0", 26 | "title": "Сенсор температуры и влажности DHT", 27 | "moduleDesc": "Позволяет получить значения температуры и влажности с dht11 или dht22.", 28 | "retInfo": "", 29 | "propInfo": { 30 | "sensor_type": "Выбираем DHT11, или AM2301 для датчиков (DHT21, DHT22, AM2302, AM2321), или Si7021", 31 | "pin": "Укажите GPIO номер пина", 32 | "int": "Количество секунд между опросами датчика." 33 | } 34 | }, 35 | "defActive": true, 36 | "usedLibs": { 37 | "esp32_C6": [], 38 | "esp32_H2": [] 39 | } 40 | } -------------------------------------------------------------------------------- /main/modules/sensors/siht/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "menuSection": "sensors", 3 | "configItem": [ 4 | { 5 | "name": "Si70xx/HTU2xD/SHT2x (temperature humidity)", 6 | "sensor": "SiHT", 7 | "id": "siht", 8 | "int": 60, 9 | "pin_SCL": 7, 10 | "pin_SDA": 6, 11 | "clusters": [ 12 | "all", 13 | "temperature", 14 | "humidity" 15 | ], 16 | "EP": 1, 17 | "descr": "Датчик температуры / влажности" 18 | } 19 | ], 20 | "about": { 21 | "authorName": "xyzroe", 22 | "authorContact": "https://t.me/xyzroe", 23 | "authorGit": "https://github.com/xyzroe", 24 | "specialThanks": "", 25 | "moduleName": "siht", 26 | "moduleVersion": "1.0", 27 | "title": "Сенсор температуры и влажности Si7021", 28 | "moduleDesc": "Позволяет получить значения температуры и влажности с Si7013/Si7020/Si7021/HTU2xD/SHT2x.", 29 | "retInfo": "", 30 | "propInfo": { 31 | "int": "Количество секунд между опросами датчика.", 32 | "pin_SDA": "Укажите GPIO номер пина", 33 | "pin_SCL": "Укажите GPIO номер пина" 34 | } 35 | }, 36 | "defActive": true, 37 | "usedLibs": { 38 | "esp32_C6": [], 39 | "esp32_H2": [] 40 | } 41 | } -------------------------------------------------------------------------------- /main/modules/sensors/scd4x/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "menuSection": "sensors", 3 | "configItem": [ 4 | { 5 | "name": "SCD4x CO2 + temperature, humidity", 6 | "sensor": "SCD4x", 7 | "id": "scd4x", 8 | "int": 60, 9 | "pin_SCL": 7, 10 | "pin_SDA": 6, 11 | "clusters": [ 12 | "all", 13 | "co2", 14 | "temperature", 15 | "humidity" 16 | ], 17 | "EP": 1, 18 | "descr": "Датчик CO2 + температура + влажность" 19 | } 20 | ], 21 | "about": { 22 | "authorName": "xyzroe", 23 | "authorContact": "https://t.me/xyzroe", 24 | "authorGit": "https://github.com/xyzroe", 25 | "specialThanks": "", 26 | "moduleName": "scd4x", 27 | "moduleVersion": "1.0", 28 | "title": "Датчик SCD4x CO2", 29 | "moduleDesc": "Позволяет получить значения углекислого, температуры и влажности с датчиков Sensirion SCD4x.", 30 | "retInfo": "", 31 | "propInfo": { 32 | "int": "Количество секунд между опросами датчика.", 33 | "pin_SDA": "Укажите GPIO номер пина", 34 | "pin_SCL": "Укажите GPIO номер пина" 35 | } 36 | }, 37 | "defActive": true, 38 | "usedLibs": { 39 | "esp32_C6": [], 40 | "esp32_H2": [] 41 | } 42 | } -------------------------------------------------------------------------------- /main/effects/diagonals.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Diagonal movements effect by SottNick 3 | */ 4 | #include "effects/diagonals.h" 5 | 6 | #include 7 | 8 | #define MAX_SPEED 10 9 | #define CHANGE_DIR 3 10 | 11 | #define P_SPEED 0 12 | 13 | EFFECT_PARAMS(diagonals, 1) = { 14 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, MAX_SPEED, MAX_SPEED / 2), 15 | }; 16 | 17 | static uint8_t slowdown; 18 | static uint8_t pixels; 19 | static int8_t dx = 1; 20 | static int8_t dy = 1; 21 | static size_t x = 0; 22 | static size_t y = 0; 23 | static uint8_t hue = 0; 24 | 25 | esp_err_t effect_diagonals_prepare(framebuffer_t *fb) 26 | { 27 | int r = PARAM_VAL(diagonals, P_SPEED) - MAX_SPEED / 2; 28 | 29 | slowdown = r < 0 ? -r + 1 : 1; 30 | pixels = r > 0 ? r + 1 : 1; 31 | 32 | return ESP_OK; 33 | } 34 | 35 | esp_err_t effect_diagonals_run(framebuffer_t *fb) 36 | { 37 | CHECK(fb_begin(fb)); 38 | 39 | if (!(fb->frame_num % slowdown)) 40 | { 41 | for (uint8_t i = 0; i < pixels; i++) 42 | { 43 | fb_fade(fb, 2); 44 | 45 | if (random8_to(CHANGE_DIR)) dx = (int8_t) (-dx); 46 | if (random8_to(CHANGE_DIR)) dy = (int8_t) (-dy); 47 | x = (fb->width + x + dx) % fb->width; 48 | y = (fb->height + y + dy) % fb->height; 49 | 50 | fb_set_pixel_hsv(fb, x, y, hsv_from_values(hue++, 255, 255)); 51 | } 52 | } 53 | 54 | return fb_end(fb); 55 | } 56 | -------------------------------------------------------------------------------- /dependencies.lock: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/ds18b20: 3 | component_hash: d676429d9f1f686b65ed895e418eb4b331477bcd5d63c27f43dc3d6a2de8f13b 4 | source: 5 | service_url: https://api.components.espressif.com/ 6 | type: service 7 | version: 0.1.1 8 | espressif/esp-zboss-lib: 9 | component_hash: c7020f631cd4ad25e159ddb812bdc80906b5b424457abc81c9b8b0e92687837a 10 | source: 11 | service_url: https://api.components.espressif.com/ 12 | type: service 13 | version: 1.3.2 14 | espressif/esp-zigbee-lib: 15 | component_hash: 752dbc8abb2befd2d49ee902051699fac5e32c6962950d64cd888d75d6566ca0 16 | source: 17 | service_url: https://api.components.espressif.com/ 18 | type: service 19 | version: 1.3.2 20 | espressif/led_strip: 21 | component_hash: fc66f8544851132555bc668475f7b68acd6a211c8075db5ce1951cbfa27dfb88 22 | source: 23 | service_url: https://api.components.espressif.com/ 24 | type: service 25 | version: 2.5.4 26 | espressif/onewire_bus: 27 | component_hash: c4c781940d8bd988432b47ac3ee68479c69e14e01fdfba0b61365b233a3ba5d6 28 | source: 29 | service_url: https://api.components.espressif.com/ 30 | type: service 31 | version: 1.0.2 32 | idf: 33 | component_hash: null 34 | source: 35 | type: idf 36 | version: 5.3.0 37 | manifest_hash: 91cacdb2315790da7de4c79743c18caf2485e19e4c4d32268d3d925da0d60e93 38 | target: esp32c6 39 | version: 1.0.0 40 | -------------------------------------------------------------------------------- /main/wifi/api.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_API_H_ 2 | #define MEEF_API_H_ 3 | 4 | #include "../utils/common.h" 5 | #include 6 | 7 | // API Handlers 8 | // 9 | // GET /api/info -> Application name, version, build date etc 10 | // GET /api/settings/reset -> reset wifi and led settings to defaults 11 | // GET /api/settings/wifi -> return current wifi settings 12 | // POST /api/settings/wifi -> set wifi settings 13 | // GET /api/settings/leds -> return led settings 14 | // POST /api/settings/leds -> set led settings 15 | // GET /api/reboot -> reboot lamp 16 | // GET /api/effects -> get effects list 17 | // GET /api/effects/reset -> reset effect settings to defaults 18 | // GET /api/lamp/state -> get current lamp state, effect, brightness and FPS 19 | // POST /api/lamp/state -> set current lamp state, effect, brightness and FPS 20 | // GET /api/lamp/effect -> get current effect settings 21 | // POST /api/lamp/effect -> set current effect settings 22 | // GET /* -> отправка любых файлов 23 | // POST /saveelement -> сохранение списка элементов 24 | // POST /upload_firmware -> обновление прошивки OTA 25 | 26 | // Сохранение кофига в виде JSON не используется 27 | // POST /saveconfig -> сохранение конфигурации 28 | 29 | esp_err_t api_init(httpd_handle_t server); 30 | 31 | #endif /* MEEF_API_H_ */ 32 | -------------------------------------------------------------------------------- /main/effects/rain.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Rain effect by Shaitan 3 | */ 4 | #include "effects/rain.h" 5 | 6 | #include 7 | 8 | #define MODE_SINGLE_COLOR 0 9 | 10 | #define P_MODE 0 11 | #define P_HUE 1 12 | #define P_DENSITY 2 13 | #define P_TAIL 3 14 | 15 | EFFECT_PARAMS(rain, 4) = { 16 | DECL_PARAM_BOOL(P_MODE, "Colored", 0), 17 | DECL_PARAM_RANGE(P_HUE, "Hue", 0, 255, HUE_AQUA), 18 | DECL_PARAM_RANGE(P_DENSITY, "Density", 0, 100, 50), 19 | DECL_PARAM_RANGE(P_TAIL, "Tail length", 100, 200, 150), 20 | }; 21 | 22 | static uint8_t density; 23 | 24 | esp_err_t effect_rain_prepare(framebuffer_t *fb) 25 | { 26 | density = 255 - qadd8(PARAM_VAL(rain, P_DENSITY), 155); 27 | return ESP_OK; 28 | } 29 | 30 | esp_err_t effect_rain_run(framebuffer_t *fb) 31 | { 32 | CHECK(fb_begin(fb)); 33 | 34 | for (size_t x = 0; x < fb->width; x++) 35 | { 36 | rgb_t c; 37 | fb_get_pixel_rgb(fb, x, fb->height - 1, &c); 38 | if (!rgb_luma(c) && random8_to(density) == 0) 39 | fb_set_pixel_hsv(fb, x, fb->height - 1, 40 | hsv_from_values(PARAM_VAL(rain, P_MODE) == MODE_SINGLE_COLOR ? PARAM_VAL(rain, P_HUE) : random8(), 255, 255)); 41 | else 42 | { 43 | c = rgb_scale(c, PARAM_VAL(rain, P_TAIL) + random8_to(100) - 50); 44 | fb_set_pixel_rgb(fb, x, fb->height - 1, rgb_luma(c) < 3 ? rgb_from_values(0, 0, 0) : c); 45 | } 46 | } 47 | fb_shift(fb, 1, FB_SHIFT_DOWN); 48 | 49 | return fb_end(fb); 50 | } 51 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.portWin": "COM5", 3 | "idf.flashType": "UART", 4 | "files.associations": { 5 | "zboss_api.h": "c", 6 | "zb_zcl_custom_cluster.h": "c", 7 | "esp_efuse.h": "c", 8 | "esp_efuse_table.h": "c", 9 | "esp_mac.h": "c", 10 | "sensair_s8.h": "c", 11 | "compare": "c", 12 | "zb_zcl_reporting.h": "c", 13 | "zigbee_utils": "c", 14 | "esp_check.h": "c", 15 | "zigbee_disconnected.h": "c", 16 | "chrono": "c", 17 | "random": "c", 18 | "sensor_init.h": "c", 19 | "bmx280.h": "c", 20 | "binary_input.h": "c", 21 | "sensor_dht.h": "c", 22 | "dht.h": "c", 23 | "string": "c", 24 | "string.h": "c", 25 | "sensor_example.h": "c", 26 | "sensor.h": "c", 27 | "sensor_gpioin.h": "c", 28 | "array": "c", 29 | "string_view": "c", 30 | "functional": "c", 31 | "sensor_ds18x20.h": "c", 32 | "esp_zigbee_zcl_power_config.h": "c", 33 | "adc_cali_scheme.h": "c", 34 | "esp_zb_sleepy_end_device.h": "c", 35 | "common.h": "c", 36 | "sensor_gpioout.h": "c", 37 | "send_data.h": "c", 38 | "mqtt.h": "c", 39 | "effect.h": "c", 40 | "ds18b20.h": "c", 41 | "sensor_bmp280.h": "c", 42 | "inttypes.h": "c" 43 | }, 44 | "idf.adapterTargetName": "esp32c6", 45 | "C_Cpp.errorSquiggles": "disabled", 46 | "idf.openOcdConfigs": [ 47 | "board/esp32c6-builtin.cfg" 48 | ] 49 | } -------------------------------------------------------------------------------- /components/aht/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 Ruslan V. Uss 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of itscontributors 14 | may be used to endorse or promote products derived from this software without 15 | specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /components/si7021/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Ruslan V. Uss 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of itscontributors 14 | may be used to endorse or promote products derived from this software without 15 | specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /main/effects/relax.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Light soft color change 3 | * 4 | * Author: Julia Uss 5 | */ 6 | #include "effects/relax.h" 7 | 8 | #include 9 | 10 | #define P_SPEED 0 11 | #define P_HUE 1 12 | #define P_SAT 2 13 | #define P_PIXELS 3 14 | 15 | EFFECT_PARAMS(relax, 4) = { 16 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 100, 15), 17 | DECL_PARAM_RANGE(P_HUE, "Start hue", 0, 255, 100), 18 | DECL_PARAM_RANGE(P_SAT, "Saturation", 0, 255, 255), 19 | DECL_PARAM_RANGE(P_PIXELS, "Pixels to update", 1, 50, 1), 20 | }; 21 | 22 | static uint8_t hue = 0; 23 | static uint16_t step = 0; 24 | static bool reset = false; 25 | 26 | esp_err_t effect_relax_prepare(framebuffer_t *fb) 27 | { 28 | step = 1200 - 10 * PARAM_VAL(relax, P_SPEED); 29 | reset = true; 30 | hue = PARAM_VAL(relax, P_HUE); 31 | return ESP_OK; 32 | } 33 | 34 | esp_err_t effect_relax_run(framebuffer_t *fb) 35 | { 36 | CHECK(fb_begin(fb)); 37 | 38 | rgb_t c = hsv2rgb_rainbow(hsv_from_values(hue, PARAM_VAL(relax, P_SAT), 255)); 39 | if (reset) 40 | { 41 | for (size_t i = 0; i < fb->width * fb->height; i++) 42 | fb->data[i] = c; 43 | reset = false; 44 | } 45 | else 46 | { 47 | if (!(fb->frame_num % step)) hue++; 48 | 49 | for (uint8_t i = 0; i < PARAM_VAL(relax, P_PIXELS); i++) 50 | { 51 | uint16_t x = random16_to(fb->width); 52 | uint16_t y = random16_to(fb->height); 53 | 54 | fb_set_pixel_rgb(fb, x, y, c); 55 | } 56 | } 57 | 58 | return fb_end(fb); 59 | } 60 | -------------------------------------------------------------------------------- /components/scd4x/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021, Sensirion AG 2 | Copyright (c) 2021 Ruslan V. Uss 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of itscontributors 15 | may be used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /spiffs_storage/ota.html: -------------------------------------------------------------------------------- 1 | 33 | 34 | 35 | 36 | 37 |

Firmware upgrade

38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /components/dht/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Jonathan Hartsuiker (https://github.com/jsuiker) 2 | Copyright (c) 2018 Ruslan V. Uss (https://github.com/UncleRus) 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of itscontributors 15 | may be used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /main/effects/water.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Water surface effect 3 | * 4 | * https://wokwi.com/arduino/projects/287787908971102732 5 | */ 6 | #include "effects/water.h" 7 | 8 | #include 9 | #include 10 | 11 | #define P_HUE 0 12 | #define P_SAT 1 13 | #define P_SPEED 2 14 | 15 | EFFECT_PARAMS(water, 3) = { 16 | DECL_PARAM_RANGE(P_HUE, "Hue", 0, 255, 150), 17 | DECL_PARAM_RANGE(P_SAT, "Saturation", 0, 255, 255), 18 | DECL_PARAM_RANGE(P_SPEED, "Speed", 0, 54, 30), 19 | }; 20 | 21 | #define PALETTE_SIZE 16 22 | 23 | static rgb_t palette[PALETTE_SIZE]; 24 | 25 | esp_err_t effect_water_prepare(framebuffer_t *fb) 26 | { 27 | rgb_fill_solid_hsv(palette, hsv_from_values(PARAM_VAL(water, P_HUE), PARAM_VAL(water, P_SAT), 230), PALETTE_SIZE); 28 | 29 | rgb_t c1 = hsv2rgb_rainbow(hsv_from_values(PARAM_VAL(water, P_HUE), PARAM_VAL(water, P_SAT) - 60, 255)); 30 | rgb_t c2 = hsv2rgb_rainbow(hsv_from_values(PARAM_VAL(water, P_HUE), 255 - PARAM_VAL(water, P_SAT), 210)); 31 | palette[7] = c1; 32 | palette[8] = c2; 33 | palette[9] = c2; 34 | palette[10] = c1; 35 | 36 | return ESP_OK; 37 | } 38 | 39 | esp_err_t effect_water_run(framebuffer_t *fb) 40 | { 41 | CHECK(fb_begin(fb)); 42 | 43 | uint32_t time_ms = esp_timer_get_time() / 1000; 44 | 45 | for (size_t y = 0; y < fb->height; y++) 46 | for (size_t x = 0; x < fb->width; x++) 47 | { 48 | uint8_t idx = inoise8_3d(x * 30, y * 30, time_ms / (255 - (PARAM_VAL(water, P_SPEED) + 200))); 49 | fb_set_pixel_rgb(fb, x, y, color_from_palette_rgb(palette, PALETTE_SIZE, idx, 255, true)); 50 | } 51 | fb_blur2d(fb, 32); 52 | 53 | return fb_end(fb); 54 | } 55 | -------------------------------------------------------------------------------- /main/effects/fire.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fire.c 3 | * 4 | * Fire effect based on Perlin noise 5 | * 6 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 7 | * 8 | * https://pastebin.com/jSSVSRi6 9 | */ 10 | #include "effects/fire.h" 11 | 12 | #include 13 | #include 14 | #include "palettes.h" 15 | 16 | #define MAX_SCALE 100 17 | #define HALF_SCALE (MAX_SCALE / 2) 18 | 19 | 20 | #define P_PALETTE 0 21 | #define P_SCALE 1 22 | 23 | EFFECT_PARAMS(fire, 2) = { 24 | DECL_PARAM_RANGE(P_PALETTE, "Palette", PALETTE_FIRE, PALETTE_LITHIUM_FIRE, 0), 25 | DECL_PARAM_RANGE(P_SCALE, "Scale", 10, MAX_SCALE, 60), 26 | }; 27 | 28 | static uint32_t time_scale = 1; 29 | 30 | esp_err_t effect_fire_prepare(framebuffer_t *fb) 31 | { 32 | time_scale = PARAM_VAL(fire, P_SCALE) >= HALF_SCALE ? 1 : (HALF_SCALE - PARAM_VAL(fire, P_SCALE)) / 2; 33 | 34 | return ESP_OK; 35 | } 36 | 37 | esp_err_t effect_fire_run(framebuffer_t *fb) 38 | { 39 | CHECK(fb_begin(fb)); 40 | 41 | uint32_t time_ms = esp_timer_get_time() / 1000; 42 | 43 | for (size_t x = 0; x < fb->width; x++) 44 | for (size_t y = 0; y < fb->height; y++) 45 | { 46 | uint8_t idx = qsub8( 47 | inoise8_3d(x * PARAM_VAL(fire, P_SCALE), y * PARAM_VAL(fire, P_SCALE) + time_ms / time_scale, time_ms / 3), 48 | abs8(y - (fb->height - 1)) * 255 / (fb->height - 1) 49 | ); 50 | rgb_t c = color_from_palette_rgb(palettes[PARAM_VAL(fire, P_PALETTE)].palette, palettes[PARAM_VAL(fire, P_PALETTE)].size, idx, 255, true); 51 | fb_set_pixel_rgb(fb, x, fb->height - y - 1, c); 52 | } 53 | 54 | return fb_end(fb); 55 | } 56 | -------------------------------------------------------------------------------- /main/utils/common.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_COMMON_H_ 2 | #define MEEF_COMMON_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "effects/config.h" 16 | 17 | extern const char *TAG; 18 | 19 | #define CHECK(x) \ 20 | do \ 21 | { \ 22 | esp_err_t __; \ 23 | if ((__ = (x)) != ESP_OK) \ 24 | return __; \ 25 | } while (0) 26 | 27 | #define CHECK_ARG(VAL) \ 28 | do \ 29 | { \ 30 | if (!(VAL)) \ 31 | return ESP_ERR_INVALID_ARG; \ 32 | } while (0) 33 | 34 | #define CHECK_LOGE(x, msg, ...) \ 35 | do \ 36 | { \ 37 | esp_err_t __; \ 38 | if ((__ = (x)) != ESP_OK) \ 39 | { \ 40 | ESP_LOGE(TAG, msg, ##__VA_ARGS__); \ 41 | return __; \ 42 | } \ 43 | } while (0) 44 | 45 | #define MAX(a, b) \ 46 | ({ __typeof__(a) _a = (a); \ 47 | __typeof__(b) _b = (b); \ 48 | _a > _b ? _a : _b; }) 49 | 50 | #define MIN(a, b) \ 51 | ({ __typeof__(a) _a = (a); \ 52 | __typeof__(b) _b = (b); \ 53 | _a < _b ? _a : _b; }) 54 | 55 | #endif /* MEEF_COMMON_H_ */ 56 | -------------------------------------------------------------------------------- /main/effects/dunes.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Colored dunes (AA lines) 3 | * 4 | * Author: costyn (https://wokwi.com/projects/284541784463245837) 5 | */ 6 | #include "effects/dunes.h" 7 | 8 | #include 9 | #include "palettes.h" 10 | 11 | #define P_SPEED 0 12 | #define P_PALETTE 1 13 | 14 | EFFECT_PARAMS(dunes, 2) = { 15 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 40, 5), 16 | DECL_PARAM_RANGE(P_PALETTE, "Palette", 0, PALETTE_MAX - 1, PALETTE_WOOD_FIRE), 17 | }; 18 | 19 | esp_err_t effect_dunes_run(framebuffer_t *fb) 20 | { 21 | CHECK(fb_begin(fb)); 22 | 23 | uint32_t ms = esp_timer_get_time() / 1000 * PARAM_VAL(dunes, P_SPEED) / 10; 24 | 25 | uint32_t y_hue_delta = (int32_t)sin16(ms * 11) / 128; 26 | uint32_t x_hue_delta = (int32_t)cos16(ms * 11) / 128; 27 | uint32_t start_hue = ms << 8; 28 | uint32_t line_start_hue = start_hue - (fb->height + 1) / 2 * y_hue_delta; 29 | int16_t yd2 = sin16(ms * 3) / 32; 30 | int16_t xd2 = sin16(ms * 7) / 32; 31 | for (size_t y = 0; y < fb->height; y++) 32 | { 33 | uint32_t pixel_hue = line_start_hue - (fb->width + 1) / 2 * x_hue_delta; 34 | uint32_t xhd = x_hue_delta; 35 | line_start_hue += y_hue_delta; 36 | y_hue_delta += yd2; 37 | for (size_t x = 0; x < fb->width; x++) 38 | { 39 | //rgb_t c = color_from_palette_rgb(palette, palette_size, pixel_hue >> 8, 255, true); 40 | rgb_t c = color_from_palette_rgb( 41 | palettes[PARAM_VAL(dunes, P_PALETTE)].palette, 42 | palettes[PARAM_VAL(dunes, P_PALETTE)].size, 43 | pixel_hue >> 8, 255, true); 44 | fb_set_pixel_rgb(fb, x, y, c); 45 | pixel_hue += xhd; 46 | xhd += xd2; 47 | } 48 | } 49 | 50 | return fb_end(fb); 51 | } 52 | -------------------------------------------------------------------------------- /main/modules/sensors/gpioIN/sensor_gpioin.c: -------------------------------------------------------------------------------- 1 | #include "freertos/FreeRTOS.h" 2 | #include "freertos/task.h" 3 | #include "esp_log.h" 4 | #include "esp_err.h" 5 | #include "cJSON.h" 6 | #include "string.h" 7 | #include "../../sensor_init.h" 8 | #include 9 | #include "sensor_gpioin.h" 10 | #include "utils/send_data.h" 11 | 12 | static const char *TAG = "GPIO_IN"; 13 | 14 | void vTaskGPIOin(void *pvParameters) 15 | { 16 | TaskParameters *params = (TaskParameters *)pvParameters; 17 | char *param_id = params->param_id; 18 | char id[30] = ""; 19 | strcpy(id, param_id); 20 | int param_pin = params->param_pin; 21 | char *param_cluster = params->param_cluster; 22 | char cluster[30] = ""; 23 | strcpy(cluster, param_cluster); 24 | int param_ep = params->param_ep; 25 | int param_int = params->param_int; 26 | 27 | gpio_set_direction(param_pin, GPIO_MODE_INPUT); 28 | gpio_set_pull_mode(param_pin, GPIO_PULLUP_ONLY); 29 | 30 | uint16_t last_state = gpio_get_level(param_pin); 31 | send_data(last_state, param_ep, cluster); 32 | // uint16_t last_state = 0; 33 | while (1) 34 | { 35 | uint16_t button_state = gpio_get_level(param_pin); 36 | if (button_state != last_state) 37 | { 38 | ESP_LOGI(TAG, "Button %d changed: %d", param_pin, button_state); 39 | last_state = button_state; 40 | send_data(button_state, param_ep, cluster); 41 | } 42 | 43 | vTaskDelay(param_int / portTICK_PERIOD_MS); 44 | } 45 | } 46 | 47 | void gpioin(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams) 48 | { 49 | ESP_LOGW(TAG, "Task: %s created. Cluster: %s EP: %d", sensor, cluster, EP); 50 | xTaskCreate(vTaskGPIOin, taskParams->param_id, 4096, taskParams, 5, NULL); 51 | } 52 | -------------------------------------------------------------------------------- /main/modules/sensors/gpioIN/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "menuSection": "executive_devices", 3 | "configItem": [ 4 | { 5 | "name": "GPIO IN", 6 | "sensor": "gpioIN", 7 | "id": "gpioIN", 8 | "int": 100, 9 | "pin": 2, 10 | "clusters": [ 11 | "Contact", 12 | "ZoneStatus", 13 | "Motion", 14 | "Door_Window", 15 | "Fire", 16 | "Occupancy", 17 | "Carbon", 18 | "Remote_Control", 19 | "BINARY" 20 | ], 21 | "EP": 1, 22 | "descr": "Освещение", 23 | "pinMode": "INPUT", 24 | "inv": 0 25 | } 26 | ], 27 | "about": { 28 | "authorName": "AVAKS", 29 | "authorContact": "https://t.me/avaks", 30 | "authorGit": "https://github.com/avaksru", 31 | "specialThanks": "", 32 | "moduleName": "GPIO IN", 33 | "moduleVersion": "1.0", 34 | "title": "Кнопка подключенная к пину", 35 | "moduleDesc": "Позволяет интерпретировать сигналы на цифровом пине как кнопку, т.е. создает в системе объект для чтения булевых значений с внешнего физического источника. Может вести себя как кнопка или как переключатель.", 36 | "retInfo": "Элемент данного модуля может иметь два значения 0 - низкий уровень, 1 - высокий уровень на входе. Значение меняется при выполнении условий по параметрам.", 37 | "propInfo": { 38 | "pin": "Укажите GPIO номер пина для чтения состояний подключенной кнопки", 39 | "pinMode": "Может быть INPUT_PULLUP INPUT_PULLDOWN INPUT", 40 | "int": "Время обработки дребезга", 41 | "inv": "Инвертировать снимаемые показания на последнем этапе." 42 | } 43 | }, 44 | "defActive": true, 45 | "usedLibs": { 46 | "esp32_C6": [], 47 | "esp32_H2": [] 48 | } 49 | } -------------------------------------------------------------------------------- /main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | idf_component_register( 3 | INCLUDE_DIRS . 4 | SRCS 5 | main.c 6 | settings.c 7 | wifi/wifi.c 8 | wifi/webserver.c 9 | wifi/api.c 10 | wifi/mqtt.c 11 | utils/bus.c 12 | utils/utils.c 13 | utils/spiffs.c 14 | utils/nvs.c 15 | utils/json.c 16 | utils/send_data.c 17 | utils/common.c 18 | zigbee/zigbee_init.c 19 | modules/sensor_init.c 20 | modules/sensors/gpioOUT/sensor_gpioOUT.c 21 | modules/sensors/gpioIN/sensor_gpioin.c 22 | modules/sensors/_example/sensor_example.c 23 | modules/sensors/aht/sensor_aht.c 24 | modules/sensors/dht/sensor_dht.c 25 | modules/sensors/bmp280/sensor_bmp280.c 26 | modules/sensors/ds18b20/sensor_ds18b20.c 27 | modules/sensors/siht/sensor_siht.c 28 | modules/sensors/scd4x/sensor_scd4x.c 29 | 30 | modules/virtual/battery/battery.c 31 | modules/virtual/deepsleep/deepsleep.c 32 | 33 | modules/exec/led_light/led_light.c 34 | modules/exec/led_light/light.c 35 | modules/exec/led_light/crc16.c 36 | 37 | effects/effect.c 38 | effects/surface.c 39 | effects/input.c 40 | effects/palettes.c 41 | 42 | effects/crazybees.c 43 | effects/dna.c 44 | effects/fire.c 45 | effects/lamp.c 46 | effects/lava.c 47 | effects/matrix.c 48 | effects/plasma_waves.c 49 | effects/rain.c 50 | effects/rainbow.c 51 | effects/rays.c 52 | effects/sparkles.c 53 | effects/waterfall.c 54 | effects/metaballs.c 55 | effects/water.c 56 | effects/holiday.c 57 | effects/hoop.c 58 | effects/twister.c 59 | effects/flower.c 60 | effects/polar_lights.c 61 | 62 | effects/relax.c 63 | effects/wheel.c 64 | effects/peacock.c 65 | effects/diagonals.c 66 | effects/whirls.c 67 | effects/sun.c 68 | effects/spaceships.c 69 | effects/fireflies.c 70 | effects/tunnel.c 71 | effects/dunes.c 72 | effects/octopus.c 73 | effects/nuclear.c 74 | 75 | 76 | 77 | ) 78 | 79 | spiffs_create_partition_image(storage ../spiffs_storage FLASH_IN_PROJECT) 80 | -------------------------------------------------------------------------------- /main/effects/wheel.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Radiant wheel effect 3 | */ 4 | #include 5 | #include 6 | #include "wheel.h" 7 | 8 | #define P_SPEED 0 9 | #define P_HUE1 1 10 | #define P_SAT1 2 11 | #define P_HUE2 3 12 | #define P_SAT2 4 13 | #define P_RAYS 5 14 | 15 | EFFECT_PARAMS(wheel, 6) = { 16 | DECL_PARAM_RANGE(P_SPEED, "Rotation speed", 0, 255, 60), 17 | DECL_PARAM_RANGE(P_HUE1, "Hue 1", 0, 255, 0), 18 | DECL_PARAM_RANGE(P_SAT1, "Saturation 1", 0, 255, 255), 19 | DECL_PARAM_RANGE(P_HUE2, "Hue 2", 0, 255, 150), 20 | DECL_PARAM_RANGE(P_SAT2, "Saturation 2", 0, 255, 0), 21 | DECL_PARAM_RANGE(P_RAYS, "Number of rays", 2, 6, 3), 22 | }; 23 | 24 | #define BLACK_TH 40 25 | #define BRIGHT_TH 200 26 | 27 | esp_err_t effect_wheel_run(framebuffer_t *fb) 28 | { 29 | CHECK(fb_begin(fb)); 30 | 31 | float t = (float)esp_timer_get_time() / 1000000.0f; 32 | 33 | size_t cx = fb->width / 2; 34 | size_t cy = fb->height / 2; 35 | float speed = (float)(PARAM_VAL(wheel, P_SPEED)) / 20.0f; 36 | 37 | float offs_y = sinf(t / 2) * fb->height / 3; 38 | float offs_x = sinf(t / 3) * fb->width / 3; 39 | 40 | for (int x = 0; x < fb->width; x++) 41 | for (int y = 0; y < fb->height; y++) 42 | { 43 | int16_t v = (int16_t)(sinf(PARAM_VAL(wheel, P_RAYS) * atan2f((float)x - cx + offs_x, (float)y - cy + offs_y) + t * speed) * 255); 44 | 45 | hsv_t color; 46 | color.val = abs(v); 47 | color.val = color.val > BRIGHT_TH ? color.val : color.val / 2; 48 | color.val = color.val < BLACK_TH ? 0 : color.val; 49 | if (v > 0) 50 | { 51 | color.hue = PARAM_VAL(wheel, P_HUE1); 52 | color.sat = PARAM_VAL(wheel, P_SAT1); 53 | } 54 | else 55 | { 56 | color.hue = PARAM_VAL(wheel, P_HUE2); 57 | color.sat = PARAM_VAL(wheel, P_SAT2); 58 | } 59 | fb_set_pixel_hsv(fb, x, fb->height - 1 - y, color); 60 | } 61 | 62 | return fb_end(fb); 63 | } 64 | -------------------------------------------------------------------------------- /main/effects/effect.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_EFFECT_H_ 2 | #define MEEF_EFFECT_H_ 3 | 4 | #include "../utils/common.h" 5 | #include 6 | 7 | typedef enum { 8 | PARAM_TYPE_RANGE = 0, 9 | PARAM_TYPE_BOOL, 10 | } effect_param_type_t; 11 | 12 | #define EFFECT_PARAMS(name, count) effect_param_t effect_ ##name## _params[count] 13 | 14 | #define DECL_PARAM_RANGE(ID, NAME, MIN, MAX, DEF) [ID] = { .name = NAME, .min = MIN, .max = MAX, .def = DEF, .value = DEF, .type = PARAM_TYPE_RANGE } 15 | #define DECL_PARAM_BOOL(ID, NAME, DEF) [ID] = { .name = NAME, .min = 0, .max = 1, .def = DEF, .value = DEF, .type = PARAM_TYPE_BOOL } 16 | 17 | #define PARAM_VAL(name, X) (effect_ ##name## _params[(X)].value) 18 | 19 | #define DECL_EFFECT_FULL(CODE, NAME) { \ 20 | .name = NAME, \ 21 | .prepare = effect_ ##CODE## _prepare, \ 22 | .run = effect_ ##CODE## _run, \ 23 | .params = effect_ ##CODE## _params, \ 24 | .params_count = sizeof(effect_ ##CODE## _params) / sizeof(effect_param_t) } 25 | 26 | #define DECL_EFFECT_SHORT(CODE, NAME) { \ 27 | .name = NAME, \ 28 | .prepare = NULL, \ 29 | .run = effect_ ##CODE## _run, \ 30 | .params = effect_ ##CODE## _params, \ 31 | .params_count = sizeof(effect_ ##CODE## _params) / sizeof(effect_param_t) } 32 | 33 | typedef struct 34 | { 35 | char name[32]; 36 | uint8_t min, max, def, value, type; 37 | } effect_param_t; 38 | 39 | typedef esp_err_t (*effect_prepare_cb)(framebuffer_t *fb); 40 | typedef esp_err_t (*effect_run_cb)(framebuffer_t *fb); 41 | 42 | typedef struct 43 | { 44 | char name[32]; 45 | effect_prepare_cb prepare; 46 | effect_run_cb run; 47 | effect_param_t *params; 48 | size_t params_count; 49 | } effect_descriptor_t; 50 | 51 | //////////////////////////////////////////////////////////////////////////////// 52 | 53 | extern const effect_descriptor_t effects[]; 54 | 55 | extern const size_t effects_count; 56 | 57 | esp_err_t effects_reset(); 58 | 59 | esp_err_t effect_param_set(size_t effect, size_t param, uint8_t value); 60 | 61 | esp_err_t effects_init(); 62 | 63 | #endif /* MEEF_EFFECT_H_ */ 64 | -------------------------------------------------------------------------------- /main/utils/json.c: -------------------------------------------------------------------------------- 1 | #include "cJSON.h" 2 | #include "esp_log.h" 3 | #include 4 | static const char *TAG = "JSON"; 5 | extern cJSON *settings_json; 6 | 7 | char *config_getString(char *key) 8 | { 9 | if (settings_json == NULL) 10 | { 11 | // Handle the case where settings_json is NULL 12 | ESP_LOGE(TAG, "settings_json is NULL"); 13 | return NULL; 14 | } 15 | 16 | cJSON *JSON_string = cJSON_GetObjectItemCaseSensitive(settings_json->child, key); 17 | if (JSON_string != NULL && cJSON_IsString(JSON_string)) 18 | { 19 | // ESP_LOGI(TAG, "JSON_string Name: %s", JSON_string->valuestring); 20 | return JSON_string->valuestring; 21 | } 22 | else 23 | { 24 | ESP_LOGE(TAG, "Error accessing JSON_string \"%s\" from JSON", key); 25 | return NULL; 26 | } 27 | } 28 | 29 | int config_getInt(char *key) 30 | { 31 | if (settings_json == NULL) 32 | { 33 | // Handle the case where settings_json is NULL 34 | ESP_LOGE(TAG, "settings_json is NULL"); 35 | return NULL; 36 | } 37 | 38 | cJSON *JSON_int = cJSON_GetObjectItemCaseSensitive(settings_json->child, key); 39 | if (JSON_int != NULL && cJSON_IsNumber(JSON_int)) 40 | { 41 | // ESP_LOGI(TAG, "JSON_string Name: %s", JSON_string->valuestring); 42 | return JSON_int->valueint; 43 | } 44 | else 45 | { 46 | ESP_LOGE(TAG, "Error accessing JSON_string \"%s\" from JSON", key); 47 | return NULL; 48 | } 49 | } 50 | bool config_getBool(char *key) 51 | { 52 | if (settings_json == NULL) 53 | { 54 | // Handle the case where settings_json is NULL 55 | ESP_LOGE(TAG, "settings_json is NULL"); 56 | return NULL; 57 | } 58 | 59 | cJSON *JSON_bool = cJSON_GetObjectItemCaseSensitive(settings_json->child, key); 60 | if (JSON_bool != NULL && cJSON_IsBool(JSON_bool)) 61 | { 62 | // ESP_LOGI(TAG, "JSON_string BOOL:"); 63 | return JSON_bool->valueint; 64 | } 65 | else 66 | { 67 | ESP_LOGE(TAG, "Error accessing JSON_string \"%s\" from JSON", key); 68 | return NULL; 69 | } 70 | } -------------------------------------------------------------------------------- /main/effects/rainbow.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple rainbow effect 3 | */ 4 | #include "effects/rainbow.h" 5 | 6 | #include 7 | 8 | #define P_DIRECTION 0 9 | #define P_SCALE 1 10 | #define P_SPEED 2 11 | 12 | EFFECT_PARAMS(rainbow, 3) = { 13 | DECL_PARAM_RANGE(P_DIRECTION, "Direction", 0, 2, 0), 14 | DECL_PARAM_RANGE(P_SCALE, "Scale", 1, 50, 20), 15 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 40, 5), 16 | }; 17 | 18 | enum { 19 | RAINBOW_HORIZONTAL = 0, 20 | RAINBOW_VERTICAL, 21 | RAINBOW_DIAGONAL, 22 | }; 23 | 24 | esp_err_t effect_rainbow_run(framebuffer_t *fb) 25 | { 26 | CHECK(fb_begin(fb)); 27 | 28 | if (PARAM_VAL(rainbow, P_DIRECTION) == RAINBOW_DIAGONAL) 29 | { 30 | for (size_t x = 0; x < fb->width; x++) 31 | for (size_t y = 0; y < fb->height; y++) 32 | { 33 | float twirl = 3.0f * PARAM_VAL(rainbow, P_SCALE) / 100.0f; 34 | hsv_t color = { 35 | .hue = fb->frame_num / 2 * PARAM_VAL(rainbow, P_SPEED) 36 | + (fb->width / fb->height * x + y * twirl) * PARAM_VAL(rainbow, P_SCALE), 37 | .sat = 255, 38 | .val = 255 39 | }; 40 | fb_set_pixel_hsv(fb, x, y, color); 41 | } 42 | } 43 | else 44 | { 45 | size_t outer = PARAM_VAL(rainbow, P_DIRECTION) == RAINBOW_HORIZONTAL ? fb->width : fb->height; 46 | size_t inner = PARAM_VAL(rainbow, P_DIRECTION) == RAINBOW_HORIZONTAL ? fb->height : fb->width; 47 | 48 | for (size_t i = 0; i < outer; i++) 49 | { 50 | hsv_t color = { 51 | .hue = fb->frame_num / 2 * PARAM_VAL(rainbow, P_SPEED) + i * PARAM_VAL(rainbow, P_SCALE), 52 | .sat = 255, 53 | .val = 255 54 | }; 55 | for (size_t j = 0; j < inner; j++) 56 | if (PARAM_VAL(rainbow, P_DIRECTION) == RAINBOW_HORIZONTAL) 57 | fb_set_pixel_hsv(fb, i, j, color); 58 | else 59 | fb_set_pixel_hsv(fb, j, i, color); 60 | } 61 | } 62 | 63 | return fb_end(fb); 64 | } 65 | -------------------------------------------------------------------------------- /main/effects/lava.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Perlin noise effect 3 | * 4 | * Author: Chuck Sommerville 5 | */ 6 | #include "effects/lava.h" 7 | 8 | #include 9 | #include 10 | #include "palettes.h" 11 | 12 | #define MODE_RAINBOW 0 13 | #define MODE_LAVA 1 14 | #define MODE_PALETTE 2 15 | 16 | #define P_SCALE 0 17 | #define P_SPEED 1 18 | #define P_MODE 2 19 | #define P_PALETTE 3 20 | 21 | EFFECT_PARAMS(lava, 4) = { 22 | DECL_PARAM_RANGE(P_SCALE, "Scale", 5, 100, 40), 23 | DECL_PARAM_RANGE(P_SPEED, "Speed", 0, 50, 15), 24 | DECL_PARAM_RANGE(P_MODE, "Mode", 0, MODE_PALETTE, 1), 25 | DECL_PARAM_RANGE(P_PALETTE, "Palette", 0, PALETTE_MAX - 1, 0), 26 | }; 27 | 28 | static const rgb_t lava_palette[] = { 29 | C_BLACK, 30 | C_BLACK, 31 | C_BLACK, 32 | C_DARK_RED, 33 | C_RED, 34 | C_YELLOW, 35 | C_WHITE 36 | }; 37 | 38 | #define LAVA_PALETTE_SIZE (sizeof(lava_palette) / sizeof(rgb_t)) 39 | 40 | static uint16_t z_pos; 41 | static uint16_t x_offs; 42 | static uint8_t hue; 43 | 44 | esp_err_t effect_lava_run(framebuffer_t *fb) 45 | { 46 | CHECK(fb_begin(fb)); 47 | 48 | if (!(fb->frame_num % 30)) x_offs++; 49 | 50 | z_pos += PARAM_VAL(lava, P_SPEED); 51 | hue++; 52 | 53 | for (int x = 0; x < fb->width; x++) 54 | for (int y = 0; y < fb->height; y++) 55 | { 56 | uint8_t noise = inoise8_3d(x * PARAM_VAL(lava, P_SCALE) + x_offs, y * PARAM_VAL(lava, P_SCALE), z_pos); 57 | 58 | switch (PARAM_VAL(lava, P_MODE)) 59 | { 60 | case MODE_RAINBOW: 61 | fb_set_pixel_hsv(fb, x, y, hsv_from_values(hue + noise, 255, 255)); 62 | break; 63 | case MODE_LAVA: 64 | fb_set_pixel_rgb(fb, x, y, color_from_palette_rgb(lava_palette, LAVA_PALETTE_SIZE, noise, 255, true)); 65 | break; 66 | default: 67 | fb_set_pixel_rgb(fb, x, y, color_from_palette_rgb(palettes[PARAM_VAL(lava, P_PALETTE)].palette, 68 | palettes[PARAM_VAL(lava, P_PALETTE)].size, noise, 255, true)); 69 | break; 70 | } 71 | } 72 | 73 | return fb_end(fb); 74 | } 75 | -------------------------------------------------------------------------------- /main/effects/tunnel.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Tunnel effect 3 | * 4 | * Original Lua/TIC-80 source was live-coded in 25 minutes by exoticorn during a 256-byte battle 5 | * at outlinedemoparty.nl 2021-05-15 6 | * 7 | * Author: exoticorn, Ported by: sutarobosu (https://wokwi.com/projects/332710874737279572) 8 | */ 9 | #include "effects/tunnel.h" 10 | 11 | #include 12 | #include 13 | 14 | #define P_SPEED 0 15 | 16 | EFFECT_PARAMS(tunnel, 1) = { 17 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 170, 90), 18 | }; 19 | 20 | static uint8_t half_width = 0; 21 | static uint8_t half_height = 0; 22 | static rgb_t *last = NULL; 23 | 24 | static const uint32_t pal[] = { 25 | 0x1a1c2c, 0x5d275d, 0xb13e53, 0xef7d57, 26 | 0xffcd75, 0xa7f070, 0x38b764, 0x257179, 0x29366f, 0x3b5dc9, 27 | 0x41a6f6, 0x73eff7, 0xf4f4f4, 0x94b0c2, 0x566c86, 0x333c57 28 | }; 29 | 30 | esp_err_t effect_tunnel_prepare(framebuffer_t *fb) 31 | { 32 | half_width = fb->width / 2; 33 | half_height = fb->height / 2; 34 | last = fb->data + fb->height * fb->width - 1; 35 | return ESP_OK; 36 | } 37 | 38 | esp_err_t effect_tunnel_run(framebuffer_t *fb) 39 | { 40 | CHECK(fb_begin(fb)); 41 | 42 | rgb_t *pixel = last; 43 | uint8_t c; 44 | 45 | float t = ((esp_timer_get_time() / 1000) % (21 * (201 - PARAM_VAL(tunnel, P_SPEED)) * 2)) / (201.0f - PARAM_VAL(tunnel, P_SPEED)), z, q, w; 46 | for (int8_t y = -half_height - half_height / 8; y < half_height - half_height / 8; y++) 47 | { 48 | for (int8_t x = -half_width; x <= 0; x++) 49 | { 50 | z = 20.0f / sqrtf(x * x + y * y) + t; 51 | q = (fmodf(z, 21) < 15) ? z - fmodf(z, 21) + 15 : z; 52 | w = 9.0f / y + t; 53 | if (y > 0 && w < q) 54 | c = (powf(x * (w - t), 2) < 39 ? 14 : 6) + fmodf(w, 2); 55 | else if (-y * (q - t) < 99.f / (powf(x * (q - t) / 50.f, 2) + 1)) 56 | c = (q == z) ? fmodf(z, 2) : 3; 57 | else 58 | c = 9 - y / 3 - ((0x2 >> (-y % 3)) & 1); 59 | *pixel-- = rgb_from_code(pal[c]); 60 | } 61 | rgb_t *src = pixel + 1; 62 | for (uint8_t x = 1; x < half_width; x++) 63 | *pixel-- = *++src; 64 | } 65 | 66 | return fb_end(fb); 67 | } 68 | -------------------------------------------------------------------------------- /main/modules/sensors/_example/sensor_example.c: -------------------------------------------------------------------------------- 1 | #include "freertos/FreeRTOS.h" 2 | #include "freertos/task.h" 3 | #include "esp_log.h" 4 | #include "esp_err.h" 5 | #include "string.h" 6 | // #include "driver/gpio.h" 7 | #include "../../../utils/send_data.h" 8 | #include "../../sensor_init.h" 9 | #include "sensor_example.h" 10 | 11 | static const char *TAG = "sensor_example"; 12 | static void sensor_example_task(void *pvParameters) 13 | { 14 | TaskParameters *params = (TaskParameters *)pvParameters; 15 | char *param_id = params->param_id; 16 | char id[30] = ""; 17 | strcpy(id, param_id); 18 | int param_pin = params->param_pin; 19 | char *param_cluster = params->param_cluster; 20 | char cluster[30] = ""; 21 | strcpy(cluster, param_cluster); 22 | int param_ep = params->param_ep; 23 | int param_int = params->param_int * 1000; 24 | char *param_sensor_type = params->param_sensor_type; 25 | char sensor_type[30] = ""; 26 | strcpy(sensor_type, param_sensor_type); 27 | // gpio_num_t param_pin_SCL = params->param_pin_SCL; 28 | // gpio_num_t param_pin_SDA = params->param_pin_SDA; 29 | int param_I2C_GND = params->param_I2C_GND; 30 | int I2C_ADDRESS_int = 0; 31 | sscanf(params->param_I2C_ADDRESS, "%x", &I2C_ADDRESS_int); 32 | char *param_I2C_ADDRESS; 33 | //*******************************************// 34 | 35 | //*******************************************// 36 | while (1) 37 | { 38 | 39 | if (strcmp(cluster, "sensor_example") == 0) 40 | { 41 | uint16_t sensor_example_state = 1; 42 | send_data(sensor_example_state, param_ep, cluster); 43 | ESP_LOGW(TAG, "int: %d", param_int); 44 | ESP_LOGW(TAG, "pin: %d", param_pin); 45 | } 46 | ESP_LOGI(TAG, "ep: %d", param_ep); 47 | ESP_LOGI(TAG, "id: %s", id); 48 | ESP_LOGI(TAG, "cluster: %s", cluster); 49 | ESP_LOGI(TAG, "sensor_type: %s", sensor_type); 50 | 51 | vTaskDelay(param_int / portTICK_PERIOD_MS); 52 | } 53 | } 54 | //----------------------------------// 55 | void sensor_example(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams) 56 | { 57 | ESP_LOGW(TAG, "Task: %s created. Cluster: %s EP: %d", sensor, cluster, EP); 58 | xTaskCreate(sensor_example_task, taskParams->param_id, 4096, taskParams, 5, NULL); 59 | } 60 | -------------------------------------------------------------------------------- /main/wifi/webserver.c: -------------------------------------------------------------------------------- 1 | #include "webserver.h" 2 | #include 3 | #include "api.h" 4 | // #include "embed.h" 5 | 6 | static httpd_handle_t server = NULL; 7 | 8 | //////////////////////////////////////////////////////////////////////////////// 9 | /// Internal 10 | /* 11 | #define DECLARE_EMBED_HANDLER(NAME, URI, CT) \ 12 | esp_err_t get_##NAME(httpd_req_t *req) { \ 13 | httpd_resp_set_type(req, CT); \ 14 | return httpd_resp_sendstr(req, embed_##NAME); \ 15 | } \ 16 | static const httpd_uri_t route_get_##NAME = { .uri = (URI), .method = HTTP_GET, .handler = get_##NAME } 17 | */ 18 | //////////////////////////////////////////////////////////////////////////////// 19 | /// Handlers 20 | /* 21 | DECLARE_EMBED_HANDLER(jquery_js, "/jquery.js", "text/javascript"); 22 | DECLARE_EMBED_HANDLER(styles_css, "/styles.css", "text/css"); 23 | DECLARE_EMBED_HANDLER(index_html, "/index.html", "text/html"); 24 | static const httpd_uri_t route_get_root = { .uri = "/", .method = HTTP_GET, .handler = get_index_html }; 25 | */ 26 | //////////////////////////////////////////////////////////////////////////////// 27 | /// Init 28 | 29 | static esp_err_t init() 30 | { 31 | // API handlers 32 | CHECK(api_init(server)); 33 | 34 | // Static file handlers 35 | // CHECK(httpd_register_uri_handler(server, &route_get_jquery_js)); 36 | // CHECK(httpd_register_uri_handler(server, &route_get_styles_css)); 37 | // CHECK(httpd_register_uri_handler(server, &route_get_index_html)); 38 | // CHECK(httpd_register_uri_handler(server, &route_get_root)); 39 | 40 | return ESP_OK; 41 | } 42 | 43 | //////////////////////////////////////////////////////////////////////////////// 44 | /// Public 45 | 46 | esp_err_t webserver_restart() 47 | { 48 | if (server) 49 | { 50 | ESP_LOGI(TAG, "HTTPD started, trying to stop..."); 51 | httpd_stop(server); 52 | } 53 | 54 | httpd_config_t config = HTTPD_DEFAULT_CONFIG(); 55 | config.uri_match_fn = httpd_uri_match_wildcard; 56 | config.max_uri_handlers = 100; 57 | config.stack_size = HTTPD_STACK_SIZE; 58 | config.lru_purge_enable = true; 59 | 60 | CHECK(httpd_start(&server, &config)); 61 | CHECK(init()); 62 | 63 | ESP_LOGI(TAG, "HTTPD started on port %d, free mem: %lu Kb", config.server_port, esp_get_free_heap_size() / 1024); 64 | 65 | return ESP_OK; 66 | } 67 | -------------------------------------------------------------------------------- /main/effects/whirls.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Whirls effect by SottNick 3 | */ 4 | #include "effects/whirls.h" 5 | 6 | #include 7 | #include 8 | #include "palettes.h" 9 | 10 | #define MAX_WHIRLS 50 11 | 12 | #define P_COUNT 0 13 | #define P_SCALE 1 14 | #define P_PALETTE 2 15 | #define P_FADEOUT 3 16 | #define P_TIME_SCALE 4 17 | 18 | EFFECT_PARAMS(whirls, 5) = { 19 | DECL_PARAM_RANGE(P_COUNT, "Count", 10, MAX_WHIRLS, 20), 20 | DECL_PARAM_RANGE(P_SCALE, "Scale", 5, 50, 26), 21 | DECL_PARAM_RANGE(P_PALETTE, "Palette", PALETTE_FIRE, PALETTE_MAX - 1, 0), 22 | DECL_PARAM_RANGE(P_FADEOUT, "Fadeout", 10, 250, 50), 23 | DECL_PARAM_RANGE(P_TIME_SCALE, "Time scale", 1, 10, 10), 24 | }; 25 | 26 | typedef struct 27 | { 28 | float x, y; 29 | } whirl_t; 30 | 31 | static whirl_t whirls[MAX_WHIRLS] = { 0 }; 32 | 33 | static void reset_whirl(framebuffer_t *fb, size_t i) 34 | { 35 | whirls[i].x = random8_to(fb->width); 36 | whirls[i].y = 0.0f; 37 | } 38 | 39 | esp_err_t effect_whirls_prepare(framebuffer_t *fb) 40 | { 41 | for (size_t i = 0; i < PARAM_VAL(whirls, P_COUNT); i++) 42 | reset_whirl(fb, i); 43 | 44 | return ESP_OK; 45 | } 46 | 47 | esp_err_t effect_whirls_run(framebuffer_t *fb) 48 | { 49 | CHECK(fb_begin(fb)); 50 | 51 | uint16_t scaled_time = esp_timer_get_time() / 1000 / PARAM_VAL(whirls, P_TIME_SCALE); 52 | 53 | fb_fade(fb, PARAM_VAL(whirls, P_FADEOUT)); 54 | 55 | for (size_t i = 0; i < PARAM_VAL(whirls, P_COUNT); i++) 56 | { 57 | uint16_t x_offset = PARAM_VAL(whirls, P_SCALE) * whirls[i].x; 58 | uint16_t y_offset = PARAM_VAL(whirls, P_SCALE) * whirls[i].y; 59 | uint8_t angle = inoise8_3d(scaled_time + x_offset, scaled_time + y_offset, scaled_time); 60 | 61 | whirls[i].x += (float)sin8(angle) * 0.0078125f - 1.0f; 62 | whirls[i].y -= (float)cos8(angle) * 0.0078125f - 1.0f; 63 | 64 | rgb_t c = color_from_palette_rgb( 65 | palettes[PARAM_VAL(whirls, P_PALETTE)].palette, 66 | palettes[PARAM_VAL(whirls, P_PALETTE)].size, 67 | angle / 2, 255, true); 68 | fb_set_pixelf_rgb(fb, whirls[i].x, whirls[i].y, c); 69 | 70 | if (whirls[i].x < 0 || whirls[i].x >= (float)fb->width || whirls[i].y < 0 || whirls[i].y >= (float)fb->height) 71 | reset_whirl(fb, i); 72 | } 73 | 74 | return fb_end(fb); 75 | } 76 | -------------------------------------------------------------------------------- /main/effects/sun.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Sun radiation effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | */ 6 | #include "effects/sun.h" 7 | 8 | #include 9 | #include 10 | #include "palettes.h" 11 | 12 | #define MODE_SINGLE_COLOR 0 13 | 14 | #define P_SIZE 0 15 | #define P_PALETTE 1 16 | 17 | EFFECT_PARAMS(sun, 2) = { 18 | DECL_PARAM_RANGE(P_SIZE, "Size", 4, 32, 8), 19 | DECL_PARAM_RANGE(P_PALETTE, "Palette", 0, PALETTE_MAX - 1, PALETTE_HEAT), 20 | }; 21 | 22 | static uint8_t *bump_map = NULL; 23 | 24 | esp_err_t effect_sun_prepare(framebuffer_t *fb) 25 | { 26 | if (!bump_map) 27 | bump_map = malloc((fb->width + 2) * (fb->height + 2)); 28 | if (!bump_map) 29 | { 30 | ESP_LOGE(TAG, "Error allocating memory for bump map in sun effect"); 31 | return ESP_ERR_NO_MEM; 32 | } 33 | return ESP_OK; 34 | } 35 | 36 | static void generate_bump(framebuffer_t *fb) 37 | { 38 | size_t time = esp_timer_get_time() / 4000; 39 | size_t i = 0; 40 | for (size_t x = 0; x < fb->width + 2; x++) 41 | for (size_t y = 0; y < fb->height + 2; y++) 42 | bump_map[i++] = inoise8_3d_raw(x * 25, y * 25, time) / 2; 43 | } 44 | 45 | esp_err_t effect_sun_run(framebuffer_t *fb) 46 | { 47 | CHECK(fb_begin(fb)); 48 | 49 | generate_bump(fb); 50 | 51 | int idx_y = (int)fb->width + 3; 52 | int vly = -((int)fb->height / 2 + 1); 53 | for (size_t y = 0; y < fb->height; y++) 54 | { 55 | vly++; 56 | int vlx = -((int)fb->width / 2 + 1); 57 | for (size_t x = 0; x < fb->width; x++) 58 | { 59 | vlx++; 60 | int8_t nx = (int8_t)(bump_map[x + idx_y + 1] - bump_map[x + idx_y - 1]); 61 | int8_t ny = (int8_t)(bump_map[x + idx_y + (fb->width + 2)] - bump_map[x + idx_y - (fb->width + 2)]); 62 | 63 | uint8_t dx = abs8(vlx * 7 - nx); 64 | uint8_t dy = abs8(vly * 7 - ny); 65 | int temp = dx * dx + dy * dy; 66 | int c = 200 - temp / PARAM_VAL(sun, P_SIZE); 67 | if (c < 0) c = 0; 68 | fb_set_pixel_rgb(fb, x, y, 69 | color_from_palette_rgb(palettes[PARAM_VAL(sun, P_PALETTE)].palette, palettes[PARAM_VAL(sun, P_PALETTE)].size, c, 255, true)); 70 | } 71 | idx_y += ((int)fb->width + 2); 72 | } 73 | 74 | return fb_end(fb); 75 | } 76 | -------------------------------------------------------------------------------- /main/effects/polar_lights.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Polar lights effect 3 | * 4 | * Author: Kostyantyn Matviyevskyy kostyamat 05.02.2021 5 | * 6 | * https://editor.soulmatelights.com/gallery/762-polar-lights 7 | */ 8 | #include "effects/polar_lights.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include "utils/utils.h" 14 | #include "palettes.h" 15 | 16 | #define PALETTE_BLUE 0 17 | #define PALETTE_GREEN 1 18 | 19 | #define P_SPEED 0 20 | #define P_SCALE 1 21 | #define P_PALETTE 2 22 | #define P_HEIGHT 3 23 | 24 | EFFECT_PARAMS(polar_lights, 4) = { 25 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 255, 127), 26 | DECL_PARAM_RANGE(P_SCALE, "Scale", 1, 255, 60), 27 | DECL_PARAM_RANGE(P_PALETTE, "Palette", 0, 1, 0), 28 | DECL_PARAM_RANGE(P_HEIGHT, "Height adjustment", 1, 255, 50), 29 | }; 30 | 31 | #define PALETTE_SIZE 4 32 | 33 | static rgb_t palette[PALETTE_SIZE]; 34 | 35 | static const rgb_t BLACK = C_BLACK; 36 | static const rgb_t BLUE = C_BLUE; 37 | static const rgb_t RED = C_RED; 38 | static const rgb_t YELLOW = C_YELLOW; 39 | static const rgb_t GREEN = C_GREEN; 40 | 41 | static float height_adj; 42 | static uint16_t p_scale; 43 | static uint8_t p_speed; 44 | static uint32_t t = 0; 45 | 46 | esp_err_t effect_polar_lights_prepare(framebuffer_t *fb) 47 | { 48 | palette[0] = BLACK; 49 | palette[2] = YELLOW; 50 | palette[3] = RED; 51 | switch (PARAM_VAL(polar_lights, P_PALETTE)) 52 | { 53 | case PALETTE_BLUE: 54 | palette[1] = BLUE; 55 | break; 56 | default: 57 | palette[1] = GREEN; 58 | } 59 | 60 | height_adj = PARAM_VAL(polar_lights, P_HEIGHT) / 2.0f; 61 | p_scale = map(PARAM_VAL(polar_lights, P_SCALE), 1, 255, 30, map(fb->width, 8, 64, 310, 63)); 62 | p_speed = map(PARAM_VAL(polar_lights, P_SPEED), 1, 255, 128, 16); 63 | return ESP_OK; 64 | } 65 | 66 | esp_err_t effect_polar_lights_run(framebuffer_t *fb) 67 | { 68 | CHECK(fb_begin(fb)); 69 | 70 | for (size_t x = 0; x < fb->width; x++) 71 | for (size_t y = 0; y < fb->height; y++) 72 | { 73 | t++; 74 | rgb_t color = color_from_palette_rgb(palette, PALETTE_SIZE, 75 | qsub8(inoise8_3d(t % 2 + x * p_scale, y * 16 + t % 16, t / p_speed), 76 | fabsf((float)fb->height / 2 - y) * height_adj), 77 | 255, true); 78 | fb_set_pixel_rgb(fb, x, y, color); 79 | } 80 | 81 | return fb_end(fb); 82 | } 83 | -------------------------------------------------------------------------------- /main/effects/dna.c: -------------------------------------------------------------------------------- 1 | /** 2 | * DNA spiral effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | * 6 | * Max supported framebuffer size is 256x256 7 | */ 8 | #include "effects/dna.h" 9 | 10 | #include 11 | #include "palettes.h" 12 | 13 | #define P_SPEED 0 14 | #define P_SIZE 1 15 | #define P_BORDER 2 16 | 17 | EFFECT_PARAMS(dna, 3) = { 18 | DECL_PARAM_RANGE(P_SPEED, "Rotation speed", 10, 100, 50), 19 | DECL_PARAM_RANGE(P_SIZE, "Spiral size", 1, 10, 5), 20 | DECL_PARAM_BOOL(P_BORDER, "Add white border", 1), 21 | }; 22 | 23 | static uint32_t offset; 24 | 25 | static const rgb_t dark_slate_gray = C_DARK_SLATE_GRAY; 26 | static const rgb_t white = C_WHITE; 27 | 28 | static void horizontal_line(framebuffer_t *fb, uint8_t x1, uint8_t x2, uint8_t y, rgb_t color, bool dot) 29 | { 30 | uint8_t steps = abs8(x2 - x1) + 1; 31 | 32 | for (uint8_t i = 1; i <= steps; i++) 33 | { 34 | uint8_t dx = lerp8by8(x1, x2, i * 255 / steps); 35 | rgb_t pixel; 36 | fb_get_pixel_rgb(fb, dx, y, &pixel); 37 | pixel = rgb_scale_video(rgb_add_rgb(pixel, color), i * 255 / steps); 38 | fb_set_pixel_rgb(fb, dx, y, pixel); 39 | } 40 | 41 | if (dot) 42 | { 43 | //add white point at the ends of line 44 | rgb_t pixel; 45 | fb_get_pixel_rgb(fb, x1, y, &pixel); 46 | fb_set_pixel_rgb(fb, x1, y, rgb_add_rgb(pixel, dark_slate_gray)); 47 | fb_set_pixel_rgb(fb, x2, y, white); 48 | } 49 | } 50 | 51 | esp_err_t effect_dna_run(framebuffer_t *fb) 52 | { 53 | CHECK(fb_begin(fb)); 54 | 55 | offset += PARAM_VAL(dna, P_SPEED) / 10; 56 | 57 | fb_fade(fb, 130); 58 | 59 | for (uint8_t i = 0; i < fb->height; i++) 60 | { 61 | uint16_t x1 = beatsin8(PARAM_VAL(dna, P_SPEED), 0, fb->width - 1, 0, i * PARAM_VAL(dna, P_SIZE)) 62 | + beatsin8(PARAM_VAL(dna, P_SPEED) - 7, 0, fb->width - 1, 0, i * PARAM_VAL(dna, P_SIZE) + 128); 63 | uint16_t x2 = beatsin8(PARAM_VAL(dna, P_SPEED), 0, fb->width - 1, 0, 128 + i * PARAM_VAL(dna, P_SIZE)) 64 | + beatsin8(PARAM_VAL(dna, P_SPEED) - 7, 0, fb->width - 1, 0, 128 + 64 + i * PARAM_VAL(dna, P_SIZE)); 65 | 66 | rgb_t color = hsv2rgb_rainbow(hsv_from_values(i * 128 / (fb->height - 1) + offset, 255, 255)); 67 | 68 | if ((i + offset / 8) & 3) 69 | horizontal_line(fb, x1 / 2, x2 / 2, i, color, PARAM_VAL(dna, P_BORDER)); 70 | } 71 | 72 | return fb_end(fb); 73 | } 74 | -------------------------------------------------------------------------------- /main/effects/rays.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Colored rays effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | * https://editor.soulmatelights.com/gallery/819-colored-bursts 6 | * 7 | * Max supported framebuffer size is 256x256 8 | */ 9 | #include "effects/rays.h" 10 | 11 | #include 12 | 13 | #define P_SPEED 0 14 | #define P_MIN_RAYS 1 15 | #define P_MAX_RAYS 2 16 | 17 | EFFECT_PARAMS(rays, 3) = { 18 | DECL_PARAM_RANGE(P_SPEED, "Speed", 0, 50, 10), 19 | DECL_PARAM_RANGE(P_MIN_RAYS, "Min rays", 1, 10, 3), 20 | DECL_PARAM_RANGE(P_MAX_RAYS, "Max rays", 1, 20, 6), 21 | }; 22 | 23 | static uint8_t hue; 24 | static uint8_t num_rays; 25 | 26 | static void line(framebuffer_t *fb, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, rgb_t color) 27 | { 28 | uint8_t x_steps = abs8((int8_t)(x1 - x2)) + 1; 29 | uint8_t y_steps = abs8((int8_t)(y1 - y2)) + 1; 30 | uint8_t steps = x_steps >= y_steps ? x_steps : y_steps; 31 | 32 | for (uint8_t i = 1; i <= steps; i++) 33 | { 34 | uint8_t dx = lerp8by8(x1, x2, i * 255 / steps); 35 | uint8_t dy = lerp8by8(y1, y2, i * 255 / steps); 36 | 37 | rgb_t pixel; 38 | fb_get_pixel_rgb(fb, dx, dy, &pixel); 39 | fb_set_pixel_rgb(fb, dx, dy, rgb_scale_video(rgb_add_rgb(pixel, color), i * 255 / steps)); 40 | } 41 | } 42 | 43 | esp_err_t effect_rays_run(framebuffer_t *fb) 44 | { 45 | CHECK(fb_begin(fb)); 46 | 47 | // change number of rays 48 | if (PARAM_VAL(rays, P_MAX_RAYS) > PARAM_VAL(rays, P_MIN_RAYS) && !(fb->frame_num % 10)) 49 | { 50 | if (random8_to(2)) 51 | num_rays++; 52 | else 53 | num_rays--; 54 | } 55 | if (num_rays < PARAM_VAL(rays, P_MIN_RAYS)) num_rays = PARAM_VAL(rays, P_MIN_RAYS); 56 | if (num_rays > PARAM_VAL(rays, P_MAX_RAYS)) num_rays = PARAM_VAL(rays, P_MAX_RAYS); 57 | 58 | hue += 5; 59 | fb_fade(fb, 40); 60 | for (uint8_t i = 0; i < num_rays; i++) 61 | { 62 | uint8_t x1 = beatsin8(4 + PARAM_VAL(rays, P_SPEED), 0, (fb->width - 1), 0, 0); 63 | uint8_t y1 = beatsin8(2 + PARAM_VAL(rays, P_SPEED), 0, (fb->height - 1), 0, 0); 64 | uint8_t x2 = beatsin8(8 + PARAM_VAL(rays, P_SPEED), 0, (fb->width - 1), 0, i * 24); 65 | uint8_t y2 = beatsin8(10 + PARAM_VAL(rays, P_SPEED), 0, (fb->height - 1), 0, i * 48 + 64); 66 | 67 | line(fb, x1, y1, x2, y2, hsv2rgb_rainbow(hsv_from_values(i * 255 / num_rays + hue, 255, 255))); 68 | } 69 | fb_blur2d(fb, 8); 70 | 71 | return fb_end(fb); 72 | } 73 | -------------------------------------------------------------------------------- /main/effects/config.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_CONFIG_H_ 2 | #define MEEF_CONFIG_H_ 3 | 4 | //////////////////////////////////////////////////////////////////////////////// 5 | /// System 6 | 7 | #if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) 8 | #error Unsupported target 9 | #endif 10 | 11 | #define APP_NAME "MEEF" 12 | 13 | //////////////////////////////////////////////////////////////////////////////// 14 | /// Settings 15 | 16 | #define SETTINGS_MAGIC 0xbeef001a 17 | 18 | #ifdef CONFIG_EL_WIFI_MODE_AP 19 | #define DEFAULT_WIFI_MODE WIFI_MODE_AP 20 | #else 21 | #define DEFAULT_WIFI_MODE WIFI_MODE_STA 22 | #endif 23 | 24 | #if CONFIG_EL_WIFI_DHCP 25 | #define DEFAULT_WIFI_DHCP true 26 | #else 27 | #define DEFAULT_WIFI_DHCP false 28 | #endif 29 | 30 | #define DEFAULT_WIFI_AP_MAXCONN 5 31 | 32 | #if CONFIG_EL_LED_TYPE_APA106 33 | #define DEFAULT_LED_TYPE LED_STRIP_APA106 34 | #elif CONFIG_EL_LED_TYPE_SK6812 35 | #define DEFAULT_LED_TYPE LED_STRIP_SK6812 36 | #elif CONFIG_EL_LED_TYPE_SM16703 37 | #define DEFAULT_LED_TYPE LED_MODEL_WS2812 38 | #else 39 | #define DEFAULT_LED_TYPE LED_MODEL_WS2812 40 | #endif 41 | 42 | #if CONFIG_EL_MATRIX_ROTATION_90 43 | #define DEFAULT_MATRIX_ROTATION MATRIX_ROTATION_90 44 | #elif CONFIG_EL_MATRIX_ROTATION_180 45 | #define DEFAULT_MATRIX_ROTATION MATRIX_ROTATION_180 46 | #elif CONFIG_EL_MATRIX_ROTATION_270 47 | #define DEFAULT_MATRIX_ROTATION MATRIX_ROTATION_270 48 | #else 49 | #define DEFAULT_MATRIX_ROTATION MATRIX_ROTATION_0 50 | #endif 51 | 52 | //////////////////////////////////////////////////////////////////////////////// 53 | /// Bus 54 | 55 | #define BUS_QUEUE_LEN 5 56 | #define BUS_TIMEOUT_MS 500 57 | #define BUS_EVENT_DATA_SIZE 64 58 | 59 | //////////////////////////////////////////////////////////////////////////////// 60 | /// Main task 61 | 62 | #define MAIN_TASK_STACK_SIZE 8192 63 | #define MAIN_TASK_PRIORITY 5 64 | 65 | //////////////////////////////////////////////////////////////////////////////// 66 | /// Surface 67 | 68 | #define FPS_MAX 120 69 | #define SURFACE_TASK_STACK_SIZE 8192 70 | #define MAX_SURFACE_BLOCKS 8 // RMT_CHANNEL_MAX 71 | #define MAX_BLOCK_LEDS 1024 72 | #define MIN_BLOCK_SIZE 8 73 | #define MAX_BLOCK_SIZE 128 74 | 75 | #if CONFIG_EL_MATRIX_H_BLOCKS * CONFIG_EL_MATRIX_V_BLOCKS > MAX_SURFACE_BLOCKS 76 | #error Too much LED blocks! 77 | #endif 78 | 79 | //////////////////////////////////////////////////////////////////////////////// 80 | /// Webserver 81 | 82 | #define HTTPD_STACK_SIZE 32768 83 | #define MAX_POST_SIZE 4096 84 | 85 | #endif /* MEEF_CONFIG_H_ */ 86 | -------------------------------------------------------------------------------- /main/modules/exec/led_light/crc16.c: -------------------------------------------------------------------------------- 1 | #include "crc16.h" 2 | 3 | static const uint16_t crc16Table[256] = { 4 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 5 | 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 6 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 7 | 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 8 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 9 | 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 10 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 11 | 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 12 | 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 13 | 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 14 | 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 15 | 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 16 | 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 17 | 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 18 | 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 19 | 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 20 | 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 21 | 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 22 | 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 23 | 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 24 | 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 25 | 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 26 | 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 27 | 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, 28 | 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 29 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, 30 | 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 31 | 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 32 | 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 33 | 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 34 | 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 35 | 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 36 | }; 37 | 38 | uint16_t crc16(uint8_t *data, uint16_t length) 39 | { 40 | uint16_t crc = 0xFFFF; 41 | 42 | while (length--) 43 | crc = (uint16_t) ((crc << 8) ^ crc16Table[(crc >> 8) ^ *data++]); 44 | 45 | return crc; 46 | } 47 | -------------------------------------------------------------------------------- /main/effects/octopus.c: -------------------------------------------------------------------------------- 1 | /** 2 | * "Octopus" 3 | * 4 | * Author: Stepko 5 | * https://editor.soulmatelights.com/gallery/671-octopus 6 | * 7 | * Note: only even-sized framebuffers are supported 8 | */ 9 | #include "effects/octopus.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #define P_SPEED 0 16 | #define P_LEGS 1 17 | #define P_CLOCKWISE 2 18 | 19 | EFFECT_PARAMS(octopus, 3) = { 20 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 10, 3), 21 | DECL_PARAM_RANGE(P_LEGS, "Legs", 2, 10, 3), 22 | DECL_PARAM_BOOL(P_CLOCKWISE, "Clockwise", 0), 23 | }; 24 | 25 | typedef struct { 26 | uint8_t angle; 27 | uint8_t radius; 28 | } map_item_t; 29 | 30 | #define MAP_XY(x, y) (map[((y) * fb->width + (x))]) 31 | 32 | static map_item_t *map = NULL; 33 | static float mmap = 0.0f; 34 | static uint16_t t = 0; 35 | 36 | esp_err_t effect_octopus_prepare(framebuffer_t *fb) 37 | { 38 | CHECK_ARG(fb); 39 | 40 | if (fb->width % 2 || fb->height % 2) 41 | { 42 | ESP_LOGE("octopus", "Only even-sized framebuffers are supported"); 43 | return ESP_FAIL; 44 | } 45 | 46 | if (!map) map = calloc(fb->width * fb->height, sizeof(map_item_t)); 47 | if (!map) return ESP_ERR_NO_MEM; 48 | 49 | int center_x = (int)fb->width / 2; 50 | int center_y = (int)fb->height / 2; 51 | 52 | mmap = 255.0f / MAX(fb->width, fb->height); 53 | 54 | for (int x = -center_x; x < center_x; x++) 55 | for (int y = -center_y; y < center_y; y++) 56 | { 57 | float xf = (float)x; 58 | float yf = (float)y; 59 | MAP_XY(x + center_x, y + center_y).angle = (uint8_t)(128 * (atan2f(yf, xf) / (float)M_PI)); 60 | MAP_XY(x + center_x, y + center_y).radius = (uint8_t)(hypotf(xf, yf) * mmap); 61 | } 62 | 63 | t = 0; 64 | 65 | return ESP_OK; 66 | } 67 | 68 | esp_err_t effect_octopus_run(framebuffer_t *fb) 69 | { 70 | CHECK(fb_begin(fb)); 71 | 72 | t += PARAM_VAL(octopus, P_SPEED); 73 | 74 | for (size_t x = 0; x < fb->width; x++) 75 | for (size_t y = 0; y < fb->height; y++) 76 | { 77 | size_t px = !PARAM_VAL(octopus, P_CLOCKWISE) ? x : fb->width - x - 1; 78 | map_item_t i = MAP_XY(x, y); 79 | fb_set_pixel_hsv(fb, px, y, 80 | hsv_from_values( 81 | t / 2 - i.radius, 82 | 255, 83 | sin8(sin8((i.angle * 4 - i.radius) / 4 + t) + i.radius - t * 2 + i.angle * PARAM_VAL(octopus, P_LEGS)) 84 | ) 85 | ); 86 | } 87 | 88 | return fb_end(fb); 89 | } 90 | -------------------------------------------------------------------------------- /main/effects/crazybees.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Crazy Bees effect 3 | * 4 | * Author: Stepko 5 | */ 6 | #include "effects/crazybees.h" 7 | #include 8 | 9 | #define MAX_BEES 10 10 | 11 | #define P_NUM_BEES 0 12 | #define P_BEE_HUE 1 13 | #define P_BEE_SAT 2 14 | 15 | EFFECT_PARAMS(crazybees, 3) = { 16 | DECL_PARAM_RANGE(P_NUM_BEES, "Number of bees", 1, MAX_BEES, 3), 17 | DECL_PARAM_RANGE(P_BEE_HUE, "Bee hue", 0, 255, 100), 18 | DECL_PARAM_RANGE(P_BEE_SAT, "Bee saturation", 0, 255, 0), 19 | }; 20 | 21 | typedef struct 22 | { 23 | size_t x, y; 24 | size_t flower_x, flower_y; 25 | uint8_t flower_hue; 26 | } bee_t; 27 | 28 | static bee_t bees[MAX_BEES]; 29 | 30 | static rgb_t bee_color; 31 | 32 | static void change_flower(framebuffer_t *fb, uint8_t bee) 33 | { 34 | bees[bee].flower_x = random8_to(fb->width); 35 | bees[bee].flower_y = random8_to(fb->height); 36 | bees[bee].flower_hue = random8(); 37 | } 38 | 39 | esp_err_t effect_crazybees_prepare(framebuffer_t *fb) 40 | { 41 | for (uint8_t i = 0; i < PARAM_VAL(crazybees, P_NUM_BEES); i++) 42 | { 43 | // set bee 44 | bees[i].x = random8_to(fb->width); 45 | bees[i].y = random8_to(fb->height); 46 | // set flower 47 | change_flower(fb, i); 48 | } 49 | bee_color = hsv2rgb_rainbow(hsv_from_values(PARAM_VAL(crazybees, P_BEE_HUE), PARAM_VAL(crazybees, P_BEE_SAT), 255)); 50 | return ESP_OK; 51 | } 52 | 53 | esp_err_t effect_crazybees_run(framebuffer_t *fb) 54 | { 55 | CHECK(fb_begin(fb)); 56 | 57 | fb_fade(fb, 8); 58 | for (uint8_t i = 0; i < PARAM_VAL(crazybees, P_NUM_BEES); i++) 59 | { 60 | // move bee 61 | if (bees[i].x > bees[i].flower_x) bees[i].x--; 62 | if (bees[i].y > bees[i].flower_y) bees[i].y--; 63 | if (bees[i].x < bees[i].flower_x) bees[i].x++; 64 | if (bees[i].y < bees[i].flower_y) bees[i].y++; 65 | 66 | // bingo, change flower 67 | if (bees[i].x == bees[i].flower_x && bees[i].y == bees[i].flower_y) 68 | change_flower(fb, i); 69 | 70 | // draw bee 71 | fb_set_pixel_rgb(fb, bees[i].x, bees[i].y, bee_color); 72 | 73 | // draw flower 74 | hsv_t c = { .h = bees[i].flower_hue, .s = 255, .v = 255 }; 75 | fb_set_pixel_hsv(fb, bees[i].flower_x - 1, bees[i].flower_y, c); 76 | fb_set_pixel_hsv(fb, bees[i].flower_x, bees[i].flower_y - 1, c); 77 | fb_set_pixel_hsv(fb, bees[i].flower_x + 1, bees[i].flower_y, c); 78 | fb_set_pixel_hsv(fb, bees[i].flower_x, bees[i].flower_y + 1, c); 79 | } 80 | fb_blur2d(fb, 16); 81 | 82 | return fb_end(fb); 83 | } 84 | -------------------------------------------------------------------------------- /main/effects/nuclear.c: -------------------------------------------------------------------------------- 1 | /** 2 | * "Nuclear Noise" 3 | * 4 | * Author: Stepko 5 | * https://editor.soulmatelights.com/gallery/1569-radialnuclearnoise 6 | * 7 | * Note: only even-sized framebuffers are supported 8 | */ 9 | #include "effects/nuclear.h" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #define P_SPEED 0 17 | 18 | EFFECT_PARAMS(nuclear, 1) = { 19 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 10, 3), 20 | }; 21 | 22 | typedef struct { 23 | uint8_t angle; 24 | uint8_t radius; 25 | } map_item_t; 26 | 27 | #define MAP_XY(x, y) (map[((y) * fb->width + (x))]) 28 | 29 | #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) 30 | 31 | static map_item_t *map = NULL; 32 | static float mmap = 0.0f; 33 | static uint16_t t = 0; 34 | 35 | esp_err_t effect_nuclear_prepare(framebuffer_t *fb) 36 | { 37 | CHECK_ARG(fb); 38 | 39 | if (!map) map = calloc(fb->width * fb->height, sizeof(map_item_t)); 40 | if (!map) return ESP_ERR_NO_MEM; 41 | 42 | int center_x = (int)fb->width / 2; 43 | int center_y = (int)fb->height / 2; 44 | 45 | mmap = 255.0f / MAX(fb->width, fb->height); 46 | 47 | for (int x = -center_x; x < center_x; x++) 48 | for (int y = -center_y; y < center_y; y++) 49 | { 50 | float xf = (float)x; 51 | float yf = (float)y; 52 | MAP_XY(x + center_x, y + center_y).angle = (uint8_t)(128 * (atan2f(yf, xf) / (float)M_PI)); 53 | MAP_XY(x + center_x, y + center_y).radius = (uint8_t)(hypotf(xf, yf) * mmap); 54 | } 55 | 56 | t = 0; 57 | 58 | return ESP_OK; 59 | } 60 | 61 | esp_err_t effect_nuclear_run(framebuffer_t *fb) 62 | { 63 | CHECK(fb_begin(fb)); 64 | 65 | t += PARAM_VAL(nuclear, P_SPEED); 66 | 67 | uint16_t t1 = t / 2; 68 | for (size_t x = 0; x < fb->width; x++) 69 | for (size_t y = 0; y < fb->height; y++) 70 | { 71 | map_item_t i = MAP_XY(x, y); 72 | uint8_t angle = sin8(t1 / 2 + i.angle * 3); 73 | uint8_t radius = (i.radius) * 2 - t; 74 | 75 | uint8_t noise[3] = { 76 | inoise8_3d(angle, radius, t1), 77 | inoise8_3d(angle, 12032 + t1, radius), 78 | inoise8_3d(radius, 120021 + t1, angle) 79 | }; 80 | for (uint8_t c = 0; c < 3; c++) 81 | noise[c] = noise[c] < 128 82 | ? 0 83 | : constrain((noise[c] - 128) * 3, 0, 255); 84 | fb_set_pixel_rgb(fb, x, y, rgb_from_values(noise[0], noise[1], noise[2])); 85 | } 86 | 87 | return fb_end(fb); 88 | } 89 | -------------------------------------------------------------------------------- /main/settings.h: -------------------------------------------------------------------------------- 1 | #ifndef MEEF_SETTINGS_H_ 2 | #define MEEF_SETTINGS_H_ 3 | 4 | #include "utils/common.h" 5 | #include 6 | 7 | typedef enum 8 | { 9 | MATRIX_ROTATION_0 = 0, 10 | MATRIX_ROTATION_90, 11 | MATRIX_ROTATION_180, 12 | MATRIX_ROTATION_270 13 | } matrix_rotation_t; 14 | 15 | typedef struct 16 | { 17 | struct 18 | { 19 | char devicename[16]; 20 | } device; 21 | struct 22 | { 23 | uint32_t mode; 24 | bool wifi_present; 25 | bool wifi_enabled; 26 | bool wifi_conected; 27 | bool STA_conected; 28 | char STA_MAC[16]; 29 | struct 30 | { 31 | bool dhcp; 32 | char ip[16]; 33 | char staip[16]; 34 | char netmask[16]; 35 | char gateway[16]; 36 | char dns[16]; 37 | } ip; 38 | wifi_ap_config_t ap; 39 | wifi_sta_config_t sta; 40 | } wifi; 41 | struct 42 | { 43 | bool zigbee_present; 44 | bool zigbee_enabled; 45 | bool zigbee_conected; 46 | bool zigbee_dc_power; 47 | bool zigbee_router; 48 | bool zigbee_light_sleep; 49 | uint8_t lastBatteryPercentageRemaining; 50 | char modelname[16]; 51 | char manufactuer[16]; 52 | char manufactuer_id[16]; 53 | 54 | } zigbee; 55 | struct 56 | { 57 | bool mqtt_enabled; 58 | bool mqtt_conected; 59 | char server[32]; 60 | int port; 61 | char prefx[64]; 62 | char user[23]; 63 | char password[32]; 64 | char path[64]; 65 | 66 | } mqtt; 67 | struct 68 | { 69 | uint8_t block_width; 70 | uint8_t block_height; 71 | uint8_t h_blocks; 72 | uint8_t v_blocks; 73 | uint8_t type; 74 | uint8_t rotation; 75 | uint32_t current_limit; 76 | } leds; 77 | } system_settings_t; 78 | 79 | extern system_settings_t sys_settings; 80 | 81 | typedef struct 82 | { 83 | uint8_t fps; 84 | uint8_t brightness; 85 | size_t effect; 86 | } volatile_settings_t; 87 | 88 | extern volatile_settings_t vol_settings; 89 | 90 | esp_err_t settings_init(); 91 | 92 | esp_err_t sys_settings_reset_nvs(); 93 | 94 | esp_err_t sys_settings_load_nvs(); 95 | 96 | esp_err_t sys_settings_save_nvs(); 97 | 98 | esp_err_t sys_settings_save_spiffs(); 99 | 100 | esp_err_t vol_settings_reset(); 101 | 102 | esp_err_t vol_settings_load(); 103 | 104 | esp_err_t vol_settings_save(); 105 | 106 | void sys_settings_load_spiffs(cJSON *json_data); 107 | 108 | #endif /* MEEF_SETTINGS_H_ */ 109 | -------------------------------------------------------------------------------- /main/effects/metaballs.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Metaballs effect 3 | * 4 | * Author: Yaroslaw Turbin 02.09.2020 (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | * 6 | * https://wokwi.com/arduino/libraries/FastLED/Metaballs 7 | */ 8 | #include "effects/metaballs.h" 9 | #include "palettes.h" 10 | 11 | #include 12 | 13 | #define MAX_BALLS 6 14 | #define MAX_PALETTES 3 15 | 16 | #define P_PALETTE 0 17 | #define P_COUNT 1 18 | 19 | EFFECT_PARAMS(metaballs, 2) = { 20 | DECL_PARAM_RANGE(P_PALETTE, "Palette", 0, MAX_PALETTES - 1, 0), 21 | DECL_PARAM_RANGE(P_COUNT, "Balls", 2, MAX_BALLS, 3), 22 | }; 23 | 24 | enum { 25 | PAL_FIRE = 0, 26 | PAL_BLUE, 27 | PAL_GREEN, 28 | }; 29 | 30 | #define PALETTE_SIZE 6 31 | 32 | static const rgb_t _palettes[MAX_PALETTES][PALETTE_SIZE] = { 33 | [PAL_FIRE] = { C_BLACK, C_BLACK, C_RED, C_YELLOW, C_YELLOW, C_WHITE }, 34 | [PAL_BLUE] = { C_BLACK, C_BLACK, C_DARK_BLUE, C_CYAN, C_CYAN, C_WHITE }, 35 | [PAL_GREEN] = { C_BLACK, C_BLACK, C_DARK_GREEN, C_SPRING_GREEN, C_SPRING_GREEN, C_WHITE }, 36 | }; 37 | 38 | typedef struct { 39 | uint8_t bpm_x, bpm_y; 40 | uint8_t phase; 41 | uint8_t x, y; 42 | } ball_t; 43 | 44 | ball_t balls[MAX_BALLS]; 45 | 46 | static uint8_t dist(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) 47 | { 48 | int a = y2 - y1; 49 | int b = x2 - x1; 50 | uint16_t s = sqrt16(a * a + b * b); 51 | return s ? 255 / s : 255; 52 | } 53 | 54 | esp_err_t effect_metaballs_prepare(framebuffer_t *fb) 55 | { 56 | for (size_t i = 0; i < PARAM_VAL(metaballs, P_COUNT); i++) 57 | { 58 | balls[i].bpm_x = random8_between(10, 40); 59 | balls[i].bpm_y = random8_between(10, 40); 60 | balls[i].phase = 256 / MAX_BALLS * i; 61 | } 62 | 63 | return ESP_OK; 64 | } 65 | 66 | esp_err_t effect_metaballs_run(framebuffer_t *fb) 67 | { 68 | CHECK(fb_begin(fb)); 69 | 70 | for (size_t i = 0; i < PARAM_VAL(metaballs, P_COUNT); i++) 71 | { 72 | balls[i].x = beatsin8(balls[i].bpm_x, 0, fb->width - 1, 0, balls[i].phase); 73 | balls[i].y = beatsin8(balls[i].bpm_y, 0, fb->height - 1, 0, balls[i].phase); 74 | } 75 | 76 | for (int i = 0; i < fb->width; i++) 77 | { 78 | for (int j = 0; j < fb->height; j++) 79 | { 80 | uint8_t sum = 0; 81 | for (size_t b = 0; b < PARAM_VAL(metaballs, P_COUNT); b++) 82 | sum = qadd8(sum, dist(i, j, balls[b].x, balls[b].y)); 83 | 84 | fb_set_pixel_rgb(fb, i, j, color_from_palette_rgb(_palettes[PARAM_VAL(metaballs, P_PALETTE)], PALETTE_SIZE, qsub8(sum, 32), 255, true)); 85 | } 86 | } 87 | 88 | fb_blur2d(fb, 32); 89 | 90 | return fb_end(fb); 91 | } 92 | -------------------------------------------------------------------------------- /main/effects/holiday.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Holiday lights 3 | * 4 | * Author: stepko 5 | * 6 | * https://wokwi.com/arduino/projects/287698321325163021 7 | */ 8 | #include "effects/holiday.h" 9 | #include 10 | 11 | #define P_MODE 0 12 | #define P_SPEED 1 13 | 14 | EFFECT_PARAMS(holiday, 2) = { 15 | DECL_PARAM_RANGE(P_MODE, "Mode", 0, 3, 0), 16 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 20, 8), 17 | }; 18 | 19 | static uint8_t hue = 0; 20 | 21 | static void wave(framebuffer_t *fb) 22 | { 23 | fb_fade(fb, 2); 24 | 25 | uint8_t scale = beatsin8(1, 1, 255, 0, 0); 26 | for (int i = 0; i < fb->width - 1; i++) 27 | { 28 | uint16_t fx = beatsin16(i * PARAM_VAL(holiday, P_SPEED), i * 5, ((fb->width - 1) * 10 - 2) - (i * 5 + 2), 0, 0); 29 | fb_set_pixelf_hsv(fb, (float)fx / 10, i, hsv_from_values(hue + i * scale, 255, 100)); 30 | } 31 | } 32 | 33 | static void radar(framebuffer_t *fb) 34 | { 35 | fb_fade(fb, 2); 36 | 37 | uint8_t scale = beatsin8(1, 1, 255, 0, 0); 38 | for (int i = 0; i < fb->width - 1; i++) 39 | { 40 | uint16_t fx = beatsin16(PARAM_VAL(holiday, P_SPEED) * 5, i * 2.5, (fb->width - 1) * 5 - i * 2.5, 0, 0); 41 | fb_set_pixelf_hsv(fb, (float)fx / 5, i, hsv_from_values(hue + i * scale, 255, 255)); 42 | } 43 | } 44 | 45 | static void sparks(framebuffer_t *fb) 46 | { 47 | fb_fade(fb, 3); 48 | fb_blur2d(fb, 20); 49 | 50 | for (int i = 0; i < fb->width - 1; i++) 51 | { 52 | uint8_t fx = random8_between(i * 2, (fb->width - 1) * 4 - i * 2); 53 | rgb_t c; 54 | fb_get_pixel_rgb(fb, fx / 4, i, &c); 55 | if (rgb_is_zero(c)) 56 | fb_set_pixelf_hsv(fb, (float)fx / 4, i, hsv_from_values(random8(), 255, 255)); 57 | } 58 | } 59 | 60 | static void tree(framebuffer_t *fb) 61 | { 62 | fb_fade(fb, 5); 63 | 64 | for (int i = 0; i < fb->width - 1; i++) 65 | { 66 | uint16_t fx = beatsin16(i * PARAM_VAL(holiday, P_SPEED), i * 2, ((fb->width - 1) * 4 - 2) - (i * 2 + 2), 0, 0); 67 | fb_set_pixelf_hsv(fb, (float)fx / 4, i, random8_to(10) == 0 68 | ? hsv_from_values(random8(), random8_between(32, 255), 255) 69 | : hsv_from_values(100, 255, 100)); 70 | } 71 | } 72 | 73 | esp_err_t effect_holiday_run(framebuffer_t *fb) 74 | { 75 | CHECK(fb_begin(fb)); 76 | 77 | hue++; 78 | switch (PARAM_VAL(holiday, P_MODE)) 79 | { 80 | case HOLIDAY_RADAR: 81 | radar(fb); 82 | break; 83 | case HOLIDAY_SPARKS: 84 | sparks(fb); 85 | break; 86 | case HOLIDAY_TREE: 87 | tree(fb); 88 | break; 89 | default: 90 | wave(fb); 91 | } 92 | 93 | return fb_end(fb); 94 | } 95 | -------------------------------------------------------------------------------- /main/effects/spaceships.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Flight of spaceships effect 3 | * 4 | * Author: stepko 5 | * https://wokwi.com/projects/289609636203463176 6 | */ 7 | #include "effects/spaceships.h" 8 | 9 | #include 10 | 11 | #define P_COUNT 0 12 | #define P_DIRECTION_TIME 1 13 | 14 | EFFECT_PARAMS(spaceships, 2) = { 15 | DECL_PARAM_RANGE(P_COUNT, "Number of ships", 2, 16, 8), 16 | DECL_PARAM_RANGE(P_DIRECTION_TIME, "Direction change time", 1, 60, 5), 17 | }; 18 | 19 | typedef enum { 20 | DIR_UP = 0, 21 | DIR_UP_RIGHT, 22 | DIR_RIGHT, 23 | DIR_DOWN_RIGHT, 24 | DIR_DOWN, 25 | DIR_DOWN_LEFT, 26 | DIR_LEFT, 27 | DIR_UP_LEFT, 28 | 29 | DIR_MAX 30 | } direction_t; 31 | 32 | static direction_t dir = DIR_UP_RIGHT; 33 | static uint32_t last_change = 0; 34 | 35 | esp_err_t effect_spaceships_run(framebuffer_t *fb) 36 | { 37 | CHECK(fb_begin(fb)); 38 | 39 | uint32_t t = esp_timer_get_time() / 1000000; // current time in seconds 40 | if (!last_change) last_change = t; // seconds 41 | 42 | // shift framebuffer in opposite direction 43 | switch (dir) 44 | { 45 | case DIR_UP: 46 | fb_shift(fb, 1, FB_SHIFT_DOWN); 47 | break; 48 | case DIR_UP_RIGHT: 49 | fb_shift(fb, 1, FB_SHIFT_DOWN); 50 | fb_shift(fb, 1, FB_SHIFT_LEFT); 51 | break; 52 | case DIR_RIGHT: 53 | fb_shift(fb, 1, FB_SHIFT_LEFT); 54 | break; 55 | case DIR_DOWN_RIGHT: 56 | fb_shift(fb, 1, FB_SHIFT_UP); 57 | fb_shift(fb, 1, FB_SHIFT_LEFT); 58 | break; 59 | case DIR_DOWN: 60 | fb_shift(fb, 1, FB_SHIFT_UP); 61 | break; 62 | case DIR_DOWN_LEFT: 63 | fb_shift(fb, 1, FB_SHIFT_UP); 64 | fb_shift(fb, 1, FB_SHIFT_RIGHT); 65 | break; 66 | case DIR_LEFT: 67 | fb_shift(fb, 1, FB_SHIFT_RIGHT); 68 | break; 69 | case DIR_UP_LEFT: 70 | fb_shift(fb, 1, FB_SHIFT_DOWN); 71 | fb_shift(fb, 1, FB_SHIFT_RIGHT); 72 | break; 73 | default: 74 | break; 75 | } 76 | 77 | for (uint8_t i = 0; i < PARAM_VAL(spaceships, P_COUNT); i++) 78 | fb_set_pixelf_hsv(fb, 79 | beatsin8(12 + i, 2, fb->width - 3, 0, 0), 80 | beatsin8(15 + i, 2, fb->height - 3, 0, 0), 81 | hsv_from_values(beatsin8(12 + i, 0, 255, 0, 0), 255, 255)); 82 | fb_blur2d(fb, 32); 83 | 84 | if (t - last_change >= PARAM_VAL(spaceships, P_DIRECTION_TIME)) 85 | { 86 | last_change = t; 87 | dir += random8_to(2) ? 1 : -1; 88 | if (dir >= DIR_MAX) 89 | dir = DIR_UP; 90 | } 91 | 92 | return fb_end(fb); 93 | } 94 | -------------------------------------------------------------------------------- /main/utils/spiffs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "esp_log.h" 4 | #include "esp_err.h" 5 | #include "esp_spiffs.h" 6 | #include "nvs_flash.h" 7 | #include "nvs.h" 8 | #include "spiffs.h" 9 | #define STORAGE_NAMESPACE "nvs_storage" 10 | 11 | static const char *TAG_spiffs = "storage"; 12 | /* Function to initialize SPIFFS for web_data */ 13 | esp_err_t mount_storage(const char *base_path) 14 | { 15 | ESP_LOGI(TAG_spiffs, "Initializing SPIFFS"); 16 | esp_vfs_spiffs_conf_t conf = { 17 | .base_path = base_path, 18 | .partition_label = NULL, 19 | .max_files = 5, // This sets the maximum number of files that can be open at the same time 20 | .format_if_mount_failed = true}; 21 | 22 | esp_err_t ret = esp_vfs_spiffs_register(&conf); 23 | if (ret != ESP_OK) 24 | { 25 | if (ret == ESP_FAIL) 26 | { 27 | ESP_LOGE(TAG_spiffs, "Failed to mount or format filesystem"); 28 | } 29 | else if (ret == ESP_ERR_NOT_FOUND) 30 | { 31 | ESP_LOGE(TAG_spiffs, "Failed to find SPIFFS partition"); 32 | } 33 | else 34 | { 35 | ESP_LOGE(TAG_spiffs, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret)); 36 | } 37 | return ret; 38 | } 39 | 40 | size_t total = 0, used = 0; 41 | ret = esp_spiffs_info(NULL, &total, &used); 42 | if (ret != ESP_OK) 43 | { 44 | ESP_LOGE(TAG_spiffs, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret)); 45 | return ret; 46 | } 47 | 48 | ESP_LOGI(TAG_spiffs, "Partition size: total: %dKb, used: %dKb", total / 1024, used / 1024); 49 | return ESP_OK; 50 | } 51 | 52 | // Запись в файл 53 | static int writeFile(char *fname, char *mode, char *buf) 54 | { 55 | FILE *fd = fopen(fname, mode); 56 | if (fd == NULL) 57 | { 58 | ESP_LOGE("[write]", "fopen failed"); 59 | return -1; 60 | } 61 | int len = strlen(buf); 62 | int res = fwrite(buf, 1, len, fd); 63 | if (res != len) 64 | { 65 | ESP_LOGE("[write]", "fwrite failed: %d <> %d ", res, len); 66 | res = fclose(fd); 67 | if (res) 68 | { 69 | ESP_LOGE("[write]", "fclose failed: %d", res); 70 | return -2; 71 | } 72 | return -3; 73 | } 74 | res = fclose(fd); 75 | if (res) 76 | { 77 | ESP_LOGE("[write]", "fclose failed: %d", res); 78 | return -4; 79 | } 80 | return 0; 81 | } 82 | 83 | void writeJSONtoFile(char fileName, char *json_data) 84 | { 85 | cJSON *body_json = cJSON_Parse(json_data); 86 | char *string = cJSON_Print(body_json); 87 | const char *base_path = "/spiffs_storage/"; 88 | strcat(base_path, fileName); 89 | writeFile(base_path, "w", string); 90 | free(json_data); 91 | } 92 | void deleteFile(const char *fileName) 93 | { 94 | if (remove(fileName) != 0) 95 | { 96 | perror("Error deleting file"); 97 | } 98 | else 99 | { 100 | ESP_LOGI(TAG_spiffs, "File deleted successfully: %s\n", fileName); 101 | } 102 | } -------------------------------------------------------------------------------- /main/effects/twister.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Oldschool twister demo effect 3 | * 4 | * Author: Yaroslaw Turbin (https://vk.com/ldirko, https://www.reddit.com/user/ldirko/) 5 | * 6 | * https://wokwi.com/arduino/projects/297732081748804105 7 | * 8 | * Max supported framebuffer size is 256x256 9 | */ 10 | #include "effects/twister.h" 11 | 12 | #include 13 | #include 14 | #include 15 | #include "palettes.h" 16 | 17 | #define P_SPEED 0 18 | #define P_BORDER 1 19 | #define P_IRIDESCENT 2 20 | 21 | EFFECT_PARAMS(twister, 3) = { 22 | DECL_PARAM_RANGE(P_SPEED, "Speed", 0, 40, 30), 23 | DECL_PARAM_BOOL(P_BORDER, "Add black border", 1), 24 | DECL_PARAM_BOOL(P_IRIDESCENT, "Iridescent colors", 0), 25 | }; 26 | 27 | static const rgb_t c_black = C_BLACK; 28 | 29 | static void horizontal_line(framebuffer_t *fb, uint8_t x1, uint8_t x2, uint8_t y, hsv_t color) 30 | { 31 | uint8_t steps = abs8(x2 - x1) + 1; 32 | rgb_t rgb = hsv2rgb_rainbow(color); 33 | 34 | for (uint16_t i = 1; i <= steps; i++) 35 | { 36 | uint8_t dx = lerp8by8(x1, x2, i * 255 / steps); 37 | rgb_t pixel = rgb_scale_video(rgb, (steps - i) * 255 / steps); 38 | fb_set_pixel_rgb(fb, dx, y, pixel); 39 | } 40 | 41 | if (PARAM_VAL(twister, P_BORDER)) 42 | { 43 | // add black points at the ends of line 44 | fb_set_pixel_rgb(fb, x1, y, c_black); 45 | fb_set_pixel_rgb(fb, x2, y, c_black); 46 | } 47 | } 48 | 49 | esp_err_t effect_twister_run(framebuffer_t *fb) 50 | { 51 | CHECK(fb_begin(fb)); 52 | 53 | fb_clear(fb); 54 | 55 | uint16_t a = esp_timer_get_time() / 1000 / (41 - PARAM_VAL(twister, P_SPEED)); 56 | 57 | for (size_t i = 0; i < fb->height; i++) 58 | { 59 | uint8_t sin_offs = sin8(i * 8 / M_PI + cos8(a / 2 + i) / 4 + a / 3); 60 | 61 | uint8_t x1 = sin8(sin_offs + a) * fb->width / 255; 62 | uint8_t x2 = sin8(sin_offs + a + 64) * fb->width / 255; 63 | uint8_t x3 = sin8(sin_offs + a + 128) * fb->width / 255; 64 | uint8_t x4 = sin8(sin_offs + a + 192) * fb->width / 255; 65 | x1 = x1 >= fb->width ? fb->width - 1 : x1; 66 | x2 = x2 >= fb->width ? fb->width - 1 : x2; 67 | x3 = x3 >= fb->width ? fb->width - 1 : x3; 68 | x4 = x4 >= fb->width ? fb->width - 1 : x4; 69 | 70 | uint8_t hue = sin8(PARAM_VAL(twister, P_IRIDESCENT) ? a : a / 20); 71 | if (x1 < x2) 72 | horizontal_line(fb, x1, x2, i, hsv_from_values(hue, 255, 255)); 73 | if (x2 < x3) 74 | horizontal_line(fb, x2, x3, i, hsv_from_values(hue + 64, 255, 255)); 75 | if (x3 < x4) 76 | horizontal_line(fb, x3, x4, i, hsv_from_values(hue + 128, 255, 255)); 77 | if (x4 < x1) 78 | horizontal_line(fb, x4, x1, i, hsv_from_values(hue + 192, 255, 255)); 79 | } 80 | 81 | return fb_end(fb); 82 | } 83 | -------------------------------------------------------------------------------- /main/effects/plasma_waves.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Plasma waves effect 3 | * 4 | * Author: Edmund "Skorn" Horn 5 | */ 6 | #include "effects/plasma_waves.h" 7 | 8 | #include 9 | 10 | #define P_SPEED 0 11 | 12 | EFFECT_PARAMS(plasma_waves, 1) = { 13 | DECL_PARAM_RANGE(P_SPEED, "Speed", 1, 255, 40), 14 | }; 15 | 16 | static uint8_t speed; 17 | 18 | static const uint8_t exp_gamma[256] = { 19 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 20 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21 | 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 22 | 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 23 | 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 24 | 12, 13, 13, 14, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 25 | 19, 20, 20, 21, 21, 22, 23, 23, 24, 24, 25, 26, 26, 27, 28, 26 | 28, 29, 30, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 27 | 39, 40, 41, 42, 43, 44, 44, 45, 46, 47, 48, 49, 50, 51, 52, 28 | 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 29 | 68, 70, 71, 72, 73, 74, 75, 77, 78, 79, 80, 82, 83, 84, 85, 30 | 87, 89, 91, 92, 93, 95, 96, 98, 99, 100, 101, 102, 105, 106, 108, 31 | 109, 111, 112, 114, 115, 117, 118, 120, 121, 123, 125, 126, 128, 130, 131, 32 | 133, 135, 136, 138, 140, 142, 143, 145, 147, 149, 151, 152, 154, 156, 158, 33 | 160, 162, 164, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 34 | 190, 192, 194, 196, 198, 200, 202, 204, 207, 209, 211, 213, 216, 218, 220, 35 | 222, 225, 227, 229, 232, 234, 236, 239, 241, 244, 246, 249, 251, 253, 254, 36 | 255 37 | }; 38 | 39 | esp_err_t effect_plasma_waves_prepare(framebuffer_t *fb) 40 | { 41 | speed = 255 - PARAM_VAL(plasma_waves, P_SPEED) + 1; 42 | 43 | return ESP_OK; 44 | } 45 | 46 | esp_err_t effect_plasma_waves_run(framebuffer_t *fb) 47 | { 48 | CHECK(fb_begin(fb)); 49 | 50 | uint8_t t1 = cos8((42 * fb->frame_num) / speed); 51 | uint8_t t2 = cos8((35 * fb->frame_num) / speed); 52 | uint8_t t3 = cos8((38 * fb->frame_num) / speed); 53 | 54 | for (uint16_t y = 0; y < fb->height; y++) 55 | for (uint16_t x = 0; x < fb->width; x++) 56 | { 57 | // Calculate 3 separate plasma waves, one for each color channel 58 | uint8_t r = cos8((x << 3) + (t1 >> 1) + cos8(t2 + (y << 3))); 59 | uint8_t g = cos8((y << 3) + t1 + cos8((t3 >> 2) + (x << 3))); 60 | uint8_t b = cos8((y << 3) + t2 + cos8(t1 + x + (g >> 2))); 61 | 62 | rgb_t c = { 63 | .r = exp_gamma[r], 64 | .g = exp_gamma[g], 65 | .b = exp_gamma[b] 66 | }; 67 | fb_set_pixel_rgb(fb, x, y, c); 68 | } 69 | 70 | return fb_end(fb); 71 | } 72 | -------------------------------------------------------------------------------- /main/effects/input.c: -------------------------------------------------------------------------------- 1 | #include "input.h" 2 | #include 3 | #include "utils/bus.h" 4 | 5 | static const event_type_t event_types[] = { 6 | [BUTTON_PRESSED] = EVENT_BUTTON_PRESSED, 7 | [BUTTON_RELEASED] = EVENT_BUTTON_RELEASED, 8 | [BUTTON_CLICKED] = EVENT_BUTTON_CLICKED, 9 | [BUTTON_PRESSED_LONG] = EVENT_BUTTON_PRESSED_LONG, 10 | }; 11 | 12 | static button_t buttons[INPUT_BTN_MAX] = {0}; 13 | 14 | static void callback(button_t *btn, button_state_t state) 15 | { 16 | bus_send_event(event_types[state], &btn->ctx, sizeof(btn->ctx)); 17 | } 18 | 19 | esp_err_t input_init() 20 | { 21 | /* 22 | buttons[INPUT_BTN_MAIN].gpio = CONFIG_EL_BUTTON_MAIN_GPIO; 23 | buttons[INPUT_BTN_MAIN].internal_pull = CONFIG_EL_BUTTON_PULLUPDOWN; 24 | buttons[INPUT_BTN_MAIN].pressed_level = CONFIG_EL_BUTTON_LEVEL; 25 | buttons[INPUT_BTN_MAIN].autorepeat = false; 26 | buttons[INPUT_BTN_MAIN].callback = callback; 27 | buttons[INPUT_BTN_MAIN].ctx = (void *)INPUT_BTN_MAIN; 28 | CHECK_LOGE(button_init(&buttons[INPUT_BTN_MAIN]), 29 | "Failed init 'Main' button"); 30 | */ 31 | buttons[INPUT_BTN_RESET].gpio = CONFIG_EL_BUTTON_RESET_GPIO; 32 | buttons[INPUT_BTN_RESET].internal_pull = CONFIG_EL_BUTTON_PULLUPDOWN; 33 | buttons[INPUT_BTN_RESET].pressed_level = CONFIG_EL_BUTTON_RESET_LEVEL; 34 | buttons[INPUT_BTN_RESET].autorepeat = false; 35 | buttons[INPUT_BTN_RESET].callback = callback; 36 | buttons[INPUT_BTN_RESET].ctx = (void *)INPUT_BTN_RESET; 37 | CHECK_LOGE(button_init(&buttons[INPUT_BTN_RESET]), 38 | "Failed init 'Reset' button"); 39 | /* 40 | buttons[INPUT_BTN_UP].gpio = CONFIG_EL_BUTTON_UP_GPIO; 41 | buttons[INPUT_BTN_UP].internal_pull = CONFIG_EL_BUTTON_PULLUPDOWN; 42 | buttons[INPUT_BTN_UP].pressed_level = CONFIG_EL_BUTTON_LEVEL; 43 | buttons[INPUT_BTN_UP].autorepeat = true; 44 | buttons[INPUT_BTN_UP].callback = callback; 45 | buttons[INPUT_BTN_UP].ctx = (void *)INPUT_BTN_UP; 46 | CHECK_LOGE(button_init(&buttons[INPUT_BTN_UP]), 47 | "Failed init 'Up' button"); 48 | 49 | buttons[INPUT_BTN_DOWN].gpio = CONFIG_EL_BUTTON_DOWN_GPIO; 50 | buttons[INPUT_BTN_DOWN].internal_pull = CONFIG_EL_BUTTON_PULLUPDOWN; 51 | buttons[INPUT_BTN_DOWN].pressed_level = CONFIG_EL_BUTTON_LEVEL; 52 | buttons[INPUT_BTN_DOWN].autorepeat = true; 53 | buttons[INPUT_BTN_DOWN].callback = callback; 54 | buttons[INPUT_BTN_DOWN].ctx = (void *)INPUT_BTN_DOWN; 55 | CHECK_LOGE(button_init(&buttons[INPUT_BTN_DOWN]), 56 | "Failed init 'Down' button"); 57 | */ 58 | return ESP_OK; 59 | } 60 | -------------------------------------------------------------------------------- /main/modules/sensors/siht/sensor_siht.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "freertos/FreeRTOS.h" 3 | #include "freertos/task.h" 4 | #include "esp_log.h" 5 | #include "esp_err.h" 6 | #include "cJSON.h" 7 | #include "string.h" 8 | #include "../../../utils/send_data.h" 9 | #include "../../sensor_init.h" 10 | #include "si7021.h" 11 | 12 | static const char *TAG = "sensor_siht"; 13 | 14 | static void sensor_siht_task(void *pvParameters) 15 | { 16 | TaskParameters *params = (TaskParameters *)pvParameters; 17 | char *param_id = params->param_id; 18 | char id[30] = ""; 19 | strcpy(id, param_id); 20 | gpio_num_t param_pin_SCL = params->param_pin_SCL; 21 | gpio_num_t param_pin_SDA = params->param_pin_SDA; 22 | 23 | char *param_cluster = params->param_cluster; 24 | char cluster[30] = ""; 25 | strcpy(cluster, param_cluster); 26 | 27 | int param_ep = params->param_ep; 28 | int param_int = params->param_int * 1000; 29 | 30 | i2c_dev_t dev; 31 | memset(&dev, 0, sizeof(i2c_dev_t)); 32 | 33 | esp_err_t init_desc_err = si7021_init_desc(&dev, 0, param_pin_SDA, param_pin_SCL); 34 | if (init_desc_err != ESP_OK) { 35 | ESP_LOGE(TAG, "Failed to initialize device descriptor: %s", esp_err_to_name(init_desc_err)); 36 | vTaskDelete(NULL); 37 | } 38 | 39 | float temperature, humidity; 40 | 41 | vTaskDelay(pdMS_TO_TICKS(1000)); // Wait for the device to boot 42 | 43 | while (1) 44 | { 45 | esp_err_t res = si7021_measure_temperature(&dev, &temperature); 46 | if (res != ESP_OK) { 47 | ESP_LOGE(TAG, "Could not measure temperature: %d (%s)", res, esp_err_to_name(res)); 48 | } else { 49 | ESP_LOGI(TAG, "Temperature: %.2f", temperature); 50 | } 51 | 52 | res = si7021_measure_humidity(&dev, &humidity); 53 | if (res != ESP_OK) { 54 | ESP_LOGE(TAG, "Could not measure humidity: %d (%s)", res, esp_err_to_name(res)); 55 | } else { 56 | ESP_LOGI(TAG, "Humidity: %.2f", humidity); 57 | } 58 | 59 | if (strcmp(cluster, "all") == 0) 60 | { 61 | uint16_t si7021_temp = (uint16_t)(temperature * 100); 62 | send_data(si7021_temp, param_ep, "temperature"); 63 | 64 | uint16_t si7021_humid = (uint16_t)(humidity * 100); 65 | send_data(si7021_humid, param_ep, "humidity"); 66 | } 67 | else if (strcmp(cluster, "temperature") == 0) 68 | { 69 | uint16_t si7021_val = (uint16_t)(temperature * 100); 70 | send_data(si7021_val, param_ep, cluster); 71 | } 72 | else if (strcmp(cluster, "humidity") == 0) 73 | { 74 | uint16_t si7021_val = (uint16_t)(humidity * 100); 75 | send_data(si7021_val, param_ep, cluster); 76 | } 77 | 78 | vTaskDelay(param_int / portTICK_PERIOD_MS); 79 | } 80 | } 81 | 82 | void sensor_siht(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams) 83 | { 84 | ESP_LOGW(TAG, "Task: %s created. Cluster: %s EP: %d", sensor, cluster, EP); 85 | xTaskCreate(sensor_siht_task, taskParams->param_id, 4096, taskParams, 5, NULL); 86 | } -------------------------------------------------------------------------------- /components/color/hsv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2013 FastLED 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * @file hsv.h 26 | * @defgroup hsv hsv 27 | * @{ 28 | * 29 | * Functions for HSV colors 30 | * 31 | * Ported from FastLED 32 | * 33 | * MIT Licensed as described in the file LICENSE 34 | */ 35 | #ifndef __COLOR_HSV_H__ 36 | #define __COLOR_HSV_H__ 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define HUE_RED 0 47 | #define HUE_ORANGE 32 48 | #define HUE_YELLOW 64 49 | #define HUE_GREEN 96 50 | #define HUE_AQUA 128 51 | #define HUE_BLUE 160 52 | #define HUE_PURPLE 192 53 | #define HUE_PINK 224 54 | 55 | typedef enum 56 | { 57 | COLOR_FORWARD_HUES = 0, 58 | COLOR_BACKWARD_HUES, 59 | COLOR_SHORTEST_HUES, 60 | COLOR_LONGEST_HUES 61 | } color_gradient_direction_t; 62 | 63 | /// HSV color representation 64 | typedef struct 65 | { 66 | union { 67 | uint8_t h; 68 | uint8_t hue; 69 | }; 70 | union { 71 | uint8_t s; 72 | uint8_t sat; 73 | uint8_t saturation; 74 | }; 75 | union { 76 | uint8_t v; 77 | uint8_t val; 78 | uint8_t value; 79 | }; 80 | } hsv_t; 81 | 82 | /// This allows testing a HSV for zero-ness 83 | static inline bool hsv_is_zero(hsv_t a) 84 | { 85 | return !(a.h | a.s | a.v); 86 | } 87 | 88 | /// Create HSV color from values 89 | static inline hsv_t hsv_from_values(uint8_t h, uint8_t s, uint8_t v) 90 | { 91 | hsv_t res = { 92 | .h = h, 93 | .s = s, 94 | .v = v 95 | }; 96 | return res; 97 | } 98 | 99 | /// Computes a new color blended some fraction of the way between two other 100 | /// colors. 101 | hsv_t blend(hsv_t existing, hsv_t overlay, fract8 amount, color_gradient_direction_t direction); 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif 106 | 107 | /**@}*/ 108 | 109 | #endif /* __COLOR_HSV_H__ */ 110 | -------------------------------------------------------------------------------- /components/esp_idf_lib_helpers/esp_idf_lib_helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Tomoyuki Sakurai 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #if !defined(__ESP_IDF_LIB_HELPERS__H__) 18 | #define __ESP_IDF_LIB_HELPERS__H__ 19 | 20 | /* XXX this header file does not need to include freertos/FreeRTOS.h. 21 | * but without it, ESP8266 RTOS SDK does not include `sdkconfig.h` in correct 22 | * order. as this header depends on sdkconfig.h, sdkconfig.h must be included 23 | * first. however, the SDK includes this header first, then includes 24 | * `sdkconfig.h` when freertos/FreeRTOS.h is not explicitly included. an 25 | * evidence can be found in `build/${COMPONENT}/${COMPONENT}.d` in a failed 26 | * build. 27 | */ 28 | #include 29 | #include 30 | 31 | #if !defined(ESP_IDF_VERSION) || !defined(ESP_IDF_VERSION_VAL) 32 | #error Unknown ESP-IDF/ESP8266 RTOS SDK version 33 | #endif 34 | 35 | /* Minimal supported version for ESP32, ESP32S2 */ 36 | #define HELPER_ESP32_MIN_VER ESP_IDF_VERSION_VAL(3, 3, 5) 37 | /* Minimal supported version for ESP8266 */ 38 | #define HELPER_ESP8266_MIN_VER ESP_IDF_VERSION_VAL(3, 3, 0) 39 | 40 | /* HELPER_TARGET_IS_ESP32 41 | * 1 when the target is esp32 42 | */ 43 | #if defined(CONFIG_IDF_TARGET_ESP32) \ 44 | || defined(CONFIG_IDF_TARGET_ESP32S2) \ 45 | || defined(CONFIG_IDF_TARGET_ESP32S3) \ 46 | || defined(CONFIG_IDF_TARGET_ESP32C2) \ 47 | || defined(CONFIG_IDF_TARGET_ESP32C3) \ 48 | || defined(CONFIG_IDF_TARGET_ESP32C6) 49 | #define HELPER_TARGET_IS_ESP32 (1) 50 | #define HELPER_TARGET_IS_ESP8266 (0) 51 | 52 | /* HELPER_TARGET_IS_ESP8266 53 | * 1 when the target is esp8266 54 | */ 55 | #elif defined(CONFIG_IDF_TARGET_ESP8266) 56 | #define HELPER_TARGET_IS_ESP32 (0) 57 | #define HELPER_TARGET_IS_ESP8266 (1) 58 | #else 59 | #error BUG: cannot determine the target 60 | #endif 61 | 62 | #if HELPER_TARGET_IS_ESP32 && ESP_IDF_VERSION < HELPER_ESP32_MIN_VER 63 | #error Unsupported ESP-IDF version. Please update! 64 | #endif 65 | 66 | #if HELPER_TARGET_IS_ESP8266 && ESP_IDF_VERSION < HELPER_ESP8266_MIN_VER 67 | #error Unsupported ESP8266 RTOS SDK version. Please update! 68 | #endif 69 | 70 | /* show the actual values for debugging */ 71 | #if DEBUG 72 | #define VALUE_TO_STRING(x) #x 73 | #define VALUE(x) VALUE_TO_STRING(x) 74 | #define VAR_NAME_VALUE(var) #var "=" VALUE(var) 75 | #pragma message(VAR_NAME_VALUE(CONFIG_IDF_TARGET_ESP32C3)) 76 | #pragma message(VAR_NAME_VALUE(CONFIG_IDF_TARGET_ESP32S2)) 77 | #pragma message(VAR_NAME_VALUE(CONFIG_IDF_TARGET_ESP32)) 78 | #pragma message(VAR_NAME_VALUE(CONFIG_IDF_TARGET_ESP8266)) 79 | #pragma message(VAR_NAME_VALUE(ESP_IDF_VERSION_MAJOR)) 80 | #endif 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /main/modules/sensors/dht/sensor_dht.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "freertos/FreeRTOS.h" 3 | #include "freertos/task.h" 4 | #include "esp_log.h" 5 | #include "esp_err.h" 6 | #include "cJSON.h" 7 | #include "string.h" 8 | #include "../../../utils/send_data.h" 9 | #include "../../sensor_init.h" 10 | #include "sensor_dht.h" 11 | #include "dht.h" 12 | 13 | static const char *TAG = "sensor_dht"; 14 | 15 | static void sensor_dht_task(void *pvParameters) 16 | { 17 | 18 | TaskParameters *params = (TaskParameters *)pvParameters; 19 | char *param_id = params->param_id; 20 | char id[30] = ""; 21 | strcpy(id, param_id); 22 | int param_pin = params->param_pin; 23 | char *param_cluster = params->param_cluster; 24 | char cluster[30] = ""; 25 | strcpy(cluster, param_cluster); 26 | int param_ep = params->param_ep; 27 | int param_int = params->param_int * 1000; 28 | char *param_sensor_type = params->param_sensor_type; 29 | char sensor_type[30] = ""; 30 | strcpy(sensor_type, param_sensor_type); 31 | 32 | if (strcmp(sensor_type, "DHT11") == 0) 33 | { 34 | #define SENSOR_TYPE DHT_TYPE_DHT11 35 | } 36 | else if (strcmp(sensor_type, "AM2301") == 0) 37 | { 38 | #define SENSOR_TYPE DHT_TYPE_AM2301 39 | } 40 | else if (strcmp(sensor_type, "SI7021") == 0) 41 | { 42 | #define SENSOR_TYPE DHT_TYPE_SI7021 43 | } 44 | 45 | float temperature, humidity; 46 | 47 | #ifdef CONFIG_EXAMPLE_INTERNAL_PULLUP 48 | gpio_set_pull_mode(dht_gpio, GPIO_PULLUP_ONLY); 49 | #endif 50 | 51 | while (1) 52 | { 53 | 54 | if (dht_read_float_data(SENSOR_TYPE, param_pin, &humidity, &temperature) == ESP_OK) 55 | { 56 | // ESP_LOGI(TAG, "Humidity: %.1f%% Temp: %.1fC", humidity, temperature); 57 | // ESP_LOGI(TAG, "dht_cluster: %s", cluster); 58 | // ESP_LOGI(TAG, "dht_sensor_type: %s", sensor_type); 59 | if (strcmp(cluster, "all") == 0) 60 | { 61 | ESP_LOGI(TAG, "Humidity: %.1f%% Temp: %.1fC EP: %d: ", humidity, temperature, param_ep); 62 | uint16_t dht_val = (uint16_t)(temperature * 100); 63 | send_data(dht_val, param_ep, "temperature"); 64 | dht_val = (uint16_t)(humidity * 100); 65 | send_data(dht_val, param_ep, "humidity"); 66 | } 67 | else if (strcmp(cluster, "temperature") == 0) 68 | { 69 | ESP_LOGI(TAG, "Temp: %.1fC EP: %d ", temperature, param_ep); 70 | uint16_t dht_val = (uint16_t)(temperature * 100); 71 | send_data(dht_val, param_ep, cluster); 72 | } 73 | else if (strcmp(cluster, "humidity") == 0) 74 | { 75 | ESP_LOGI(TAG, "Humidity: %.1f%% EP: %d ", humidity, param_ep); 76 | uint16_t dht_val = (uint16_t)(humidity * 100); 77 | send_data(dht_val, param_ep, cluster); 78 | } 79 | } 80 | else 81 | { 82 | ESP_LOGE(TAG, "Could not read data from sensor"); 83 | } 84 | vTaskDelay(param_int / portTICK_PERIOD_MS); 85 | } 86 | } 87 | //----------------------------------// 88 | 89 | void sensor_dht(const char *sensor, const char *cluster, int EP, const TaskParameters *taskParams) 90 | { 91 | ESP_LOGW(TAG, "Task: %s created. Cluster: %s EP: %d", sensor, cluster, EP); 92 | xTaskCreate(sensor_dht_task, taskParams->param_id, 4096, taskParams, 5, NULL); 93 | } 94 | -------------------------------------------------------------------------------- /main/zigbee/zigbee_init.h: -------------------------------------------------------------------------------- 1 | #include "esp_log.h" 2 | #include "freertos/FreeRTOS.h" 3 | #include "freertos/task.h" 4 | #include "ha/esp_zigbee_ha_standard.h" 5 | #include "ha/zb_ha_device_config.h" 6 | #include "zcl/esp_zigbee_zcl_power_config.h" 7 | #include 8 | #include "esp_zigbee_core.h" 9 | 10 | /* Zigbee configuration */ 11 | #define MAX_CHILDREN 10 /* the max amount of connected devices */ 12 | #define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */ 13 | #define ENDPOINT 1 14 | 15 | #define CO2_CUSTOM_CLUSTER 0xFFF2 /* Custom cluster used because standart cluster not working*/ 16 | #define ESP_ZB_PRIMARY_CHANNEL_MASK ESP_ZB_TRANSCEIVER_ALL_CHANNELS_MASK /* Zigbee primary channel mask use in the example */ 17 | #define OTA_UPGRADE_MANUFACTURER 0x1001 /* The attribute indicates the file version of the downloaded image on the device*/ 18 | #define OTA_UPGRADE_IMAGE_TYPE 0x1011 /* The attribute indicates the value for the manufacturer of the device */ 19 | // #define OTA_UPGRADE_FILE_VERSION 0x01010101 /* The attribute indicates the file version of the running firmware image on the device */ 20 | #define OTA_UPGRADE_RUNNING_FILE_VERSION 0x01010101 /* The attribute indicates the file version of the running firmware image on the device */ 21 | #define OTA_UPGRADE_DOWNLOADED_FILE_VERSION 0x01010101 /* The attribute indicates the file version of the downloaded firmware image on the device */ 22 | #define OTA_UPGRADE_HW_VERSION 0x0101 /* The parameter indicates the version of hardware */ 23 | #define OTA_UPGRADE_MAX_DATA_SIZE 64 /* The parameter indicates the maximum data size of query block image */ 24 | #define MANUFACTURER_NAME "meef.ru" 25 | #define MODEL_NAME "zigbee DIY" 26 | #define FIRMWARE_VERSION "ver-0.6" 27 | 28 | // -- EP-- // 29 | #define ED_AGING_TIMEOUT ESP_ZB_ED_AGING_TIMEOUT_64MIN 30 | #define ED_KEEP_ALIVE 4000 /* 3000 millisecond */ 31 | #define ESP_ZB_ZED_CONFIG() \ 32 | { \ 33 | .esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, \ 34 | .install_code_policy = INSTALLCODE_POLICY_ENABLE, \ 35 | .nwk_cfg.zed_cfg = { \ 36 | .ed_timeout = ED_AGING_TIMEOUT, \ 37 | .keep_alive = ED_KEEP_ALIVE, \ 38 | }, \ 39 | } 40 | // -- router -- // 41 | #define ESP_ZB_ZR_CONFIG() \ 42 | { \ 43 | .esp_zb_role = ESP_ZB_DEVICE_TYPE_ROUTER, \ 44 | .install_code_policy = INSTALLCODE_POLICY_ENABLE, \ 45 | .nwk_cfg.zczr_cfg = { \ 46 | .max_children = MAX_CHILDREN, \ 47 | }, \ 48 | } 49 | 50 | #define ESP_ZB_DEFAULT_RADIO_CONFIG() \ 51 | { \ 52 | .radio_mode = ZB_RADIO_MODE_NATIVE, \ 53 | } 54 | 55 | #define ESP_ZB_DEFAULT_HOST_CONFIG() \ 56 | { \ 57 | .host_connection_mode = ZB_HOST_CONNECTION_MODE_NONE, \ 58 | } 59 | 60 | void zigbee_init(void); 61 | void button_task(void *pvParameters); 62 | -------------------------------------------------------------------------------- /components/framebuffer/fbanimation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2021 Ruslan V. Uss 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * @file fbanimation.h 26 | * @defgroup animation animation 27 | * @{ 28 | * 29 | * ESP-IDF abstraction of framebuffer animation 30 | * 31 | * Copyright (c) 2021 Ruslan V. Uss 32 | * 33 | * MIT Licensed as described in the file LICENSE 34 | */ 35 | #ifndef __FBANIMATION_H__ 36 | #define __FBANIMATION_H__ 37 | 38 | #include 39 | #include "framebuffer.h" 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * Draw funtion type 47 | */ 48 | typedef esp_err_t (*fb_draw_cb_t)(framebuffer_t *fb); 49 | 50 | /** 51 | * Animation descriptor 52 | */ 53 | typedef struct 54 | { 55 | framebuffer_t *fb; ///< Framebuffer descriptor 56 | void *render_ctx; ///< Renderer context 57 | esp_timer_handle_t timer; ///< Animation timer 58 | fb_draw_cb_t draw; ///< Draw function 59 | } fb_animation_t; 60 | 61 | /** 62 | * @brief Create animation based on LED effect 63 | * 64 | * @param animation Animation descriptor 65 | * @param fb Framebuffer descriptor 66 | * @return ESP_OK on success 67 | */ 68 | esp_err_t fb_animation_init(fb_animation_t *animation, framebuffer_t *fb); 69 | 70 | /** 71 | * @brief Play animation 72 | * 73 | * @param animation Animation descriptor 74 | * @param fps Target FPS 75 | * @param draw Function for drawing on a framebuffer 76 | * @param render_ctx Renderer callback argument 77 | * @return ESP_OK on success 78 | */ 79 | esp_err_t fb_animation_play(fb_animation_t *animation, uint8_t fps, fb_draw_cb_t draw, void *render_ctx); 80 | 81 | /** 82 | * @brief Stop playing animation 83 | * 84 | * @param animation Animation descriptor 85 | * @return ESP_OK on success 86 | */ 87 | esp_err_t fb_animation_stop(fb_animation_t *animation); 88 | 89 | /** 90 | * @brief Create animation based on LED effect 91 | * 92 | * @param animation Animation descriptor 93 | * @return ESP_OK on success 94 | */ 95 | esp_err_t fb_animation_free(fb_animation_t *animation); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | /**@}*/ 102 | 103 | #endif /* __FBANIMATION_H__ */ 104 | -------------------------------------------------------------------------------- /components/button/button.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2021 Ruslan V. Uss 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * @file button.h 26 | * @defgroup button button 27 | * @{ 28 | * 29 | * ESP-IDF driver for simple GPIO buttons. 30 | * 31 | * Supports anti-jitter, auto repeat, long press. 32 | * 33 | * Copyright (c) 2021 Ruslan V. Uss 34 | * 35 | * MIT Licensed as described in the file LICENSE 36 | */ 37 | #ifndef __COMPONENTS_BUTTON_H__ 38 | #define __COMPONENTS_BUTTON_H__ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * Typedef of button descriptor 51 | */ 52 | typedef struct button_s button_t; 53 | 54 | /** 55 | * Button states/events 56 | */ 57 | typedef enum { 58 | BUTTON_PRESSED = 0, 59 | BUTTON_RELEASED, 60 | BUTTON_CLICKED, 61 | BUTTON_PRESSED_LONG, 62 | } button_state_t; 63 | 64 | /** 65 | * Callback prototype 66 | * 67 | * @param btn Pointer to button descriptor 68 | * @param state Button action (new state) 69 | */ 70 | typedef void (*button_event_cb_t)(button_t *btn, button_state_t state); 71 | 72 | /** 73 | * Button descriptor struct 74 | */ 75 | struct button_s 76 | { 77 | gpio_num_t gpio; //!< GPIO 78 | bool internal_pull; //!< Enable internal pull-up/pull-down 79 | uint8_t pressed_level; //!< Logic level of pressed button 80 | bool autorepeat; //!< Enable autorepeat 81 | button_event_cb_t callback; //!< Button callback 82 | void *ctx; //!< User data 83 | struct { 84 | button_state_t state; 85 | uint32_t pressed_time; 86 | uint32_t repeating_time; 87 | } internal; //!< Internal button state 88 | }; 89 | 90 | /** 91 | * @brief Init button 92 | * 93 | * @param btn Pointer to button descriptor 94 | * @return `ESP_OK` on success 95 | */ 96 | esp_err_t button_init(button_t *btn); 97 | 98 | /** 99 | * @brief Deinit button 100 | * 101 | * @param btn Pointer to button descriptor 102 | * @return `ESP_OK` on success 103 | */ 104 | esp_err_t button_done(button_t *btn); 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | /**@}*/ 111 | 112 | #endif /* __COMPONENTS_BUTTON_H__ */ 113 | -------------------------------------------------------------------------------- /main/effects/palettes.c: -------------------------------------------------------------------------------- 1 | #include "palettes.h" 2 | 3 | #define DECL_PALETTE(pal) { .size = sizeof(pal) / sizeof(rgb_t), .palette = pal } 4 | 5 | static const rgb_t p_fire[] = { C_BLACK, C_RED, C_YELLOW, C_WHITE }; 6 | static const rgb_t p_wood_fire[] = { C_BLACK, C_ORANGE_RED, C_ORANGE, C_GOLD }; 7 | static const rgb_t p_sodium_fire[] = { C_BLACK, C_ORANGE, C_GOLD, C_GOLDENROD }; 8 | static const rgb_t p_copper_fire[] = { C_BLACK, C_GREEN, C_GREEN_YELLOW, C_LIME_GREEN }; 9 | static const rgb_t p_alcohol_fire[] = { C_BLACK, C_BLUE, C_DEEP_SKY_BLUE, C_LIGHT_SKY_BLUE }; 10 | static const rgb_t p_rubidium_fire[] = { C_BLACK, C_INDIGO, C_INDIGO, C_DARK_BLUE }; 11 | static const rgb_t p_potassium_fire[] = { C_BLACK, C_INDIGO, C_MEDIUM_PURPLE, C_DEEP_PINK }; 12 | static const rgb_t p_lithium_fire[] = { C_BLACK, C_FIRE_BRICK, C_PINK, C_DEEP_PINK }; 13 | 14 | static const rgb_t p_cloud[] = { 15 | C_BLUE, C_DARK_BLUE, C_DARK_BLUE, C_DARK_BLUE, 16 | C_DARK_BLUE, C_DARK_BLUE, C_DARK_BLUE, C_DARK_BLUE, 17 | C_BLUE, C_DARK_BLUE, C_SKY_BLUE, C_SKY_BLUE, 18 | C_LIGHT_BLUE, C_WHITE, C_LIGHT_BLUE, C_SKY_BLUE 19 | }; 20 | static const rgb_t p_lava[] = { 21 | C_BLACK, C_MAROON, C_BLACK, C_MAROON, 22 | C_DARK_RED, C_MAROON, C_DARK_RED, C_MAROON, 23 | C_DARK_RED, C_DARK_RED, C_RED, C_ORANGE, 24 | C_WHITE, C_ORANGE, C_RED, C_DARK_RED 25 | }; 26 | static const rgb_t p_heat[] = { 27 | C_BLACK, 28 | { .r = 0x33, .g = 0, .b = 0 }, { .r = 0x66, .g = 0, .b = 0 }, { .r = 0x99, .g = 0, .b = 0 }, C_RED, 29 | { .r = 0xff, .g = 0x33, .b = 0 }, { .r = 0xff, .g = 0x66, .b = 0 }, { .r = 0xff, .g = 0x99, .b = 0 }, C_YELLOW, 30 | { .r = 0xff, .g = 0xff, .b = 0x33 }, { .r = 0xff, .g = 0xff, .b = 0x66 }, { .r = 0xff, .g = 0xff, .b = 0x99 }, C_WHITE 31 | }; 32 | static const rgb_t p_ocean[] = { 33 | C_MIDNIGHT_BLUE, C_DARK_BLUE, C_MIDNIGHT_BLUE, C_NAVY, 34 | C_DARK_BLUE, C_MEDIUM_BLUE, C_SEA_GREEN, C_TEAL, 35 | C_CADET_BLUE, C_BLUE, C_DARK_CYAN, C_CORNFLOWER_BLUE, 36 | C_AQUAMARINE, C_SEA_GREEN, C_AQUA, C_LIGHT_SKY_BLUE 37 | }; 38 | static const rgb_t p_forest[] = { 39 | C_DARK_GREEN, C_DARK_GREEN, C_DARK_OLIVE_GREEN, C_DARK_GREEN, 40 | C_GREEN, C_FOREST_GREEN, C_OLIVE_DRAB, C_GREEN, 41 | C_SEA_GREEN, C_MEDIUM_AQUAMARINE, C_LIME_GREEN, C_YELLOW_GREEN, 42 | C_LIGHT_GREEN, C_LAWN_GREEN, C_MEDIUM_AQUAMARINE, C_FOREST_GREEN 43 | }; 44 | static const rgb_t p_party[] = { 45 | C_RED, C_BLACK, { .r = 0xab, .g = 0x55, .b = 0 }, C_BLACK, 46 | { .r = 0xab, .g = 0xab, .b = 0 }, C_BLACK, C_GREEN, C_BLACK, 47 | { .r = 0, .g = 0xab, .b = 0x55 }, C_BLACK, C_BLUE, C_BLACK, 48 | { .r = 0x55, .g = 0, .b = 0xab }, C_BLACK, { .r = 0xab, .g = 0, .b = 0x55 }, C_BLACK 49 | }; 50 | 51 | const palette_def_t palettes[PALETTE_MAX] = { 52 | [PALETTE_FIRE] = DECL_PALETTE(p_fire), 53 | [PALETTE_WOOD_FIRE] = DECL_PALETTE(p_wood_fire), 54 | [PALETTE_SODIUM_FIRE] = DECL_PALETTE(p_sodium_fire), 55 | [PALETTE_COPPER_FIRE] = DECL_PALETTE(p_copper_fire), 56 | [PALETTE_ALCOHOL_FIRE] = DECL_PALETTE(p_alcohol_fire), 57 | [PALETTE_RUBIDIUM_FIRE] = DECL_PALETTE(p_rubidium_fire), 58 | [PALETTE_POTASSIUM_FIRE] = DECL_PALETTE(p_potassium_fire), 59 | [PALETTE_LITHIUM_FIRE] = DECL_PALETTE(p_lithium_fire), 60 | [PALETTE_CLOUD] = DECL_PALETTE(p_cloud), 61 | [PALETTE_LAVA] = DECL_PALETTE(p_lava), 62 | [PALETTE_HEAT] = DECL_PALETTE(p_heat), 63 | [PALETTE_OCEAN] = DECL_PALETTE(p_ocean), 64 | [PALETTE_FOREST] = DECL_PALETTE(p_forest), 65 | [PALETTE_PARTY] = DECL_PALETTE(p_party), 66 | }; 67 | -------------------------------------------------------------------------------- /components/framebuffer/fbanimation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2021 Ruslan V. Uss 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | */ 23 | 24 | /** 25 | * @file animation.c 26 | * 27 | * ESP-IDF abstraction of framebuffer animation 28 | * 29 | * Copyright (c) 2021 Ruslan V. Uss 30 | * 31 | * MIT Licensed as described in the file LICENSE 32 | */ 33 | #include 34 | #include 35 | #include "fbanimation.h" 36 | 37 | static const char *TAG = "animation"; 38 | 39 | #define CHECK(x) do { esp_err_t __; if ((__ = x) != ESP_OK) return __; } while (0) 40 | #define CHECK_ARG(VAL) do { if (!(VAL)) return ESP_ERR_INVALID_ARG; } while (0) 41 | 42 | static void display_frame(void *ctx) 43 | { 44 | fb_animation_t *animation = (fb_animation_t *)ctx; 45 | 46 | // run effect 47 | esp_err_t res = animation->draw ? animation->draw(animation->fb) : ESP_FAIL; 48 | if (res != ESP_OK) 49 | { 50 | ESP_LOGE(TAG, "Error running effect %d (%s)", res, esp_err_to_name(res)); 51 | return; 52 | } 53 | // render frame 54 | res = fb_render(animation->fb, animation->render_ctx); 55 | if (res != ESP_OK) 56 | { 57 | ESP_LOGE(TAG, "Error rendering frame %d (%s)", res, esp_err_to_name(res)); 58 | return; 59 | } 60 | } 61 | 62 | //////////////////////////////////////////////////////////////////////////////// 63 | 64 | esp_err_t fb_animation_init(fb_animation_t *animation, framebuffer_t *fb) 65 | { 66 | CHECK_ARG(animation && fb); 67 | 68 | animation->fb = fb; 69 | animation->timer = NULL; 70 | esp_timer_create_args_t timer_args = { 71 | .arg = animation, 72 | .callback = display_frame, 73 | .dispatch_method = ESP_TIMER_TASK, 74 | }; 75 | return esp_timer_create(&timer_args, &animation->timer); 76 | } 77 | 78 | esp_err_t fb_animation_play(fb_animation_t *animation, uint8_t fps, fb_draw_cb_t draw, void *render_ctx) 79 | { 80 | CHECK_ARG(animation && fps && draw); 81 | 82 | animation->render_ctx = render_ctx; 83 | animation->draw = draw; 84 | return esp_timer_start_periodic(animation->timer, 1000000 / fps); 85 | } 86 | 87 | esp_err_t fb_animation_stop(fb_animation_t *animation) 88 | { 89 | CHECK_ARG(animation); 90 | 91 | return esp_timer_stop(animation->timer); 92 | } 93 | 94 | esp_err_t fb_animation_free(fb_animation_t *animation) 95 | { 96 | CHECK_ARG(animation); 97 | 98 | esp_timer_stop(animation->timer); 99 | return esp_timer_delete(animation->timer); 100 | } 101 | -------------------------------------------------------------------------------- /main/effects/matrix.c: -------------------------------------------------------------------------------- 1 | #include "effects/matrix.h" 2 | 3 | #include 4 | 5 | #define P_DENSITY 0 6 | 7 | EFFECT_PARAMS(matrix, 1) = { 8 | DECL_PARAM_RANGE(P_DENSITY, "Density", 0, 255, 150), 9 | }; 10 | 11 | #define MATRIX_START_COLOR 0x9bf800 12 | #define MATRIX_DIM_COLOR 0x558800 13 | #define MATRIX_STEP 0x0a1000 14 | #define MATRIX_ALMOST_OFF 0x050800 15 | #define MATRIX_OFF_THRESH 0x030000 16 | #define MATRIX_DIMMEST_COLOR 0x020300 17 | 18 | esp_err_t effect_matrix_run(framebuffer_t *fb) 19 | { 20 | CHECK(fb_begin(fb)); 21 | 22 | for (size_t x = 0; x < fb->width; x++) 23 | { 24 | // process matrix from bottom to the second line from the top 25 | for (size_t y = 0; y < fb->height - 1; y++) 26 | { 27 | rgb_t cur_color, upper_color; 28 | 29 | // get current pixel color 30 | fb_get_pixel_rgb(fb, x, y, &cur_color); 31 | uint32_t cur_code = rgb_to_code(cur_color); 32 | // get color of the pixel above current 33 | fb_get_pixel_rgb(fb, x, y + 1, &upper_color); 34 | uint32_t upper_code = rgb_to_code(upper_color); 35 | 36 | // if above is max brightness, ignore this fact with some probability or move tail down 37 | if (upper_code == MATRIX_START_COLOR && random8_to(7 * fb->height) != 0) 38 | fb_set_pixel_rgb(fb, x, y, upper_color); 39 | // if current pixel is off, light up new tails with some probability 40 | else if (cur_code == 0 && random8_to(PARAM_VAL(matrix, P_DENSITY)) == 0) 41 | fb_set_pixel_rgb(fb, x, y, rgb_from_code(MATRIX_START_COLOR)); 42 | // if current pixel is almost off, try to make the fading out slower 43 | else if (cur_code <= MATRIX_ALMOST_OFF) 44 | { 45 | if (cur_code >= MATRIX_OFF_THRESH) 46 | fb_set_pixel_rgb(fb, x, y, rgb_from_code(MATRIX_DIMMEST_COLOR)); 47 | else if (cur_code != 0) 48 | fb_set_pixel_rgb(fb, x, y, rgb_from_code(0)); 49 | } 50 | else if (cur_code == MATRIX_START_COLOR) 51 | // first step of tail fading 52 | fb_set_pixel_rgb(fb, x, y, rgb_from_code(MATRIX_DIM_COLOR)); 53 | else 54 | // otherwise, just lower the brightness one step 55 | fb_set_pixel_rgb(fb, x, y, rgb_from_code(cur_code - MATRIX_STEP)); 56 | } 57 | 58 | // upper line processing 59 | rgb_t cur_color; 60 | fb_get_pixel_rgb(fb, x, fb->height - 1, &cur_color); 61 | uint32_t cur_code = rgb_to_code(cur_color); 62 | 63 | // if current top pixel is off, fill it with some probability 64 | if (cur_code == 0) 65 | { 66 | if (random8_to(PARAM_VAL(matrix, P_DENSITY)) == 0) 67 | fb_set_pixel_rgb(fb, x, fb->height - 1, rgb_from_code(MATRIX_START_COLOR)); 68 | } 69 | // if current pixel is almost off, try to make the fading out slower 70 | else if (cur_code <= MATRIX_ALMOST_OFF) 71 | { 72 | if (cur_code >= MATRIX_OFF_THRESH) 73 | fb_set_pixel_rgb(fb, x, fb->height - 1, rgb_from_code(MATRIX_DIMMEST_COLOR)); 74 | else 75 | fb_set_pixel_rgb(fb, x, fb->height - 1, rgb_from_code(0)); 76 | } 77 | else if (cur_code == MATRIX_START_COLOR) 78 | // first step of tail fading 79 | fb_set_pixel_rgb(fb, x, fb->height - 1, rgb_from_code(MATRIX_DIM_COLOR)); 80 | else 81 | // otherwise just lower the brightness one step 82 | fb_set_pixel_rgb(fb, x, fb->height - 1, rgb_from_code(cur_code - MATRIX_STEP)); 83 | } 84 | 85 | return fb_end(fb); 86 | } 87 | -------------------------------------------------------------------------------- /components/dht/dht.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Jonathan Hartsuiker 3 | * Copyright (c) 2018 Ruslan V. Uss 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of itscontributors 14 | * may be used to endorse or promote products derived from this software without 15 | * specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /** 30 | * @file dht.h 31 | * @defgroup dht dht 32 | * @{ 33 | * 34 | * ESP-IDF driver for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321), Itead Si7021 35 | * 36 | * Ported from esp-open-rtos 37 | * 38 | * Copyright (c) 2016 Jonathan Hartsuiker \n 39 | * Copyright (c) 2018 Ruslan V. Uss \n 40 | * 41 | * BSD Licensed as described in the file LICENSE 42 | * 43 | * @note A suitable pull-up resistor should be connected to the selected GPIO line 44 | * 45 | */ 46 | #ifndef __DHT_H__ 47 | #define __DHT_H__ 48 | 49 | #include 50 | #include 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /** 57 | * Sensor type 58 | */ 59 | typedef enum 60 | { 61 | DHT_TYPE_DHT11 = 0, //!< DHT11 62 | DHT_TYPE_AM2301, //!< AM2301 (DHT21, DHT22, AM2302, AM2321) 63 | DHT_TYPE_SI7021 //!< Itead Si7021 64 | } dht_sensor_type_t; 65 | 66 | /** 67 | * @brief Read integer data from sensor on specified pin 68 | * 69 | * Humidity and temperature are returned as integers. 70 | * For example: humidity=625 is 62.5 %, temperature=244 is 24.4 degrees Celsius 71 | * 72 | * @param sensor_type DHT11 or DHT22 73 | * @param pin GPIO pin connected to sensor OUT 74 | * @param[out] humidity Humidity, percents * 10, nullable 75 | * @param[out] temperature Temperature, degrees Celsius * 10, nullable 76 | * @return `ESP_OK` on success 77 | */ 78 | esp_err_t dht_read_data(dht_sensor_type_t sensor_type, gpio_num_t pin, 79 | int16_t *humidity, int16_t *temperature); 80 | 81 | /** 82 | * @brief Read float data from sensor on specified pin 83 | * 84 | * Humidity and temperature are returned as floats. 85 | * 86 | * @param sensor_type DHT11 or DHT22 87 | * @param pin GPIO pin connected to sensor OUT 88 | * @param[out] humidity Humidity, percents, nullable 89 | * @param[out] temperature Temperature, degrees Celsius, nullable 90 | * @return `ESP_OK` on success 91 | */ 92 | esp_err_t dht_read_float_data(dht_sensor_type_t sensor_type, gpio_num_t pin, 93 | float *humidity, float *temperature); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | /**@}*/ 100 | 101 | #endif // __DHT_H__ 102 | --------------------------------------------------------------------------------