mirror of
https://github.com/Crocmagnon/plant-badger.git
synced 2024-12-04 23:23:36 +01:00
Reduce jitter and make it only positive
This commit is contained in:
parent
ec3551d0cd
commit
54ca275810
1 changed files with 2 additions and 2 deletions
|
@ -33,14 +33,14 @@ class Badger2040(badger2040.Badger2040):
|
||||||
self.rtc.enable_timer_interrupt(True)
|
self.rtc.enable_timer_interrupt(True)
|
||||||
|
|
||||||
def set_timer_minutes_with_jitter(
|
def set_timer_minutes_with_jitter(
|
||||||
self, minutes: int, jitter_percentage: float = 0.2
|
self, minutes: int, jitter_percentage: float = 0.1
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Wake the board in X minutes with some jitter. Doesn't halt the board.
|
Wake the board in X minutes with some jitter. Doesn't halt the board.
|
||||||
jitter_percentage should be a float between 0.0 and 1.0.
|
jitter_percentage should be a float between 0.0 and 1.0.
|
||||||
"""
|
"""
|
||||||
delta = int(minutes * abs(jitter_percentage))
|
delta = int(minutes * abs(jitter_percentage))
|
||||||
minutes += random.randint(-delta, delta)
|
minutes += random.randint(0, delta)
|
||||||
self.set_timer_minutes(minutes)
|
self.set_timer_minutes(minutes)
|
||||||
|
|
||||||
def status_handler(self, mode, status, ip):
|
def status_handler(self, mode, status, ip):
|
||||||
|
|
Loading…
Reference in a new issue