Cannot Override <sendCommand> in Adafruit_SSD1351

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
djwdjw
 
Posts: 1
Joined: Mon Nov 08, 2021 6:13 pm

Cannot Override <sendCommand> in Adafruit_SSD1351

Post by djwdjw »

Hi,
I have been struggling to 'do the right thing', laughing. Years ago I used a DUE and a OLED_NHD-1.5-128128 for a project. At that time I also had a FPGA in the design and choose
to use the OLED parallel 6800 interface rather than the SPI. We can argue about if that was smart. But anyway I ended up hacking the Adafruit_SSD1351 library horribly. I was not proud but it did work. Now I am at it again with a similar project trying to be the professional that I am not,... (Yes I am an EE) I have a fair mastery of C but I am NOT a master of C++.

So I am again using the parallel interface now connected to a Pi Pico. I have written a bunch of PIO code etc and managed to test the -driver- which works. But NOW what to do ?
I need to interface it to the Adafruit_GFX , Adafruit_SSD1351 libraries without making a total mess of them. In fact I WANT to "do the right thing" and - override - a method in
Adafruit_SPITFT which is part of the class hierarchy for the Adafruit_SSD1351 class. The method is the void sendCommand(uint8_t , uint8_t *, uint8_t ) function.

Recall I mentioned I am not a C++ guru,... but via hours of trial and error, internet searches etc I - think - I know the problem, and low - for once it may not be my problem,...
I have been attempting to override sendCommand but get this error:
'void OLED_LowLevelDriver::sendCommand(uint8_t, uint8_t*, uint8_t)' marked 'override', but does not override

If all those gurus on the internet are correct this error is because the sendCommand function is not marked virtual in the Adafruit_SPITFT class.
Here I try to override,

Code: Select all

#include "Adafruit_SSD1351.h"
class OLED_LowLevelDriver : public Adafruit_SSD1351 {
 public:
     void sendCommand(uint8_t , uint8_t *, uint8_t ) override ;
};
This is the function I wan to use for the override:

Code: Select all

void OLED_LowLevelDriver::sendCommand(uint8_t commandByte, uint8_t *dataBytes, uint8_t numDataBytes) {
   // some code
}
Of course there is more code but the above is the essence.
Also the instantiation:

Code: Select all

OLED_LowLevelDriver oled = OLED_LowLevelDriver(128, 128);
I suspect that the what I am trying is appropriate BUT the problem is in the Adafruit_SPITFT class where the sendCommand method is not marked - virtual -
Being a C++ dummy, I lay myself at your feet and humbly request:
1) is my analysis correct?
2) if so would Adafruit please modify the Adafruit_SPITFT so that sendCommand may be overriden?

Cheers Dan

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”