mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 05:06:44 +00:00
Ad HASP_RANDOM mcro
This commit is contained in:
parent
bdbceeb539
commit
df393d70f9
@ -12,6 +12,14 @@
|
|||||||
#include "user_config_override.h"
|
#include "user_config_override.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
|
#define HASP_RANDOM(x) rand() * x
|
||||||
|
#elif defined(ARDUINO)
|
||||||
|
#define HASP_RANDOM(x) random(x)
|
||||||
|
#else
|
||||||
|
#define HASP_RANDOM(x) random() * x
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(WINDOWS) || defined(POSIX)
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
#define LOG_OUTPUT(x, ...) printf(__VA_ARGS__)
|
#define LOG_OUTPUT(x, ...) printf(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
|
@ -221,13 +221,7 @@ void hasp_antiburn_cb(lv_task_t* task)
|
|||||||
|
|
||||||
for(lv_coord_t y = 0; y < lv_obj_get_height(layer); y++) {
|
for(lv_coord_t y = 0; y < lv_obj_get_height(layer); y++) {
|
||||||
for(lv_coord_t x = 0; x < area.x2; x++) {
|
for(lv_coord_t x = 0; x < area.x2; x++) {
|
||||||
#if defined(WINDOWS) || defined(POSIX)
|
color[x].full = HASP_RANDOM(UINT16_MAX);
|
||||||
color[x].full = rand() * UINT16_MAX;
|
|
||||||
#elif defined(ARDUINO)
|
|
||||||
color[x].full = random(UINT16_MAX);
|
|
||||||
#else
|
|
||||||
color[x].full = random() * UINT16_MAX;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
area.y1 = y;
|
area.y1 = y;
|
||||||
area.y2 = y;
|
area.y2 = y;
|
||||||
|
@ -1142,7 +1142,7 @@ void dispatch_send_sensordata(const char*, const char*, uint8_t source)
|
|||||||
|
|
||||||
void dispatch_queue_discovery(const char*, const char*, uint8_t source)
|
void dispatch_queue_discovery(const char*, const char*, uint8_t source)
|
||||||
{
|
{
|
||||||
long seconds = random(10);
|
long seconds = HASP_RANDOM(10);
|
||||||
if(dispatchSecondsToNextTeleperiod == seconds) seconds++;
|
if(dispatchSecondsToNextTeleperiod == seconds) seconds++;
|
||||||
if(dispatchSecondsToNextSensordata == seconds) seconds++;
|
if(dispatchSecondsToNextSensordata == seconds) seconds++;
|
||||||
LOG_VERBOSE(TAG_MSGR, F("Discovery queued in %d seconds"), seconds);
|
LOG_VERBOSE(TAG_MSGR, F("Discovery queued in %d seconds"), seconds);
|
||||||
@ -1196,7 +1196,7 @@ void dispatch_send_discovery(const char*, const char*, uint8_t source)
|
|||||||
default:
|
default:
|
||||||
LOG_ERROR(TAG_MQTT, F(D_ERROR_UNKNOWN));
|
LOG_ERROR(TAG_MQTT, F(D_ERROR_UNKNOWN));
|
||||||
}
|
}
|
||||||
dispatchSecondsToNextDiscovery = dispatch_setings.teleperiod * 2 + random(10);
|
dispatchSecondsToNextDiscovery = dispatch_setings.teleperiod * 2 + HASP_RANDOM(10);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user