REBL_UI - Many errors when trying to compile unedited code.

So I downloaded the REBL_UI example from GitHub, and I also am to compile. This is this code on github without edits of any kind. I get the gamut of fun1 and remainder of menu items not declared. I was using IDE 1.8, I downgraded to 1.6, and even 1.05 I think was as far back as I went in IDE versions. None have compiled, usually getting non-declaration errors of some kind.

I have ensured my copies are what are on the github char for char, no clue why it fails. I am not well versed in programming, so software is not my strong point.

I need an easy to modify/configure 16x2 LCD Menu that is Rotary Encoder equipped that can vary several different variables as well as menu screens all from the rotary and single pushbutton, if anyone has suggestions for some other menu system that WORKS I would be grateful.

URL: GitHub - delta-G/REBL_UI: Simple menu UI for Arduino with 16x2 LCD, rotary encoder, and a single button

#include "REBL_UI.h"
#include <LiquidCrystal_SPI_8Bit.h>
#include <Time.h>

#define ENCODER_INTERRUPT_PIN 2
#define ENCODER_B_PIN 4
#define BUTTON_PIN 8
#define LCD_ENABLE_PIN A1
#define LCD_RS_PIN A3
#define HEART_BEAT_PIN A5
#define LCD_BLUE A0
#define LCD_GREEN A2
#define LCD_RED A4



MenuItem PROGMEM menuItems[] = {
  {
    "display", fun1   }
  ,
  {
    "press", pressToExit   }
  ,
  {
    "enter number", pickNumber   }
  ,
  {
    "enter string", fourLetterWord   }
  ,
  {
    "set time", enterTime   }
  ,
  {
    "show time", showTime   }
};

MenuList menuList(menuItems, menuListSize(menuItems));



void setup() {
  initLCD(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_RED, LCD_GREEN, LCD_BLUE);
  initInterface(BUTTON_PIN, ENCODER_INTERRUPT_PIN, ENCODER_B_PIN);
  reblMenu.setCurrentMenu(&menuList);
}

void loop() {
  pollButton();
  static unsigned long preMil = millis();
  unsigned long curMil = millis();
  if (curMil - preMil >= DISPLAY_DELAY) {
    preMil = curMil;
    reblMenu.doMenu();
    doDisplay();
  }

}


boolean fun1() {
  displayLineLeft(0, F("Display This"));
  displayLineLeft(1, F("   ")); // to clear the line
  return displayDelay(3);
}

boolean pressToExit() {
  displayLineLeft(0, F("Press Button"));
  displayLineLeft(1, F("to Exit"));
  if(!isButtonOn()) {
    buttonOn();
  }
  else if(checkButton()) {
    buttonOff();
    return true;
  }
  return false;
}

boolean pickNumber() {
  static int state = 0;
  static int val = 0;

  switch (state) {
  case 0: 
    {
      val = 0;
      state++;
    }
  case 1: 
    {
      if (enterNumber(val, F("Enter Number"), 0, 50, 1)) {
        state++;
      }
      break;
    }
  case 2: 
    {
      if (displayDelay(3)) {
        state = 0;
        return true;
      }
      displayLineLeft(0, "You Entered:");
      char buf[6];
      sprintf_P(buf, PSTR("%d"), val);
      displayLineLeft(1, buf);
      break;
    }
  }  // end switch (state)
  if(reblMenu.isCancelled()){
    state = 0;
    val = 0;
    return true;
  }
  return false;
}

boolean fourLetterWord() {
  static char theStr[5] = "four";
  static int state = 0;

  switch (state) {

  case 0: 
    {  // enter the string
      if (enterString(theStr, 4)) {
        state++;
        break;
      }
      theStr[4] = 0;  // just in case.
      displayLineLeft(0, F("4 Letter Word"));
      displayLineLeft(1, theStr);
      break;
    }

  case 1: 
    {   // display the entered string
      displayLineLeft(0, F("You Entered"));
      displayLineLeft(1, theStr);
      if(displayDelay(3)) {
        state = 0;
        encoderOff();
        buttonOff();
        return true;
      }
      break;
    }
  }		//  end switch (state)
  if(reblMenu.isCancelled()){
    state = 0;
    return true;
  }
  return false;
}

