Skip to content

Ticker.h - Too-large timeouts should generate an error, not silently fail (was: big float and unt32_t numbers) #8066

Closed
@enjoyneering

Description

@enjoyneering

Platform

  • Hardware: [ESP-12]
  • Core Version: [2.7.4] & [3.0.0]
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Generic ESP8266]
  • Flash Mode: [qio]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Higher Bandwidth]
  • Reset Method: [nodemcu]
  • Flash Frequency: [80Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [OTA|SERIAL]
  • Upload Speed: [115200]

Problem Description

Any Ticker tasks fire OK if time is short (tested up to 60 seconds (60 000ms)). However, when I try to control the brightness after sunset, the time gets big (for example 44944 sec (44 944 000ms)) & the same task no longer start. The code below is not exactly what I have in my project, but close.

MCVE Sketch

#include <Arduino.h>
#include <Ticker.h>

Ticker ticker_autoBrightness;

uint32_t timeSec = 44079; //12h:14m:39s

void setup() {
pinMode(2, OUTPUT);

task_clockDayBrightness();
}

void loop() {
//empty
}

void task_clockDayBrightness()
{
  digitalWrite(2, LOW); //turn LED on

  ticker_autoBrightness.once_scheduled(timeSec, task_clockNightBrightness);
}

void task_clockNightBrightness()
{
  digitalWrite(2, HIGH); //turn LED off

  ticker_autoBrightness.once_scheduled(timeSec, task_clockDayBrightness);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions