Skip to content

feat(ticker): extend ticker by adding restart timer options#12240

Merged
me-no-dev merged 7 commits intoespressif:masterfrom
nielsnl68:090126_extend_ticker
Jan 21, 2026
Merged

feat(ticker): extend ticker by adding restart timer options#12240
me-no-dev merged 7 commits intoespressif:masterfrom
nielsnl68:090126_extend_ticker

Conversation

@nielsnl68
Copy link
Contributor

By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes

Checklist

  1. Please provide specific title of the PR describing the change, including the component name (eg. „Update of Documentation link on Readme.md“)
  2. Please provide related links (eg. Issue which will be closed by this Pull Request)
  3. Please update relevant Documentation if applicable
  4. Please check Contributing guide
  5. Please confirm option to "Allow edits and access to secrets by maintainers" when opening a Pull Request

This entire section above can be deleted if all items are checked.


Description of Change

I did found that the Ticker component was missing the option to Reset the counter as possible with the ESP-IDF framework.
It adds 3 new methods restart(float seconds), restart_ms(uint64_t milliseconds), restart_us(uint64_t micros).

Test Scenarios

#include <Ticker.h>

#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif

#define PUSH_BUTTON 0

Ticker flipper;

int buttonState = 0;  // variable for reading the pushbutton status


void flip() {
  int state = digitalRead(LED_BUILTIN);  // get the current state of GPIO1 pin
  digitalWrite(LED_BUILTIN, !state);     // set pin to the opposite state
}

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  pinMode(PUSH_BUTTON, INPUT);

  // flip the pin every 0.3s
  flipper.attach(0.3, flip);
}

void loop() {
  buttonState = digitalRead(PUSH_BUTTON);
  if (buttonState == HIGH) {
    flipper.restart(0.3);
  }
}

(eg. I have tested my Pull Request on Arduino-esp32 core v3.3.5 with ESP32-S3 Board with this scenario)

Related links

Please provide links to related issue, PRs etc.

(eg. Closes #number of issue)

@nielsnl68 nielsnl68 requested a review from a team as a code owner January 14, 2026 16:33
@CLAassistant
Copy link

CLAassistant commented Jan 14, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "Add restart methods for timer with different units":
    • summary looks empty
    • type/action looks empty
  • the commit message "Fix missing closing parenthesis in restart methods":
    • summary looks empty
    • type/action looks empty
  • the commit message "change(Ticker): Add restart keywords to keywords.txt":
    • scope/component should be lowercase without whitespace, allowed special characters are _ / . , * - .
  • the commit message "change(Ticker): Refactor restart methods for better clarity and usability.":
    • scope/component should be lowercase without whitespace, allowed special characters are _ / . , * - .
    • summary should not end with a period (full stop)
  • the commit message "change(Ticker): implement the methods in CPP and leave just the declarations in the header":
    • summary appears to be too long
    • scope/component should be lowercase without whitespace, allowed special characters are _ / . , * - .

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 10 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

👋 Hello nielsnl68, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against b031a7a

@nielsnl68 nielsnl68 changed the title 090126 extend ticker by adding a restart option, feat(ticker): extend ticker by adding restart timer options, Jan 14, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds restart functionality to the Ticker library, allowing timers to be restarted without needing to detach and re-attach them. This extends the Ticker API to match the capabilities available in the ESP-IDF framework.

Changes:

  • Added three new restart methods: restart(), restart_ms(), and restart_us()
  • Methods follow the existing naming convention and time unit conversion patterns
  • Implementation checks if timer is active before attempting restart

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

Memory usage test (comparing PR against master branch)

The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP320⚠️ +840.00⚠️ +0.03000.000.00
ESP32C3000.000.00000.000.00
ESP32C5000.000.00000.000.00
ESP32C6000.000.00000.000.00
ESP32H2000.000.00000.000.00
ESP32P4000.000.00000.000.00
ESP32S20⚠️ +840.00⚠️ +0.03000.000.00
ESP32S3000.000.00000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32ESP32C3ESP32C5ESP32C6ESP32H2ESP32P4ESP32S2ESP32S3
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
libraries/Ticker/examples/Blinker⚠️ +84000----0000⚠️ +840--
libraries/Ticker/examples/TickerBasic⚠️ +84000----0000⚠️ +840--
libraries/Ticker/examples/TickerParameter⚠️ +84000----0000⚠️ +840--
libraries/Update/examples/OTAWebUpdater⚠️ +84000------00⚠️ +840--

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

Test Results

 90 files   90 suites   33m 0s ⏱️
 67 tests  67 ✅ 0 💤 0 ❌
683 runs  683 ✅ 0 💤 0 ❌

Results for commit b031a7a.

♻️ This comment has been updated with latest results.

@me-no-dev
Copy link
Member

Please implement the methods in CPP and leave just the declarations in the header

…rations in the header

change(Ticker): implement the methods in CPP and leave just the declarations in the header
…lity.

change(Ticker): Refactor restart methods for better clarity and usability.
change(Ticker): Add restart keywords to keywords.txt
@nielsnl68
Copy link
Contributor Author

nielsnl68 commented Jan 14, 2026

Please implement the methods in CPP and leave just the declarations in the header

Done.

@lucasssvaz lucasssvaz changed the title feat(ticker): extend ticker by adding restart timer options, feat(ticker): extend ticker by adding restart timer options Jan 20, 2026
@lucasssvaz lucasssvaz added the Status: Pending Merge Pull Request is ready to be merged label Jan 20, 2026
@me-no-dev me-no-dev merged commit 80e07d3 into espressif:master Jan 21, 2026
86 checks passed
@nielsnl68
Copy link
Contributor Author

Thanks for adding this PR.

@nielsnl68 nielsnl68 deleted the 090126_extend_ticker branch January 22, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Pending Merge Pull Request is ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants