0

I'm trying to make the qMenuSystem to work with my I2C Monochrome OLED display but without any luck. To summarize all here's what's with it : - the qMenuSystem is using a library called : DigoleSerial but has the things set as SPI connection - the library itself can work with I2C but i'm receiving some strange errors like this :


Arduino: 1.8.9 (Mac OS X), Board: "Arduino/Genuino Uno"

TestMenu:25:42: error: expected primary-expression before '_disp'
 DigoleSerialDisp mydisp=DigoleSerialDisp _disp(&Wire,'\x3C');
                                          ^
exit status 1
expected primary-expression before '_disp'

Here is the video of what i'm trying to display:

https://www.youtube.com/watch?v=rjON_enuOGs (I already tried what's suggested in the comments)

Here's the code so far:

#define _Digole_Serial_I2C_
#include <DigoleSerial.h>
#include <Wire.h>

#include <qMenuDisplay.h>
#include <qMenuSystem.h>

#include "TestMenu.h"

//DigoleSerialDisp mydisp=DigoleSerialDisp(8,9,10);
//DigoleSerialDisp _disp(&Wire,'\x3C');

DigoleSerialDisp mydisp=DigoleSerialDisp _disp(&Wire,'\x3C');
qMenuSystem menu=qMenuSystem(mydisp);

void setup()
{
  menu.InitMenu(mnuRoot,cntRoot,1);
  Serial.begin(9600);
}

void loop()
{
  int keycode=0;
  int clickedItem=0; 

  if (Serial.available()>0)
  {
    switch(Serial.read())
    {
      case 97:
        menu.ProcessMenu(ACTION_DOWN);
        break;
      case 113:
        menu.ProcessMenu(ACTION_UP);
        break;
      case 115:
        clickedItem=menu.ProcessMenu(ACTION_SELECT);
        break;
    }
  }

  if (clickedItem>0)
  {
    // Logic for Root menu
    if (menu.CurrentMenu==mnuRoot)
      switch (clickedItem)
      {
        case 1:
          menu.InitMenu(mnuSubmenu1,cntSubmenu1,1);
          break;
        case 2:
          menu.InitMenu(mnuSubmenu2,cntSubmenu2,1);
          break;
        case 3:
          menu.InitMenu(mnuSubmenu3,cntSubmenu3,1);
          break;
        case 4:
          menu.MessageBox("Some message!");
          break; 
      }
    // Logic for Submenu 1
    else if (menu.CurrentMenu==mnuSubmenu1)
      switch (clickedItem)
      {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
          menu.MessageBox("Item clicked");
          break;
        case 6:
          menu.InitMenu(mnuRoot,cntRoot,1);
          break;
      }
    // Logic for Submenu 2
    else if (menu.CurrentMenu==mnuSubmenu2)
      switch (clickedItem)
      {
        case 1:
          menu.MessageBox("On");
          break;
        case 2:
          menu.MessageBox("Off");
          break;
        case 3:
          menu.InitMenu(mnuRoot,cntRoot,2);
          break;
      }
    // Logic for Submenu 3
    else if (menu.CurrentMenu==mnuSubmenu3)
      switch (clickedItem)
      {
        case 1:
          menu.MessageBox("Enabled");
          break;
        case 2:
          menu.MessageBox("Disabled");
          break;
        case 3:
          menu.InitMenu(mnuRoot,cntRoot,3);
          break;
      }

  } 
}

and the progmem part :

// required for "prog_char" and "PROGMEM"
#define _PROG_TYPES_COMPAT_
#include <avr/pgmspace.h>

// texts for menus

const char itmBack[] PROGMEM = "< Back";
const char itmOn[] PROGMEM = "On";
const char itmOff[] PROGMEM = "Off";
const char itmEnabled[] PROGMEM = "Enabled";
const char itmDisabled[] PROGMEM = "Disabled";

const char itmRoot[] PROGMEM = "Root menu";
const char itmSubmenu1[] PROGMEM = "Submenu 1";
const char itmSubmenu2[] PROGMEM = "Submenu 2";
const char itmSubmenu3[] PROGMEM = "Submenu 3";
const char itmMessageBox[] PROGMEM = "Message box";
const char itmItem1[] PROGMEM = "Item 1";
const char itmItem2[] PROGMEM = "Item 2";
const char itmItem3[] PROGMEM = "Item 3";
const char itmItem4[] PROGMEM = "Item 4";
const char itmItem5[] PROGMEM = "Item 5";

////////////////////////////////////////////////////////////////
// menus - first item is menu title and it does not count toward cnt

const char* mnuRoot[] = {
  itmRoot,
  itmSubmenu1,itmSubmenu2,itmSubmenu3,itmMessageBox};
const int cntRoot = 4;

const char* mnuSubmenu1[] = {
  itmSubmenu1,
  itmItem1,itmItem2,itmItem3,itmItem4,itmItem5,itmBack};
const int cntSubmenu1 = 6;

const char* mnuSubmenu2[] = {
  itmSubmenu2,
  itmOn,itmOff,itmBack};
const int cntSubmenu2 = 3;

const char* mnuSubmenu3[] = {
  itmSubmenu3,
  itmEnabled,itmDisabled,itmBack};
const int cntSubmenu3 = 3;

I'm kinda new and I have no idea how can I make it work. Can anyone please help me figure it out what's wrong ?

Thank you for your time reading all of this.

| improve this question | | | | |
0

As the compiler is indicating, the line

DigoleSerialDisp mydisp=DigoleSerialDisp _disp(&Wire,'\x3C');

is broken.

This part:

DigoleSerialDisp _disp(&Wire,'\x3C')

declares and constructs an object named _disp of class DigoleSerialDisp.

You're trying to assign that to another variable, mydisp - that's not valid C++ - you can assign another variable, but you'd need to declare and construct it first, not in the assignment. There's also no need to construct it, name it _disp and then assign it to another variable.

Just do this:

DigoleSerialDisp mydisp(&Wire,'\x3C');

You'll probably want to rewrite

qMenuSystem menu=qMenuSystem(mydisp);

as

qMenuSystem menu(mydisp);

as well.

| improve this answer | | | | |
  • Thank you very much for your explanation and for your help. Now it's compiling without any error. All's good but I can't see anything on the display. My OLED is working well when I use the Adafruit SSD1306 library with Adafruit GFX library, but I don't know about this DigoleSerial library. Here's my OLED (sort of , it looks the same) : bit.ly/2kgZa6p . It's using the address 0x3C when I use the Adafruit libraries. Is it anything i still missing ? Thank you again for the fast help. – h4x7o0r Sep 4 '19 at 6:10
  • I'm glad this was helpful. If you have another question the best thing to do is accept this as the answer to the question you asked and ask your other question separately. This helps other people with similar problems find the answer to their problem, and lets other people who may be able to help you with your next problem find the question and offer help (they won't find it here in the comments). – romkey Sep 4 '19 at 17:34
  • Thank you again. I'm new here so i don't really know the flow but I get it. I'll ask a new question in a new topic. – h4x7o0r Sep 4 '19 at 21:33
  • You're doing great :) Thanks! – romkey Sep 5 '19 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.