boolean enterTime() {
  static time_t timeSetTime = 0;
  static int state = 0;

  switch (state) {

  case 0: 
    {  // turn things on and setup variables
      timeSetTime = now();
      state++;
    }
    /* no break */
  case 1: 
    {   // input the time
      if (inputTime(timeSetTime)) {
        state++;
        setTime(timeSetTime);
      }
      break;
    }
  case 2: 
    {   // display the running time for 10 seconds
      displayTime(now());
      if (displayDelay(10)) {
        state = 0;
        return true;
      }
      break;
    }
  }  // end switch (state)
  if(reblMenu.isCancelled()){
    state = 0;
    timeSetTime = 0;
    return true;
  }
  return false;
}

boolean showTime() {
  displayTime(now());  // display the running time
  if(reblMenu.isCancelled()){
    return true;
  }
  return displayDelay(10);  // do it for ten seconds
}

Error Messages from IDE 1.6.13:

REBL_UI_Example:19: error: 'fun1' was not declared in this scope

     "display", fun1   }

                ^

REBL_UI_Example:22: error: 'pressToExit' was not declared in this scope

     "press", pressToExit   }

              ^

REBL_UI_Example:25: error: 'pickNumber' was not declared in this scope

     "enter number", pickNumber   }

                     ^

REBL_UI_Example:28: error: 'fourLetterWord' was not declared in this scope

     "enter string", fourLetterWord   }

                     ^

REBL_UI_Example:31: error: 'enterTime' was not declared in this scope

     "set time", enterTime   }

                 ^

REBL_UI_Example:34: error: 'showTime' was not declared in this scope

     "show time", showTime   }

                  ^

C:\Users\Shawn\AppData\Local\Temp\arduino_modified_sketch_71526\REBL_UI_Example.ino: In function 'boolean enterTime()':

REBL_UI_Example:163: error: 'now' was not declared in this scope

       timeSetTime = now();

                         ^

REBL_UI_Example:171: error: 'setTime' was not declared in this scope

         setTime(timeSetTime);

                            ^

REBL_UI_Example:177: error: 'now' was not declared in this scope

       displayTime(now());

                       ^

C:\Users\Shawn\AppData\Local\Temp\arduino_modified_sketch_71526\REBL_UI_Example.ino: In function 'boolean showTime()':

REBL_UI_Example:194: error: 'now' was not declared in this scope

   displayTime(now());  // display the running time

                   ^

exit status 1
'fun1' was not declared in this scope

Probably prototype trouble. Try moving things around…

#include "REBL_UI.h"
#include <LiquidCrystal_SPI_8Bit.h>
#include <Time.h>

#define ENCODER_INTERRUPT_PIN 2
#define ENCODER_B_PIN 4
#define BUTTON_PIN 8
#define LCD_ENABLE_PIN A1
#define LCD_RS_PIN A3
#define HEART_BEAT_PIN A5
#define LCD_BLUE A0
#define LCD_GREEN A2
#define LCD_RED A4

boolean fun1() {
  displayLineLeft(0, F("Display This"));
  displayLineLeft(1, F("   ")); // to clear the line
  return displayDelay(3);
}

boolean pressToExit() {
  displayLineLeft(0, F("Press Button"));
  displayLineLeft(1, F("to Exit"));
  if(!isButtonOn()) {
    buttonOn();
  }
  else if(checkButton()) {
    buttonOff();
    return true;
  }
  return false;
}

