Go Down

Topic: LCD menu with encoder (Read 1 time) previous topic - next topic

I thought you saw it in the other post. Here it is again:
Code: [Select]
Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

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

    "display", fun1   }

               ^

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

    "press", pressToExit   }

             ^

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

    "enter number", pickNumber   }

                    ^

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

    "enter string", fourLetterWord   }

                    ^

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

    "set time", enterTime   }

                ^

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

    "show time", showTime   }

                 ^

C:\Users\uraynara\Documents\Arduino\REBL_UI_Example\REBL_UI_Example.ino: In function 'boolean enterTime()':

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

      timeSetTime = now();

                        ^

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

        setTime(timeSetTime);

                           ^

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

      displayTime(now());

                      ^

C:\Users\uraynara\Documents\Arduino\REBL_UI_Example\REBL_UI_Example.ino: In function 'boolean showTime()':

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

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

                  ^

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

Delta_G

Ok thanks.  I'll look at it this weekend when I'm home. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

[Wish I could give thumbs-up like on AllAboutCircuits]


Why did I probably needed to know C++ stuff?
Isn't it just changing/having the correct pinout, and changing the menu list to my own functions?

#18
Aug 10, 2018, 08:48 pm Last Edit: Aug 10, 2018, 08:50 pm by adamaero
I feel like it's something to do with the Time library. I left one function (fun1), and this is the error message:

Code: [Select]
Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\REBL_Functions.cpp: In function 'boolean inputTime(time_t&)':

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\REBL_Functions.cpp:81:9: error: 'tmElements_t' does not name a type

  static tmElements_t tmElem;

         ^

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\REBL_Functions.cpp:82:17: error: 'tmElem' was not declared in this scope

  breakTime(var, tmElem);

                 ^

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\REBL_Functions.cpp:82:23: error: 'breakTime' was not declared in this scope

  breakTime(var, tmElem);

                       ^

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\REBL_Functions.cpp:157:23: error: 'makeTime' was not declared in this scope

  var = makeTime(tmElem);

                       ^

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\REBL_Functions.cpp: In function 'void displayTime(time_t)':

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\REBL_Functions.cpp:175:2: error: 'tmElements_t' was not declared in this scope

  tmElements_t tmElem;

  ^

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\REBL_Functions.cpp:176:19: error: 'tmElem' was not declared in this scope

  breakTime(aTime, tmElem);

                   ^

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\REBL_Functions.cpp:176:25: error: 'breakTime' was not declared in this scope

  breakTime(aTime, tmElem);

                         ^

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


Also, attached is the (just fun1) program.

Delta_G

Another contributor sent me a pull request he says fixes it.  You can either download it again or go through and find the three files that include Time.h and change them to include TimeLib.h instead.

This was written with an older version of the IDE and it appears as if the name of the Time library has changed.

Let me know if that works.  I am not where I can try to compile it.   
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Delta_G

[Wish I could give thumbs-up like on AllAboutCircuits]


Why did I probably needed to know C++ stuff?
Isn't it just changing/having the correct pinout, and changing the menu list to my own functions?
One of the encoder pins has to stay where it is.  It's using a hardware interrupt.  The other pins you can change if you want. 

Yes, all you really gotta do is write your own functions.  The key is that they are returning boolean to indicate if they want to be called again or not.  And make sure they are NOT blocking at all. 

There are a bunch of utility functions, like inputting numbers and words and stuff in either that library or the doser code. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

#21
Aug 11, 2018, 08:01 pm Last Edit: Aug 11, 2018, 08:06 pm by adamaero
So I tried to do this:

in REBLDisplay.cpp

change to this...
void initLCD(uint8_t aRsPin, uint8_t aEnablePin, uint8_t aD1, uint8_t aD2, uint8_t aD3, uint8_t aD4) {

#ifdef USING_SERIAL
 Serial.begin(19200);
#else
 LCD = new LiquidCrystal(aRsPin, aEnablePin, aD1, aD2, aD3, aD4);
 LCD->begin(NUM_LCD_COLS, NUM_LCD_ROWS);
 LCD->noCursor();
 LCD->clear();
 //setColor(BLUE);

#endif
}

in REBLDisplay.h
Change to this
void initLCD(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);

In your sketch add these
#define LCD_D1 4
#define LCD_D2 5
#define LCD_D3 6
#define LCD_D4 7

and change to this.
initLCD(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_D1, LCD_D2, LCD_D3, LCD_D4);


Pretty sure that was all i used to make it work :)

Oh and I changed the include to use
#include <LiquidCrystal.h>
instead of the SPI one.


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

#define ENCODER_INTERRUPT_PIN 2 // CLK: Must keep pin 2.
#define ENCODER_B_PIN A0        // DT
#define BUTTON_PIN A1           // SW

