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:
@ -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() {
|
||||
|
Reference in New Issue
Block a user