I'm using several TM1637 displays to create timers, so I decided to make a Timer class. Every time I initialize an instance of the Timer class, I want it to create an instance of the TM1637Display class. So I started out with this, but the display object can't be accessed from within updateDisplay.
class Timer {
public:
Timer(uint8_t CLK, uint8_t DIO) {
TM1637Display display(CLK, DIO);
...
}
void updateDisplay() {
...
display.setSegments(displayData);
}
}
And if I do this I get the compile time error In constructor 'Timer::Timer(uint8_t, uint8_t)': src\main.cpp:16:37: error: no matching function for call to 'TM1637Display::TM1637Display()'
TM1637Display display;
Timer(uint8_t CLK, uint8_t DIO) {
display(CLK, DIO);
...
}
What should I try? Maybe make an empty pointer before the display instance is created with a public scope, assign the pointer to the display instance, then hand the updateDisplay function the pointer? That seems really convoluted.