boolean pickNumber() {
  static int state = 0;
  static int val = 0;

  switch (state) {
  case 0:
    {
      val = 0;
      state++;
    }
  case 1:
    {
      if (enterNumber(val, F("Enter Number"), 0, 50, 1)) {
        state++;
      }
      break;
    }
  case 2:
    {
      if (displayDelay(3)) {
        state = 0;
        return true;
      }
      displayLineLeft(0, "You Entered:");
      char buf[6];
      sprintf_P(buf, PSTR("%d"), val);
      displayLineLeft(1, buf);
      break;
    }
  }  // end switch (state)
  if(reblMenu.isCancelled()){
    state = 0;
    val = 0;
    return true;
  }
  return false;
}

boolean fourLetterWord() {
  static char theStr[5] = "four";
  static int state = 0;

  switch (state) {

  case 0:
    {  // enter the string
      if (enterString(theStr, 4)) {
        state++;
        break;
      }
      theStr[4] = 0;  // just in case.
      displayLineLeft(0, F("4 Letter Word"));
      displayLineLeft(1, theStr);
      break;
    }

  case 1:
    {   // display the entered string
      displayLineLeft(0, F("You Entered"));
      displayLineLeft(1, theStr);
      if(displayDelay(3)) {
        state = 0;
        encoderOff();
        buttonOff();
        return true;
      }
      break;
    }
  }		//  end switch (state)
  if(reblMenu.isCancelled()){
    state = 0;
    return true;
  }
  return false;
}

boolean enterTime() {
  static time_t timeSetTime = 0;
  static int state = 0;

  switch (state) {

  case 0:
    {  // turn things on and setup variables
      timeSetTime = now();
      state++;
    }
    /* no break */
  case 1:
    {   // input the time
      if (inputTime(timeSetTime)) {
        state++;
        setTime(timeSetTime);
      }
      break;
    }
  case 2:
    {   // display the running time for 10 seconds
      displayTime(now());
      if (displayDelay(10)) {
        state = 0;
        return true;
      }
      break;
    }
  }  // end switch (state)
  if(reblMenu.isCancelled()){
    state = 0;
    timeSetTime = 0;
    return true;
  }
  return false;
}

boolean showTime() {
  displayTime(now());  // display the running time
  if(reblMenu.isCancelled()){
    return true;
  }
  return displayDelay(10);  // do it for ten seconds
}

MenuItem PROGMEM menuItems[] = {
  {
    "display", fun1   }
  ,
  {
    "press", pressToExit   }
  ,
  {
    "enter number", pickNumber   }
  ,
  {
    "enter string", fourLetterWord   }
  ,
  {
    "set time", enterTime   }
  ,
  {
    "show time", showTime   }
};

MenuList menuList(menuItems, menuListSize(menuItems));

void setup() {
  initLCD(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_RED, LCD_GREEN, LCD_BLUE);
  initInterface(BUTTON_PIN, ENCODER_INTERRUPT_PIN, ENCODER_B_PIN);
  reblMenu.setCurrentMenu(&menuList);
}

void loop() {
  pollButton();
  static unsigned long preMil = millis();
  unsigned long curMil = millis();
  if (curMil - preMil >= DISPLAY_DELAY) {
    preMil = curMil;
    reblMenu.doMenu();
    doDisplay();
  }

}

Thanks, CB, that helped but now is referring to ‘now’ something not being declared, and I cannot find an instance where it would be. I assume that is something out of the Time library being it is in the time functions.
I’ve downloaded A Time library, but have no clue if it’s correct or what this code was based on.

Maybe Delta_G will answer.

The compiler is including...

  Arduino\hardware\tools\avr\avr\include\time.h

...instead of...

  Sketch\libraries\Time\Time.h

My first impression is that "Time.h" is a very poor choice for the filename. That obviously has the potential to be a problem under Windows. And, is currently a problem for you and I.

I suggest updating the IDE and the library to the latest version. Hopefully the problem has already been resolved.

[quote author=Coding Badly link=msg=3432719 date=1506891249] The compiler is including...

  Arduino\hardware\tools\avr\avr\include\time.h

...instead of...

  Sketch\libraries\Time\Time.h

