From 10587fc078df1fb73563b630c4ef048452239e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=2E=20=C3=81rkosi=20R=C3=B3bert?= Date: Fri, 8 Oct 2021 21:25:30 +0200 Subject: [PATCH 1/4] Add some more comments on how to use fan --- src/custom/my_custom_fan_template.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/custom/my_custom_fan_template.cpp b/src/custom/my_custom_fan_template.cpp index e8b4c31b..28a0ee48 100644 --- a/src/custom/my_custom_fan_template.cpp +++ b/src/custom/my_custom_fan_template.cpp @@ -1,8 +1,14 @@ /* MIT License - Copyright (c) 2019-2021 Francis Van Roie For full license information read the LICENSE file in the project folder */ -// USAGE: - Copy this file and rename it to my_custom.cpp -// - Change false to true on line 9 +// USAGE: - Copy this file and rename it to my_custom_fan_rotator.cpp +// - Change false to true on line 15 +// - Set the page and id of your object on lines 25 and 26 +// - Optionally set the default rotation state and angle on lines 19 and 20 +// - At run time you can change fanspeed and fanangle by updating the topics hasp//custom/fanspeed +// and hasp//custom/fanangle with values desired from your home automation system +// NOTE: This gives best results with small images (up to 64x64 pixels). Large images may draw choppy due to limited +// computing capacity of the MCU. #include "hasplib.h" @@ -10,14 +16,14 @@ #include "custom/my_custom.h" -uint16_t fanspeed = 0; -uint16_t fanangle = 450; +uint16_t fanspeed = 0; // rotation off by default (the time between angle turns in ms) +uint16_t fanangle = 450; // default angle of one turn (0.1 degree precision, so this means 45°) unsigned long prev_loop = 0; static void my_rotate_fan() { - uint8_t page = 1; - uint8_t id = 150; + uint8_t page = 1; // the page of the object you want to rotate + uint8_t id = 150; // the id of the object you want to rotate lv_obj_t* fan = hasp_find_obj_from_page_id(page, id); if(!fan) return; // object doesn't exist @@ -99,4 +105,4 @@ void custom_topic_payload(const char* topic, const char* payload, uint8_t source // Log.verbose(TAG_CUSTOM, "Handled custom message: %s => %s", topic, payload); } -#endif // HASP_USE_CUSTOM \ No newline at end of file +#endif // HASP_USE_CUSTOM From 5a7c270cb23b2250b99c66c6b10a2cf5a479eb76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=2E=20=C3=81rkosi=20R=C3=B3bert?= Date: Fri, 8 Oct 2021 22:05:02 +0200 Subject: [PATCH 2/4] remove unneeded stuff --- src/custom/my_custom_fan_template.cpp | 28 --------------------------- 1 file changed, 28 deletions(-) diff --git a/src/custom/my_custom_fan_template.cpp b/src/custom/my_custom_fan_template.cpp index 28a0ee48..03fc171e 100644 --- a/src/custom/my_custom_fan_template.cpp +++ b/src/custom/my_custom_fan_template.cpp @@ -48,34 +48,6 @@ void custom_loop() } } -void custom_every_second() -{ - Serial.print("#"); -} - -void custom_every_5seconds() -{ - Log.verbose(TAG_CUSTOM, "5 seconds have passsed..."); - dispatch_state_subtopic("my_sensor", "{\"test\":123}"); -} - -bool custom_pin_in_use(uint pin) -{ - if(pin == 1024) return true; // fictuous used pin - - // otherwise the pin is not used - return false; -} - -void custom_get_sensors(JsonDocument& doc) -{ - /* Sensor Name */ - JsonObject sensor = doc.createNestedObject(F("Custom")); - - /* Key-Value pair of the sensor value */ - sensor[F("Random")] = random(256); -} - /* Receive custom topic & payload messages */ void custom_topic_payload(const char* topic, const char* payload, uint8_t source) { From 9d5435a1b6171112a1a5190b0802bd7324f4502e Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Fri, 8 Oct 2021 22:35:55 +0200 Subject: [PATCH 3/4] Keep the function names I removed the code, but kept the names of the function --- src/custom/my_custom_fan_template.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/custom/my_custom_fan_template.cpp b/src/custom/my_custom_fan_template.cpp index 03fc171e..a7334388 100644 --- a/src/custom/my_custom_fan_template.cpp +++ b/src/custom/my_custom_fan_template.cpp @@ -48,6 +48,27 @@ void custom_loop() } } +void custom_every_second() +{ + // Unused +} + +void custom_every_5seconds() +{ + // Unused +} + +bool custom_pin_in_use(uint pin) +{ + // no pins are used + return false; +} + +void custom_get_sensors(JsonDocument& doc) +{ + // Unused +} + /* Receive custom topic & payload messages */ void custom_topic_payload(const char* topic, const char* payload, uint8_t source) { From 398dc06521dd7bc071030a82b148936a6880bcca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=2E=20=C3=81rkosi=20R=C3=B3bert?= Date: Fri, 8 Oct 2021 23:48:21 +0200 Subject: [PATCH 4/4] Update my_custom_fan_template.cpp --- src/custom/my_custom_fan_template.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/custom/my_custom_fan_template.cpp b/src/custom/my_custom_fan_template.cpp index a7334388..016da86c 100644 --- a/src/custom/my_custom_fan_template.cpp +++ b/src/custom/my_custom_fan_template.cpp @@ -1,7 +1,7 @@ /* MIT License - Copyright (c) 2019-2021 Francis Van Roie For full license information read the LICENSE file in the project folder */ -// USAGE: - Copy this file and rename it to my_custom_fan_rotator.cpp +// USAGE: - Copy this file and rename it to my_custom_fan_rotator.cpp, also copy my_custom_template.h and rename it to my_custom.h // - Change false to true on line 15 // - Set the page and id of your object on lines 25 and 26 // - Optionally set the default rotation state and angle on lines 19 and 20