Library worked, now it's broken

IDE v 2.3.2, WIN11

GitHub - dougp2/Multi_Timer_V2: Arduino timer library - multiple types of timers · GitHub was published into the IDE library manager last year.

Now it doesn’t work and different error messages are given depending on which board is the target.

With this sketch;

/* Demonstrate Multi_Timer_V2 on-delay timer function
and timer done one-shot function

Operation and expected result:
- Connect an LED to pin D10 with appropriate current limiting
resistor R1.

       LED    R1
 D10 --->|---/\/\--- GND

- Start the IDE serial monitor. Insure baud rates between
processor and monitor match.

Connect D4 to GND with either a switch or breadboard jumper.

While the timer is running and has not reached preset the
LED on D10 will light.  Once preset is reached LED on D10 goes off.
and the built-in LED turns on.  When
switch is off or jumper is removed built-in LED turns off.

When the timer reaches preset a counter is incremented 
and the value is displayed on the IDE serial monitor.
*/

#include <Multi_Timer_V2.h>

OnDelayTimer myTimer1(1000);

int counter1 = 0;
byte timerRunning = 10;
byte switch1 = 4;




void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(timerRunning, OUTPUT);
  pinMode(switch1, INPUT_PULLUP);
}

void loop() {
  myTimer1.update();  // refresh the timer value and flags

  // Enable/disable the timer using the ternary operator
  myTimer1.setEnable(digitalRead(switch1) ? false : true);

  // Turn an output on or off using the ternary operator
  digitalWrite(LED_BUILTIN, myTimer1.isDone() ? HIGH : LOW);

  // Turn an output on or off using if/else
  if (myTimer1.isRunning()) {
    digitalWrite(timerRunning, HIGH);
  } else digitalWrite(timerRunning, LOW);

  // Show the updated counter value
  if (myTimer1.getDoneRose()) {
    Serial.println(++counter1);
  }
}

ATtiny85/Micronucleus error. Board = Amazon.com: 3pcs Digispark Kickstarter ATtiny85 Module General Micro USB Development Board for Arduino : Electronics :

In file included from C:\Users\User\OneDrive\Documents\Arduino\compile_test1\compile_test1.ino:25:0:

c:\Users\User\OneDrive\Documents\Arduino\libraries\Multi_Timer_V2\src/Multi_Timer_V2.h:155:9: error: conflicting return type specified for 'virtual bool OffDelayTimer::update()'

bool update();

^~~~~~

c:\Users\User\OneDrive\Documents\Arduino\libraries\Multi_Timer_V2\src/Multi_Timer_V2.h:84:19: error: overriding 'virtual boolean Multi_Timer::update()'

virtual boolean update(); // Updates the timer which calls it.

^~~~~~

UNO error:

c:\Users\User\OneDrive\Documents\Arduino\libraries\Multi_Timer_V2\src\Multi_Timer_v2.cpp:261:30: error: virt-specifiers in 'update' not allowed outside a class definition

bool OffDelayTimer::update() override{

^~~~~~~~

I discovered this while working on a project using a DigiStump ATtiny85 clone. One of the possible problems with this board is mentioned at the bottom of the FadeLed readme

Pushing the can down the road I moved development to an UNO. I now get library errors on that board also.

Possibly useful: When I put this library up it did appear in the library manager and the examples appeared in the library dropdown. It’s still visible in the library manager and the ‘include library’ dropdown but the examples don’t show.

I verified all the libarary examples on the UNO before publishing and everything worked. Now, not so much.

What I’ve tried:

Shutdown the IDE and restarted.

Shutdown the PC and restarted.

One of the possible problems with this board (Digistump) is mentioned at the bottom of the FadeLed readme –

<Error compiling for Digispark GitHub - septillion-git/FadeLed: Makes fading LEDs on an Arduino easy · GitHub >.

I added the indicated flag(?) to the platform.txt file but that didn’t help. I’ve since removed that bit from the platform.txt file.

What have I done wrong?

Sorry I have never used this before...

But maybe which compiler that is used has been updated (i.e. a newer board version or the like)

My guess is that it does not like that your base class has (line 84):
virtual boolean update(); // Updates the timer which calls it.

And your sub-class at line: 155 has:
virtual bool update();

So you probably need to choose either bool or boolean and make them consistent.

Unzipped the library into sketchbook/libraries, copied your code into my standard Uno R3 test project and:

arduino-cli compile -b arduino:avr:uno --warnings all --output-dir ~/tmp --no-color (in directory: /home/me/Documents/sketchbook/Uno_R3/test)
Sketch uses 5736 bytes (17%) of program storage space. Maximum is 32256 bytes.
Global variables use 267 bytes (13%) of dynamic memory, leaving 1781 bytes for local variables. Maximum is 2048 bytes.
Compilation finished successfully.

Bottom line: worked for me.

Edit: on the Uno... when I tried it with ATTinyCore:avr:attinyx5:chip=85 I got your errors.

Solution to make it compile with an ATtiny85 is as @KurtE suspected: change line 84 in Multi_Timer_V2.h to

  virtual bool update();  // Updates the timer which calls it.

Yes! I changed line 83 – header file – to bool to conform with line 155.

@KurtE's suggestion is the cure. Both target processors now compile cleanly.
Thank you!

This tells me bool and boolean do not have identical meanings to the compiler.

The reason is that these are not valid Arduino sketches. I submitted a pull request to fix them:

Please review and merge the pull request at your convenience.