My first impression is that "Time.h" is a very poor choice for the filename. That obviously has the potential to be a problem under Windows. And, is currently a problem for you and I.

I suggest updating the IDE and the library to the latest version. Hopefully the problem has already been resolved.

[/quote]

Yeah there's been a change to the libraries since I wrote that. I think there has been a change to how you are supposed to include Time. I think you're supposed to use TimeLib.h or something like that.

OP, once you get a compile I'd really appreciate a pull request if you know how to do one so I can get the code on the github up to date. If not, just post it here and I'll do it.

Ok, I will see if I can find the TimeLib library and let you know Delta-G. I think I saw mention to that file somewhere else too.
I’ll try a pull as well if I get it going, either way I will repost here for future reference anyhow.

Appreciate it. I haven't dealt with the Time library since whatever change happened so I'm not sure if it is a different thing to download or if it is just a different way to include it. Hopefully someone who knows will pop in and let us know.

Well, that has been quite a journey, but fruitful I believe!
The TimeLib.h is part of Paul Stoffregens’ Time libraries hosted at:

Changing the include to
#include <TimeLib.h>
Was sufficient to resolve the bad calls to the time function ‘now’ among other time-related errors.

The LCD errors from the inclusion of LiquidCrystal_SPI_8Bit.h are because this library is outdated and has apparently deprecated the LCD init calls.

So looking around for an updated SPI / 74595 shift register library, our old friend Francisco Malpartida bails us out with the New_LiquidCrystal library set.
Per his WIKI at https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home the 595 shift register is supported under the LiquidCrystal_SR.h library.
We do lose the RGB backlight controls but can replicate those with normal digital pins I’d think.

I am currently working on resolving the color and backlight calls in the REBL_UI display h and cpp files. I will have to fire up a board to test with also. I will keep you updated.

LiquidCrystal_SPI_8Bit.h should stand on its own. I don't see why it wouldn't work. Now you're going to make me go dig.

Yeah, my aquarium doser code still compiles fine using REBL. I think I'm on 1.6.5r5 but I'm having some trouble finding where I set that up so I'm not 100% sure that's the version I'm compiling with. I have so many and I can't find the setting in Eclipse.

Yes, 1.6.5r5. IIRC That's what I was on last time I messed with it. I just deleted every version I have (actually moved to a temp folder) and I still get a compile so that must be the version Eclipse is using.

Ok, I’ll get a standalone and give this revamp a go.

I guess the one caveat with me is that I don't often use the Arduino IDE to compile anything. I'm usually writing through Eclipse. So I don't know if there are compile option differences or some difference in the way the Arduino IDE treats the headers that might cause some issue.

Well, I think I heard gears grinding in my computer, but the following code compiled properly using 1.6.5r5.

it took a bit, but it worked.

#include "REBL_UI.h"
#include <LiquidCrystal_SPI_8Bit.h>
#include <TimeLib.h>

#define ENCODER_INTERRUPT_PIN 2
#define ENCODER_B_PIN 4
#define BUTTON_PIN 8
#define LCD_ENABLE_PIN A1
#define LCD_RS_PIN A3
#define HEART_BEAT_PIN A5
#define LCD_BLUE A0
#define LCD_GREEN A2
#define LCD_RED A4

boolean fun1() {
  displayLineLeft(0, F("Display This"));
  displayLineLeft(1, F("   ")); // to clear the line
  return displayDelay(3);
}

boolean pressToExit() {
  displayLineLeft(0, F("Press Button"));
  displayLineLeft(1, F("to Exit"));
  if(!isButtonOn()) {
    buttonOn();
  }
  else if(checkButton()) {
    buttonOff();
    return true;
  }
  return false;
}

