Problem: When I include LedControl.h (or even LedController.hpp) in a sketch, I get 200 pages of warnings from the compiler.
Background: I've successfully used LedControl with 7-segment 8-digit LED displays on the Arduino Uno, but now that I'm going to the MKR Zero, I get these warnings.
Warnings:
C:\Users\info\Documents\Arduino\libraries\LedControl\src/LedControl.h:43:5: warning: 'B01111110' is deprecated: use 0b01111110 instead [-Wdeprecated-declarations]
B01111110,B00110000,B01101101,B01111001,B00110011,B01011011,B01011111,B01110000,
These warnings go on for another 200 pages (MS Word pages) in a similar vein.
Appreciate any insights. Thanks.
Here's my code:
#include <LedControl.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
But the compiler now provides binary literals (e.g., 0b00101010) that do the same thing, but better because they are standard and available for the full range of available integer values rather than only 8 bits as is the case for the macros. For this reason, use of the old macros is now deprecated.
Deprecated means that you are discouraged from using them. It does not mean that using them will cause any problems. Although we would like people to start using binary literals, there is such a legacy of use of the old macros, and so little maintenance effort required to keep them, that it is very unlikely the old macros would ever be removed from the core library.
So you have two options:
Convert the library to use binary literals. You might check to see if there is a new version of the library where someone has already done it first.
Just ignore the innocuous warnings.
The choice is yours.
You might wonder why you get them when compiling for one board but not the other. The reason is that these were added to the modern shared core library code "ArduinoCore-API". That has been integrated into the core of the "Arduino SAMD Boards" platform of the Zero. However it has not yet been integrated into the core of the "Arduino AVR Boards" platform of the Uno. At such time as the Arduino firmware developers get around to integrating ArduinoCore-API into Arduino AVR Boards platform's core, you will start seeing the same warnings when compiling for other boards.
Thank you, pert, for the quick and comprehensive response explaining why my compilation is filled with self-deprecating remarks!
And, noiasca, thanks for your update of Eberhard's LedControl.h library. I did download it, and when I included it in my sketch, I still got lots of warnings of this type:
C:\Users\info\Documents\Arduino\libraries\NoiascaLedControl\src/NoiascaLedControlCommon.h:88:45: warning: 'B01110000' is deprecated: use 0b01110000 instead [-Wdeprecated-declarations]
B01100111,B11111110,B00000101,B01011011,B01110000,B00011100,B00011100,B00000000, //P Q r S t u u @112
But I can probably proceed to test with it, especially since you provided such excellent documentation and examples.
This forum is an outstanding resource because of the efforts of experts like yourselves.
I'm very sorry for that. I checked it against a lokal copy - not what was avaialbe as download ;-(.
I've updated the library on the webserver and you can download a corrected version now.
noiasca:
Thanks for your quick reply. I deleted the old version from my library, downloaded again just now from the webserver. When I run the example LCDemoNoiascaHelloWorld
it compiles fine for the Arduino Uno, but it gives the following compilation error when I specify the compilation for the MKR Zero:
C:\Users\info\AppData\Local\Temp\arduino_build_179412\libraries\NoiascaLedControl\NoiascaLedControlCommon.cpp.o: In function LedControl_base::LedControl_base(unsigned char)': C:\Users\info\Documents\Arduino\libraries\NoiascaLedControl\src/NoiascaLedControlCommon.cpp:52: undefined reference to vtable for LedControl_base'
collect2.exe: error: ld returned 1 exit status
Using library NoiascaLedControl at version 1.2.0 in folder: C:\Users\info\Documents\Arduino\libraries\NoiascaLedControl
Using library SPI at version 1.0 in folder: C:\Users\info\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\libraries\SPI
exit status 1
Error compiling for board Arduino MKRZERO.
Just to be complete, here is the code for your Hello World example:
/*******************************************************************************
HelloWorld with
NoiascaLedControl
This is a demo Sketch to show up the new print methods of
the extended LedControl Library
name=LCDemoNoiascaHelloWorld
version=1.0.1
author=noiasca
adopted by noiasca
Sketch Version 2020-03-08
*******************************************************************************/
//We always have to include the library
#include "NoiascaLedControl.h"
/*
Now we need a LedControl to work with.
***** These pin numbers will probably not work with your hardware *****
Here we have only two MAX72XX.
*/
const uint8_t LEDCS_PIN = 8; // 8 LED CS or LOAD - 8 CS
const uint8_t LEDCLK_PIN = 13; // 7 LED Clock - 13 CLK on UNO/NANO
const uint8_t LEDDATA_PIN = 11; // 9 LED DATA IN - 11 MOSI on UNO/NANO
const uint8_t LED_MODULES = 1;
LedControl lc = LedControl (LEDDATA_PIN, LEDCLK_PIN, LEDCS_PIN, LED_MODULES); // Software Bitbang - use this if you can't use Hardware SPI
//LedControl lc = LedControl (LEDCS_PIN, LED_MODULES); // Hardware SPI (UNO/NANO: 13 CLK, 11 DATA_IN/MOSI)
/* we always wait a bit between updates of the display */
const unsigned long delaytime = 250;
/* we wait longer between the demos */
const unsigned long delaylong = 5000;
void setup() {
/* Open the Serial Monitor to know what the program is doing */
Serial.begin(115200);
Serial.println(F("Noiasca Led Control HelloWorld"));
/* The MAX72XX needs to initialize hardware */
lc.begin();
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
for (byte i = 0; i < LED_MODULES; i++)
{
lc.shutdown(i, false);
/* Set the brightness to a medium value, possible is 0-15 */
lc.setIntensity(i, 8);
}
/* and clear all displays */
lc.clearDisplay();
}
/*
This function will display the characters for the
word "Arduino"
*/
void writeArduinoOn7Segment() {
Serial.println(F("Print \"Arduino\" to LED Display"));
lc.clearDisplay();
lc.print("Arduino");
delay(delaylong);
}
/*
This function will display different characters/words
*/
void printDemo() {
lc.clearDisplay();
Serial.println(F("Print one character"));
lc.print("A");
delay(delaylong);
lc.clearDisplay();
Serial.println(F("Print more characters/a word: Arduino"));
lc.print("Arduino");
delay(delaylong);
lc.clearDisplay();
Serial.println(F("Print dots"));
lc.print("So.");
lc.print(" Cool.");
delay(delaylong);
lc.clearDisplay();
Serial.println(F("Printing multiple dots needs a hack"));
Serial.println(F("... will not work"));
lc.print("... no");
delay(delaylong);
lc.clearDisplay();
Serial.println(F(". . . . will work")); // add a blank before consecutive dots
lc.print(". . . . YES");
delay(delaylong);
lc.clearDisplay();
Serial.println(F("Print at device 0, position 2. 0/0 is on the left. Remember: setDigit starts counting at 7!"));
lc.setCursor(0, 2);
lc.print("2pos");
delay(delaylong);
}
/*
This function will display output on multiple IC's
*/
void printMultiple()
{
#if LED_MODULES >1
lc.clearDisplay();
Serial.println(F("If you have more modules you can use setCursor to switch to the second MAX7219 IC"));
lc.setCursor(1, 0);
lc.print("2nd IC");
delay(delaylong);
lc.clearDisplay();
Serial.println(F("If you have more modules you can use setCursor to set the absolute position"));
lc.setCursor(11);
lc.print("11POS");
delay(delaylong);
lc.clearDisplay();
#endif
}
/*
This function will display different numbers on the display
*/
void printNumbers() {
lc.clearDisplay();
Serial.println(F("Print an integer"));
int myint = 1234;
lc.print(myint);
delay(delaylong);
lc.clearDisplay();
Serial.println(F("Print a negative integer"));
myint = -5678;
lc.print(myint);
delay(delaylong);
lc.clearDisplay();
Serial.println(F("Print a negative float. The decimal point will be added to the number!"));
float myfloat = -12.34;
lc.print(myfloat);
delay(delaylong);
}
/*
This function will scroll all the hexa-decimal
numbers and letters on the display. You will need at least
four 7-Segment digits. otherwise it won't really look that good.
*/
void scrollDigits() {
lc.clearDisplay();
Serial.println(F("The Character Set"));
Serial.println(F("Character 0-10 are the numbers and the degrees sign"));
// we use the original function
for (int i = 0; i < 10; i++) {
lc.setDigit(0, 3, i, false);
lc.setDigit(0, 2, i + 1, false);
lc.setDigit(0, 1, i + 2, false);
lc.setDigit(0, 0, i + 3, false);
delay(delaytime);
}
Serial.println(F("From character 37-127 we try to cover as many characters as possible."));
Serial.println(F("Characters K W X are not possible and replaced with a blank. V is replaced by U. Sometimes there needs a mix of small and capital letters."));
lc.clearDisplay();
for (int i = 37; i < 128 - 4; i++) {
Serial.print(char(i));
lc.setCursor(0, 4);
lc.print(char(i));
lc.print(char(i + 1));
lc.print(char(i + 2));
lc.print(char(i + 3));
delay(delaytime);
}
Serial.print(char(125));
Serial.print(char(126));
Serial.print(char(127));
Serial.println();
delay(delaylong);
}
/*
This function shows, #
what happens if you print more than 8 characters
to one device/adress
*/
void showEndOfDevice()
{
// default setting is: NEXT_DEVICE
Serial.println(F("NEXT_DEVICE: At the End of Device (after 8 digits) we use the next available Device.\nAfter the last device go back to Device 0: NEXT_DEVICE (default)"));
lc.clearDisplay(); // will also set the cursor to positon 0 0
// 0123456701234567
lc.print(F("THIS IS TO LONG"));
delay(delaylong);
Serial.println(F("End of device: THIS_DEVICE\n - wraps around within one device (after 8 digits) - you might miss information (indeed you don't miss it - it is just to fast, that you could read it)"));
lc.clearDisplay();
lc.setEndOfDevice(THIS_DEVICE);
lc.print(F("THIS IS TO LONG"));
delay(delaylong);
Serial.println(F("The option FIRST_DEVICE is valid\n - but nearly all usecases can be covered with NEXT_DEVICE"));
lc.clearDisplay();
lc.setEndOfDevice(FIRST_DEVICE);
lc.print(F("THIS IS TO LONG"));
delay(delaylong);
// now let's switch back to the default value:
lc.setEndOfDevice(NEXT_DEVICE);
}
/*
The library supports linefeeds = switch to next device according to the EndOfDevice setting.
*/
void showLinefeed()
{
Serial.println(F("Show Linefeed"));
lc.clearDisplay();
Serial.println(F("- with println")); //println will send a carriage return AND a linefeed - only the linefeed will be used - the carriage return will be ignored
lc.println(F("LINE0"));
delay(delaylong);
Serial.println(F("- with Escape sequence \\n"));
lc.print(F("123456\n"));
delay(delaylong);
lc.println(F("1234567"));
delay(delaylong);
Serial.println(F("Be carefull when printing 8 digits: the eighth digit will cause a linefeed - println will cause a second linefeed!"));
lc.println(F("12345678"));
delay(delaylong);
lc.println(F("abcd"));
delay(delaylong);
}
void loop() {
writeArduinoOn7Segment();
printDemo();
printNumbers();
printMultiple();
scrollDigits();
showEndOfDevice();
showLinefeed();
}
Can you pls do me favor? Can you try to compile for an UNO? In the meantime i download the Arduino SAMD Boards package.
Which Arduino IDE version are you using?
could you please open the file src/NoiascaLedControlCommon.cpp
it now compiles also for the MKRZERO (with some warnings). But I don't have MKR hardware to test with.
If you confirm that you can compile it - or even that the sketch is doing what you expect, I will do another update (including a fix for the other warnings ...).
noiasca: You actually look like an amazingly helpful expert to me!
I modified the .cpp file as you advised, and now the Hello World sketch compiles with the MKR Zero as the specified target hardware. Thank you!
I will play around with it further and keep you up to date.
Again, my great thanks for your responsiveness!
Minor update: I expanded a more complex test sketch that specifies two LED displays ("lc1" and "lc2"), and it compiled and uploaded to the MKR Zero. I haven't yet hooked up the LED display units - that's a bigger project - but I will work on that and report the results. Many thanks.
noiasca: Success! I am using your LedControl library to drive a 7-segment 8-digit LED display with an Arduino MKR Zero. Many thanks!
I look forward to the possible elimination of the warnings in the compilation, but for now my project is in a good place thanks to your expert help.
I had to add the addendum you sent me earlier for the .cpp source in order to get my sketch to compile. Does that make sense?
I still get warnings of this sort:
In file included from C:\Users\info\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/ArduinoAPI.h:26:0,
from C:\Users\info\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/Arduino.h:23,
from C:\Users\info\Documents\Arduino\libraries\NoiascaLedControl\src/NoiascaLedControl.h:75,
from C:\Users\info\Documents\Arduino\libraries\NoiascaLedControl\src\NoiascaLedControl.cpp:31:
C:\Users\info\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/Binary.h:219:3: note: declared here
B00100111 DEPRECATED(0b00100111) = 39,
^~~~~~~~~
I greatly appreciate the effort and expertise you're putting into this. I hope this feedback is helpful.
some files should have timestamps from yesterday 21:31 and there are additional rows in NoiascaLedControl.common.cpp from line 297 to 305.
I even downloaded it know and checked it in a temp folder.
noiasca: I do NOT have the latest version. When I download from the link on the page on your website, I get the December, 2020 version. Where can I access the new version? Thanks!
Just received the lastest version of NoiacsaLedControl.h and it works beautifully. pert & noiacsa, "you are the answers that make my questions disappear."