arduino-libraries / Scheduler

Scheduler Library for Arduino
http://arduino.cc/
46 stars 22 forks source link

Warning on Raspberry pi pico but sketch is recommended by arduino IDE #12

Closed drakejest closed 3 years ago

drakejest commented 3 years ago

Im getting a warning when compiling for raspberry pi pico.

WARNING: library Scheduler claims to run on mbed architecture(s) and may be incompatible with your current board which runs on mbed_rp2040 architecture(s).

But the sketch and the library is recommended to me by the IDE.

image

So far it is working but its quite unsettling, that not everything might work or something is not working properly behind that i am not aware of. The sketch even says :

_Demonstrates the use of the Scheduler library for the boards:

Note: Although this seem to be the offical repo for the library the MultipleBlink Example in this repo is not the same as the one i am given.

here is what i am given

/*
 Multiple Blinks

 Demonstrates the use of the Scheduler library for the boards:

 - Arduino Nano 33 BLE, or
 - Arduino Portenta H7, or
 - Arduino Nano RP2040 Connect

 Hardware required :
 * None (LEDs are already conencted to RGB LED)

 ATTENTION: LEDs polarity is reversed (so loop3 will turn the LED off by writing 1)

 created 8 Oct 2012
 by Cristian Maglie
 Modified by
 Scott Fitzgerald 19 Oct 2012

 This example code is in the public domain

 http://www.arduino.cc/en/Tutorial/MultipleBlinks
*/

// Include Scheduler since we want to manage multiple tasks.
#include <Scheduler.h>

// On Nano RP2040 Connect, RGB leds are connected to the wifi module
// The user APIs are the same, but we can't convert to int, so use defines
#if defined(ARDUINO_NANO_RP2040_CONNECT)

#include "WiFiNINA.h"
#define led1  LEDR
#define led2  LEDG
#define led3  LEDB

// On Nicla Sense ME, RGB leds are connected via an I2C module
// The user APIs are the same, but we can't convert to int, so use defines
#elif defined(ARDUINO_NICLA)

#include "Nicla_System.h"
#define led1  LEDR
#define led2  LEDG
#define led3  LEDB

#else

int led1 = LEDR;
int led2 = LEDG;
int led3 = LEDB;

#endif

void setup() {
  Serial.begin(9600);

  // Setup the 3 pins as OUTPUT
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

  // Add "loop2" and "loop3" to scheduling.
  // "loop" is always started by default.
  Scheduler.startLoop(loop2);
  Scheduler.startLoop(loop3);
}

// Task no.1: blink LED with 1 second delay.
void loop() {
  digitalWrite(led1, HIGH);

  // IMPORTANT:
  // When multiple tasks are running 'delay' passes control to
  // other tasks while waiting and guarantees they get executed.
  delay(1000);

  digitalWrite(led1, LOW);
  delay(1000);
}

// Task no.2: blink LED with 0.1 second delay.
void loop2() {
  digitalWrite(led2, HIGH);
  delay(100);
  digitalWrite(led2, LOW);
  delay(100);
}

// Task no.3: accept commands from Serial port
// '0' turns off LED
// '1' turns on LED
void loop3() {
  if (Serial.available()) {
    char c = Serial.read();
    if (c == '0') {
      digitalWrite(led3, LOW);
      Serial.println("Led turned off!");
    }
    if (c == '1') {
      digitalWrite(led3, HIGH);
      Serial.println("Led turned on!");
    }
  }

  // IMPORTANT:
  // We must call 'yield' at a regular basis to pass
  // control to other tasks.
  yield();
}
per1234 commented 3 years ago

Hi @drakejest. Thanks for your report. The problem is that the "Arduino Mbed OS Boards" platform was getting really huge as more and more boards were added to it and so it was split into multiple "families" in order to improve the performance. Previously, all the boards of the platform had a single architecture: mbed. In order to accomplish the split, it was necessary to give each board "family" its own architecture, which followed the mbed_* format.

There is an architectures field in the Arduino library metadata file that allows the library author to indicate which architectures are supported by the library. We forgot to update the metadata at the same time as the architecture names were changed. But that has since been done (https://github.com/arduino/ArduinoCore-mbed/pull/340), and that fix will be in the next release of the "Arduino Mbed OS RP2040 Boards" platform.

Although this seem to be the offical repo for the library the MultipleBlink Example in this repo is not the same as the one i am given.

The reason is that there is a special version of the Scheduler library for the Mbed OS boards. That version is bundled with the boards platform: https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/Scheduler This "platform bundled library" system allows you to have this more general purpose installation of the Scheduler library installed at the same time as the platform-specific version. The IDE will generally pick the right library automagically and the library APIs are generally consistent, so it is not usually obvious to the user that they might have multiple versions of a given library installed and in use for their various boards.

So all is well and the right library is in use. You can safely ignore this warning.

drakejest commented 3 years ago

All is well then :) Thank you for clarifying things up @per1234 .