boolean pickNumber() {
  static int state = 0;
  static int val = 0;

  switch (state) {
  case 0:
    {
      val = 0;
      state++;
    }
  case 1:
    {
      if (enterNumber(val, F("Enter Number"), 0, 50, 1)) {
        state++;
      }
      break;
    }
  case 2:
    {
      if (displayDelay(3)) {
        state = 0;
        return true;
      }
      displayLineLeft(0, "You Entered:");
      char buf[6];
      sprintf_P(buf, PSTR("%d"), val);
      displayLineLeft(1, buf);
      break;
    }
  }  // end switch (state)
  if(reblMenu.isCancelled()){
    state = 0;
    val = 0;
    return true;
  }
  return false;
}

boolean fourLetterWord() {
  static char theStr[5] = "four";
  static int state = 0;

  switch (state) {

  case 0:
    {  // enter the string
      if (enterString(theStr, 4)) {
        state++;
        break;
      }
      theStr[4] = 0;  // just in case.
      displayLineLeft(0, F("4 Letter Word"));
      displayLineLeft(1, theStr);
      break;
    }

  case 1:
    {   // display the entered string
      displayLineLeft(0, F("You Entered"));
      displayLineLeft(1, theStr);
      if(displayDelay(3)) {
        state = 0;
        encoderOff();
        buttonOff();
        return true;
      }
      break;
    }
  }    //  end switch (state)
  if(reblMenu.isCancelled()){
    state = 0;
    return true;
  }
  return false;
}

boolean enterTime() {
  static time_t timeSetTime = 0;
  static int state = 0;

  switch (state) {

  case 0:
    {  // turn things on and setup variables
      timeSetTime = now();
      state++;
    }
    /* no break */
  case 1:
    {   // input the time
      if (inputTime(timeSetTime)) {
        state++;
        setTime(timeSetTime);
      }
      break;
    }
  case 2:
    {   // display the running time for 10 seconds
      displayTime(now());
      if (displayDelay(10)) {
        state = 0;
        return true;
      }
      break;
    }
  }  // end switch (state)
  if(reblMenu.isCancelled()){
    state = 0;
    timeSetTime = 0;
    return true;
  }
  return false;
}

boolean showTime() {
  displayTime(now());  // display the running time
  if(reblMenu.isCancelled()){
    return true;
  }
  return displayDelay(10);  // do it for ten seconds
}

MenuItem PROGMEM menuItems[] = {
  {
    "display", fun1   }
  ,
  {
    "press", pressToExit   }
  ,
  {
    "enter number", pickNumber   }
  ,
  {
    "enter string", fourLetterWord   }
  ,
  {
    "set time", enterTime   }
  ,
  {
    "show time", showTime   }
};

MenuList menuList(menuItems, menuListSize(menuItems));

void setup() {
  initLCD(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_RED, LCD_GREEN, LCD_BLUE);
  initInterface(BUTTON_PIN, ENCODER_INTERRUPT_PIN, ENCODER_B_PIN);
  reblMenu.setCurrentMenu(&menuList);
}

void loop() {
  pollButton();
  static unsigned long preMil = millis();
  unsigned long curMil = millis();
  if (curMil - preMil >= DISPLAY_DELAY) {
    preMil = curMil;
    reblMenu.doMenu();
    doDisplay();
  }

}

Awesome! Glad that’s done and you can work. If I find a bit of time in front of my machine anytime soon I’ll look at getting it going with the more recent versions. But I wouldn’t hold my breath. :slight_smile:

That was with your original headers on the git page, along with the TimeLib addition and the old 8 bit SPI LCD library. I doubt much updating would need to be done, some focus on documentation might be in order, devil in the details and all.

Now to figure out how to get it to play nice on a PCF8574 I2C backpack. :D

Thanks, Delta, I'll give it a try and see if it fits my needs. All this hard work to give my customers something a bit fancier than a group of pots and leds. lol, single rotary FTW.

I'd be willing to help as I can, but I feel like a true newbie sometimes with this coding stuff. Hardware is a breeze, I can keep the magic smoke in usually. This software though, phew!

kd6oji: some focus on documentation might be in order

Ain't that always the case? You write code because you need it. And once it is done you get lazy and don't want to do the docs.

now how did you know what I do? oh wait.. lol