mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Merge pull request #221 from nagyrobi/patch-1
Add some more comments on how to use fan
This commit is contained in:
commit
7d50baebe9
@ -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/<yourplate>/custom/fanspeed
|
||||
// and hasp/<yourplate>/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
|
||||
#endif // HASP_USE_CUSTOM
|
||||
|
Loading…
x
Reference in New Issue
Block a user