#define LCD_ENABLE_PIN 13
#define LCD_RS_PIN 12
//#define HEART_BEAT_PIN A5
//#define LCD_BLUE A0
//#define LCD_GREEN A2
//#define LCD_RED A4

#define LCD_D1 4    // New ↓
#define LCD_D2 5
#define LCD_D3 6
#define LCD_D4 7
// const int contrast = 20;    // min. PWM value

//forward declaration for the functions
boolean fun1();
boolean pressToExit();
boolean pickNumber();
boolean fourLetterWord();
boolean enterTime();
boolean showTime();


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

MenuList menuList(menuItems, menuListSize(menuItems));

//LiquidCrystal lcd( 12, 13, 5, 4, 3, 7); // Arduino pins. Creates object.
   // LCD:GND,5V(RS=2 en=3 11 12 13 14) 16=GND

void setup() {
initLCD(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_D1, LCD_D2, LCD_D3, LCD_D4); // New
initInterface(BUTTON_PIN, ENCODER_INTERRUPT_PIN, ENCODER_B_PIN);
reblMenu.setCurrentMenu(&menuList);
// LCD code:
//  pinMode(7,HIGH);  // LCD pin 15: backlight (anode)
//  pinMode(11,OUTPUT);
//  analogWrite(11,700);
//  analogWrite(6,contrast); // PWM~ pins: 3,5,(6),9,10,11


}

Attached is this edited version (where I attempted to swap the LCD libraries), but this error:
Code: [Select]
Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\uraynara\Documents\Arduino\REBL_UI_Example\REBL_UI_Example.ino: In function 'void setup()':

REBL_UI_Example:56: error: too many arguments to function 'void initLCD(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)'

   initLCD(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_D1, LCD_D2, LCD_D3, LCD_D4); // New

                                                                     ^

In file included from C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master/REBL_UI.h:14:0,

                 from C:\Users\uraynara\Documents\Arduino\REBL_UI_Example\REBL_UI_Example.ino:1:

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master/REBLDisplay.h:13:6: note: declared here

 void initLCD(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);

      ^

exit status 1
too many arguments to function 'void initLCD(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 

I haven't uploaded it yet, but I have a 4x20 LCD. Pinout to Arduino Mega + rotary encoder attached.


Delta_G

To change the LCD you'll have to make changes in REBLDisplay.h and REBLDisplay.cpp as well. 

I wish there was a base class that all the different LCD libraries could inherit, then I could just let you pass a pointer to one of those and all would be good.  Unfortunately there isn't. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

#23
Aug 12, 2018, 10:56 pm Last Edit: Aug 12, 2018, 11:56 pm by adamaero
I made a change (first attached picture shows) to REBLDisplay.h too now.

Not sure what to do for that last part near the end (where the line is pointed to in red).

Wondering if there needs to be a change in the second, middle, attachment?

Error message

Code: [Select]
Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master/REBL_UI.h:14:0,

                 from C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\Example\REBL_UI_Example\REBL_UI_Example.ino:1:

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master/REBLDisplay.h:13:8: error: expected constructor, destructor, or type conversion before '(' token

 initLCD(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_D1, LCD_D2, LCD_D3, LCD_D4); // New

        ^

C:\Users\uraynara\Documents\Arduino\libraries\REBL_UI-master\Example\REBL_UI_Example\REBL_UI_Example.ino: In function 'void setup()':

REBL_UI_Example:53: error: 'initLCD' was not declared in this scope

   initLCD(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_D1, LCD_D2, LCD_D3, LCD_D4); // New

                                                                     ^

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

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

#25
Aug 14, 2018, 12:01 am Last Edit: Aug 14, 2018, 12:02 am by adamaero
I posted the same question here:
stackoverflow.com/questions/51828915/how-to-retrofit-an-8-bit-lcd-library-menu-rotary-encoder-for-a-regular-lcd

Tomorrow I will give up and resort to using a bunch of toggle switches instead.

Delta_G

You posted pictures of part of some code and an error message.  That's a standard error message that usually means you have executable code outside of a function.  But nobody can be sure without seeing the code that produced that message.  You posted pictures of code instead of code.  Do you really not understand how totally useless a screenshot of code is?
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

PaulS

Line 13, the line that is generating the error is NOT in a function. It MUST be.
The art of getting good answers lies in asking good questions.

#28
Aug 14, 2018, 03:26 pm Last Edit: Aug 14, 2018, 03:29 pm by adamaero
@Rebel_G, they are the same files I already posted. The images of those files are supplementary. (One is actually an image of the same file attached to the same post.)

#29
Aug 14, 2018, 03:32 pm Last Edit: Aug 14, 2018, 03:34 pm by adamaero
Line 13, the line that is generating the error is NOT in a function. It MUST be.
In the REBLDisplay.h file, how do I fix it? It's not much different from the original (see attached comparison of the code).

Ohh, I think I forgot "void".........

Go Up