1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Minimize header use, move Ticker function definitions into cpp file (#6496)

* Backport from ESP32

* Use new library layout (.../src)

* Cleanup test case.

* C++ style cast required.

* Whitespace

* Inlining via header has better baseline ROM footprint.

* Reordered functions for better code-compare to master

* Reduces ROM footprint some more.

* Avoid unnecessary parameter passing - refactoring, same generated footprint.

* Reformat example sources
This commit is contained in:
Dirk O. Kaar
2019-11-14 14:02:32 +01:00
committed by Develo
parent af85bd2efc
commit 482516e393
5 changed files with 172 additions and 185 deletions

View File

@ -13,9 +13,17 @@
#include <Ticker.h>
Ticker tickerSetHigh;
Ticker tickerSetAnalog;
Ticker tickerSetLow;
Ticker tickerSetHigh;
Ticker tickerSetChar;
void setPinLow() {
digitalWrite(LED_BUILTIN, 0);
}
void setPinHigh() {
digitalWrite(LED_BUILTIN, 1);
}
void setPin(int state) {
digitalWrite(LED_BUILTIN, state);
@ -27,14 +35,15 @@ void setPinChar(char state) {
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(1, LOW);
// every 25 ms, call setPin(0)
tickerSetLow.attach_ms(25, setPin, 0);
// every 25 ms, call setPinLow()
tickerSetLow.attach_ms(25, setPinLow);
// every 26 ms, call setPinChar(1)
tickerSetHigh.attach_ms(26, setPinChar, (char)1);
// every 26 ms, call setPinHigh()
tickerSetHigh.attach_ms(26, setPinHigh);
// every 54 ms, call setPinChar(1)
tickerSetChar.attach_ms(26, setPinChar, (char)1);
}
void loop() {