Ticker, many versions


#1

Hi

I have a nodeMcu card and running VS Code with PlatformIO.

Trying to set up a small scheduler and would like to use this version of Ticker
( https://github.com/esp8266/Arduino/tree/master/libraries/Ticker ).

The compiler cant find Ticker.h.
Whats wrong ??

platform.ini

[global]
lib_deps=

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps =

lib_extra_dirs = ../../library
lib_ignore =

lib_ldf_mode = deep+
monitor_port = COM4
monitor_speed = 115200

#2

Works for me

main.cpp

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

Ticker flipper;

int count = 0;

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

	++count;
	// when the counter reaches a certain value, start blinking like crazy
	if (count == 20) {
		flipper.attach(0.1, flip);
	}
	// when the counter reaches yet another value, stop blinking
	else if (count == 120) {
		flipper.detach();
	}
}

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

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

void loop() {
}

platformio.ini

[env:esp8266]
platform = espressif8266
board = nodemcuv2
framework = arduino
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [====      ]  35.2% (used 28796 bytes from 81920 bytes)
PROGRAM: [==        ]  24.7% (used 257628 bytes from 1044464 bytes)
 [SUCCESS] Took 11.43 seconds 

#3

I changed my plattform.ini to match yours … => no luck.

Then I looked at

c:.platformio\lib\ and found a another “ticker” library

When I removed that it all worked fine.

Just a note, from VS Code PlatformIO IDE, no external library is installed. So something is mixed up here.