Yes, actually I didn't show the other messages because I didn't understand that there was a relationship between them.
It is actually the unused variable that causes this message, but it was not possible to remove the variable without other errors occurring. It is necessary to resolve this warning in another way. I don't know if this is a BUG, because when removing the variable, another routine indicates missing the variable, so the variable is being used.
Actually only one variable is causing these messages about 'In instantiation of 'xxxx' required from here':
// Generic stringWidth implementation for various kinds of strings
template <class StrType> __attribute__((always_inline)) inline unsigned int _stringWidth(DMDFrame *dmd, const uint8_t *font, StrType str)
{
unsigned int width = 0;
char c;
int idx;
for(idx = 0; c = str[idx], c != 0; idx++) {
int cwidth = dmd->charWidth(c);
if(cwidth > 0)
width += cwidth + 1;
}
if(width) {
width--;
}
return width;
}
When I make use of the 'font' variable these messages stop happening.
// Generic stringWidth implementation for various kinds of strings
template <class StrType> __attribute__((always_inline)) inline unsigned int _stringWidth(DMDFrame *dmd, const uint8_t *font, StrType str)
{
unsigned int width = 0;
char c;
int idx;
c = font[0]; // <------------------------ Use of 'font' variable just to test the warning message
for(idx = 0; c = str[idx], c != 0; idx++) {
int cwidth = dmd->charWidth(c);
if(cwidth > 0)
width += cwidth + 1;
}
if(width) {
width--;
}
return width;
}
When removing the 'font' variable from this instance, these errors below occur:
//template <class StrType> __attribute__((always_inline)) inline unsigned int _stringWidth(DMDFrame *dmd, const uint8_t *font, StrType str)
template <class StrType> __attribute__((always_inline)) inline unsigned int _stringWidth(DMDFrame *dmd, StrType str)
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp: In member function 'unsigned int DMDFrame::stringWidth_P(const char*, const uint8_t*)':
DMD2_Text.cpp:184:42: error: no matching function for call to '_stringWidth(DMDFrame*, const uint8_t*&, _FlashStringWrapper&)'
return _stringWidth(this, font, wrapper);
^
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp:140:77: note: candidate: template<class StrType> unsigned int _stringWidth(DMDFrame*, StrType)
template <class StrType> __attribute__((always_inline)) inline unsigned int _stringWidth(DMDFrame *dmd, StrType str)
^~~~~~~~~~~~
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp:140:77: note: template argument deduction/substitution failed:
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp:184:42: note: candidate expects 2 arguments, 3 provided
return _stringWidth(this, font, wrapper);
^
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp: In member function 'unsigned int DMDFrame::stringWidth(const char*, const uint8_t*)':
DMD2_Text.cpp:239:41: error: no matching function for call to '_stringWidth(DMDFrame*, const uint8_t*&, const char*&)'
return _stringWidth(this, font, bChars);
^
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp:140:77: note: candidate: template<class StrType> unsigned int _stringWidth(DMDFrame*, StrType)
template <class StrType> __attribute__((always_inline)) inline unsigned int _stringWidth(DMDFrame *dmd, StrType str)
^~~~~~~~~~~~
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp:140:77: note: template argument deduction/substitution failed:
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp:239:41: note: candidate expects 2 arguments, 3 provided
return _stringWidth(this, font, bChars);
^
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp: In member function 'unsigned int DMDFrame::stringWidth(const String&, const uint8_t*)':
DMD2_Text.cpp:246:38: error: no matching function for call to '_stringWidth(DMDFrame*, const uint8_t*&, const String&)'
return _stringWidth(this, font, str);
^
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp:140:77: note: candidate: template<class StrType> unsigned int _stringWidth(DMDFrame*, StrType)
template <class StrType> __attribute__((always_inline)) inline unsigned int _stringWidth(DMDFrame *dmd, StrType str)
^~~~~~~~~~~~
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp:140:77: note: template argument deduction/substitution failed:
/DMD2/DMD2-master/examples/Countdown/DMD2_Text.cpp:246:38: note: candidate expects 2 arguments, 3 provided
return _stringWidth(this, font, str);
The other unused variable message does not interfere with the message described above.
size_t DMD_TextBox::write(uint8_t character) {
struct FontHeader header;
memcpy_P(&header, (void *)this->dmd.font, sizeof(FontHeader));
uint8_t rowHeight = header.height+1;
if(width == 0)
width = dmd.width - left;
if(height == 0)
height = dmd.height - top;
uint8_t char_width = dmd.charWidth(character) + 1;
while((cur_x > 0 && cur_x + char_width >= this->width) || pending_newline) { // Need to wrap to new line
if (height >= rowHeight*2) { // Can scroll
cur_y += rowHeight;
cur_x = 0;
if(cur_y + rowHeight > height) { // Scroll
// Variable 'delta' not used:
//int delta = cur_y + rowHeight - height; // the amount that it's over by
}
} else if(pending_newline) { // No room, so just clear display
clear();
} else { // Scroll characters horizontally
int scroll_by = char_width - (this->width - cur_x - 1);
scrollX(-scroll_by);
}
pending_newline = false;
}
if(character == '\n') {
pending_newline = true;
// clear the rest of the line after the current cursor position,
// this allows you to then use reset() and do a flicker-free redraw
dmd.drawFilledBox(cur_x+left,cur_y+top,left+width,cur_y+top+rowHeight, inverted ? GRAPHICS_ON : GRAPHICS_OFF);
}
dmd.drawChar(cur_x+left,cur_y+top,character, inverted ? GRAPHICS_OFF : GRAPHICS_ON);
cur_x += char_width;
return 1;
}