Trying to display on OLED the "right way"

I am trying to create my own “display controllers”, one for each of my props (multi_prop.h, jetpack_prop.h & morsecode_prop.h. For now, they are all in a file I called multipropdisplaycontroller.h, I used a copy of all the elements from BlasterDisplayController() as an example:

I adapted all the codes to my props and came up with my version 00. To my surprise, it compiled almost immediately (just a few missing/stray commas, and a few typing mistakes to correct, but no weird or complicated errors).

I added in ssd1306.h these few lines:

#ifdef PROPS_MULTI_PROP_H                 // added by Oli
#include "multipropdisplaycontroller.h"   // added by Oli
#endif                                    // added by Oli

So my code would not use extra memory when it is not needed.

So far so good, now lets add some stuff to display some text messages. And this is where the problem started.
Please find attached my version02
multipropdisplaycontroller.h (13.9 KB)

And this is the errors I am getting:

In file included from C:\...\ProffieOS\display\ssd1306.h:984,
                 from C:\...\ProffieOS\ProffieOS.ino:1556:
C:\...\ProffieOS\display\multipropdisplaycontroller.h: In member function 'void MultiPropDisplayController<Width, col_t, PREFIX>::SB_Effect2(EffectType, EffectLocation)':
C:\...\ProffieOS\display\multipropdisplaycontroller.h:64:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
   64 |   SetMessage("saber/nmode");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:64:3: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
C:\...\ProffieOS\display\multipropdisplaycontroller.h:65:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
   65 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:71:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
   71 |   SetMessage("blaster/n mode");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:72:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
   72 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:78:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
   78 |   SetMessage("detonator/n  mode");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:79:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
   79 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:85:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
   85 |   SetMessage("jetpack/nmode");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:86:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
   86 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:92:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
   92 |   SetMessage("morse code/n  mode");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:93:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
   93 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h: In member function 'void JetpackDisplayController<Width, col_t, PREFIX>::SB_Effect2(EffectType, EffectLocation)':
C:\...\ProffieOS\display\multipropdisplaycontroller.h:189:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  189 |   SetMessage("aiming");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:190:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  190 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:196:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  196 |   SetMessage("targetting");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:197:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  197 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:203:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  203 |   SetMessage("launching\nmissile");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:204:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  204 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:210:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  210 |   SetMessage("missile\nexplodes");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:211:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  211 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:217:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  217 |   SetMessage("nice shot");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:218:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  218 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:224:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  224 |   SetMessage("disarming");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:225:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  225 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:233:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  233 |   SetMessage("jetpack\nfalse start");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:234:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  234 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:240:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  240 |   SetMessage("jetpack\nstuttering");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:241:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  241 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:247:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  247 |   SetMessage("jetpack\nself destruct");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:248:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  248 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:253:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  253 |   SetMessage("jetpack\nigniting");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:254:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  254 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:257:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  257 |   SetMessage("jetpack\nidling");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:258:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  258 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:261:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  261 |   SetMessage("jetpack\nstarting");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:262:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  262 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:265:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  265 |   SetMessage("jetpack\running");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:266:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  266 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:269:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  269 |   SetMessage("jetpack\nshutdown");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:270:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  270 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:273:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  273 |   SetMessage("  jetpack\ncompletely off");
      |   ^~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h:274:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  274 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~
C:\...\ProffieOS\display\multipropdisplaycontroller.h: In member function 'void MorseCodeDisplayController<Width, col_t, PREFIX>::SB_Effect2(EffectType, EffectLocation)':
C:\...\ProffieOS\display\multipropdisplaycontroller.h:328:3: error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]
  328 |   SetMessage("add morsecode\ndisplay variable here");
C:\...\ProffieOS\display\multipropdisplaycontroller.h:329:3: error: there are no arguments to 'SetScreenNow' that depend on a template parameter, so a declaration of 'SetScreenNow' must be available [-fpermissive]
  329 |   SetScreenNow(SCREEN_MESSAGE);
      |   ^~~~~~~~~~~~

exit status 1

Compilation error: there are no arguments to 'SetMessage' that depend on a template parameter, so a declaration of 'SetMessage' must be available [-fpermissive]

I doubt that the solution would be to just copy paste SetMessage & SetScreenNow functions in each of my display controllers as that would not be an elegant solution.

Thanks for reading so far and thank you for any help.

I think you just need to do this->SetMessage(...) instead of just SetMessage(...)

Ideally these display controllers should live in the prop files.
I haven’t tested that, so there may be issues with doing that, but that is the intent.

1 Like

That was easy enough and painless. I do not understand what this-> do but it worked.

That is a great idea, I will test that and report back.
Where in the prop files do you think it should go:

  • before the prop declaration, at global level,
  • within the prop declaration,
  • or after the prop declaration ?

And I guess I should “sandwich” the code between:

#if defined(INCLUDE_SSD1306) || defined(ENABLE_SSD1306)
... display controller code goes here ...
#endif

For anyone who’s interested, this is the working version:
multipropdisplaycontroller.h (14.1 KB)

I tried all 3, they all give the same or similar errors, I used:

#if defined(INCLUDE_SSD1306) || defined(ENABLE_SSD1306)
#include "multipropdisplaycontroller.h"
#endif

in multi_prop.h
These are the errors both before & after the prop definition:
error_displaycontroller_after.or.before_prop.h (39.9 KB)
These are the errors if used within the prop definition:
error_displaycontroller_within_prop.h (42.6 KB)

Only INCLUDE_SSD1306 is required.
If the config file has ENABLE_SSD1306, it’s not going to use your controller anyawys.

Before or after the prop class, NOT inside.
However, looking at it, it will not work as intended right now, because the prop file is included before the display code. I have some ideas for how I can do it, but it will require a little re-organizing to do.

Done

I’ll keep an eye on Github for the update. Thank you for your assistance as always.