I use an Attiny88 board. I program it with the Arduino IDE.
When I want to use libraries there are sometimes problems, the code does not want to compile correctly.
Here is an example. I use the library SoftwareI2C. But it seems to cause a problem:
In file included from C:\Users\ordi2113604\Documents\Arduino\libraries\SH1106Lib-master/SH1106Lib.h:21:0,
from C:\Users\ordi2113604\Documents\Arduino\1-ordi-lycee\attiny88oledText\attiny88oledText.ino:28:
C:\Users\ordi2113604\Documents\Arduino\libraries\SoftI2CMaster-master\src/SoftI2CMaster.h:347:18: error: missing binary operator before token "("
#if __has_include("digitalWriteFast.h")
^
exit status 1
Compiling error for MH-ET LIVE Tiny88(16.0MHz) board
Do you understand the error?
I was able to solve it like this but it's probably not a good solution:
#if 1==0 //__has_include("digitalWriteFast.h")
Pourtant cette erreur ne se produit pas quand j'utilise "AttinyCore" pour programmer l'attiny88 à la place d'utiliser "MH-ET LIVE Boards" (officiel).
Comprenez vous pourquoi ceci se passe ? Comment le résoudre ?
When I replace with this. I can upload my code without problems, and the program works.
You are right. The library (should I call it library?) AttinyCore seems to be better than the official library.
But I mainly posted this topic to understand this strange problem.
If the problem is in one of the libraries used (here SofwareI2C), why does the compiler not take the error into account when selecting AttinyCore?
Here is the code for my sketch:
/*
* SH1106Lib\Examples\Text.ino
* Example sketch demonstrating how use the lib to display text
* glcdfont.h is part of the Adafruit GFX Library:
* https://github.com/adafruit/Adafruit-GFX-Library/blob/master/glcdfont.c
*
* 2018, noti
*/
// config for softwareI2Cmaster lib
#define I2C_HARDWARE 1
#define I2C_TIMEOUT 10
#define I2C_MAXWAIT 10
#define I2C_PULLUP 1
#define I2C_FASTMODE 1
#define SDA_PORT PORTC
#define SDA_PIN 4 // = A4
#define SCL_PORT PORTC
#define SCL_PIN 5 // = A5
// config for tinyprint lib
#define TP_PRINTLINES 0
#define TP_FLASHSTRINGHELPER 1
#define TP_NUMBERS 0
#define TP_FLOAT 0
#define TP_WINDOWSLINEENDS 0
#include <SH1106Lib.h>
#include "glcdfont.h"
SH1106Lib display;
void setup() {
display.initialize();
display.clearDisplay();
display.setFont(font, 5, 7);
display.setTextWrap(true);
display.setTextColor(WHITE, BLACK);
delay(1000);
display.clearDisplay();
display.setCursor(0,0);
display.print(F("Hello World"));
}
void loop() {
}
The board manager core is effectively just another layer of software that sits between your code and the hardware. Think of it a bit like the operating system code.
The code layers all need to match or you will get errors. I suspect there is a mismatch between your sketch, or one of the libraries, and the default core you are using. When you use ATTinyCore this issue goes away.
I have found ATTinyCore to be much better than the default... the biggest advantage is that a lot of work has gone in so that the code that sits above it is much more like the code, that for example would run on an Uno. You don't need special versions of ATTiny code.
It is an art to learn how to read error messages, but you can do that. You will use that the rest of your life with computers, so pay attention to what kind of messages lead to what causes... irrelevant of the language ... if you use a computer, learn how to read it's complaints.
generally forgotten about is a debugger. When you can look at values while the program is in operation is so much more simple than sprinkling some kind of output statement...
'print' statements are of little use with an embedded micro that has no way to output something during testing/development.
Both of these take time to learn, but the payoff is big and relatively quickly compared to other technical learning curves ...