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