Hi,
I get a weird error with program that has got a library initialisation and loop wrapped in compiler directives.
Here is my code (simplified to the minimum) to get the error:
//========= (Hardware definitions) =========
//Set definitions to 1 when hardware is present:
#define RF24L01 false
#define LoRaSPI false
#define Display4Dig true
#define Nokia5110Display false
#define OLED128x64Display false
#define OLED64x48Display false
//4*7 Segment LED
#if Display4Dig
#include "TM1637Display.h"
#define CLK 6
#define DIO 5
#endif
void setup() {
//Initialisation Display Hardware
#if Display4Dig
TM1637Display display(CLK, DIO);
display.setBrightness(0x08);
//Turn off segments 1&2, write "dB" on 3&4.
byte data[] = {0x0, 0x0, 0b01011110 , 0b01111100};
display.setSegments(data);
#endif
}
void loop() {
//==== (Display) ======
#if Display4Dig
//TM1637Display display(CLK, DIO);
//display.setBrightness(0x08);
display.showNumberDec(int(23), false, 2, 0);
#endif
}
The library is initialised correctly and should run, but since they are wrapped in compiler directives I got the error:
exit status 1
'display' was not declared in this scope
on instruction
display.showNumberDec(int(23), false, 2, 0);
The complete programm has many such options which were previously all compiled and conditionally executed.
I wanted to redesign the code to be more compact and fit into an ATmega168.
I failed with replacing the conditions with compiler directives.
How can I get it the right way?
For your info:
The program compiles correctly
-if the library is unconditionally included or
-if I uncomment the //TM1637Display display(CLK, DIO); line which repeats the initialization i the loop.
But that's IMHO not the way it should be.
Thank you for your advice.
Laszlo