LCD 16x2 I2C Menu Struktur library with Rotary Encoder?

Dear Pro Users,

since I have startet studing (instead of working) I got a bit time on my hand, then my girlfriend bought a little aquarium and so I though "let's automate it!" :slight_smile: I have worked with industriel PLC Controller, but an Arduino LCD Menu System is kind off over my head.

The last days I googled a lot to this thema, what I found out is that there is a couple library I could use. User olikraus, writer from m2tklib, has made a list. See hear -->LiberyList

I first intendet to "Copy" the Marlin LCD Menu for 3D Printers with a rotary encoder and a button because it's so simple to handle, but I was not able to extraxt it from all the code. So I though I have to use one of the library avalible. But wich on?

I tried a bit with m2tklib "Lib Elements"and a example I found, but yeah it was not going in the direction I'd like to.

It would be awesome if you guys could help me find the best lib for my struktur, or at least give me a idea how I should change it to make it the most simple way.

Thanks!! :slight_smile:

Don't take to code to serious, i tried it the first time yesterday night :slight_smile:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "M2tk.h"
#include "utility/m2ghnlc.h"

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//=================================================
// Forward declaration of the toplevel element
M2_EXTERN_ALIGN(top_menu);
//=================================================

uint8_t TargetTemp = 0;
uint8_t SetpointTemp = 0;
uint8_t AlarmTemp = 0;
uint8_t PID_ManAuto  = 0;
uint8_t Xd =20;
uint8_t Xi = 0;
uint8_t Xs = 0;
uint8_t LightOnOff = 0;
uint8_t LightMaxY = 0;
uint8_t LightMinY = 0;
uint8_t Fertilizer = 0;

//Default screen
M2_LABEL(el_9, NULL, "Temp");
M2_LABEL(el_10, NULL, "Y Light:");
M2_LABEL(el_l1, NULL, "Set.Temp:");
M2_U8NUM(el_u1, "c2", 0, 99, &SetpointTemp);
M2_LABEL(el_l2, NULL, "Xd");
M2_U8NUM(el_u2, "c2", 0, 99, &TargetTemp);


M2_LIST(list) = { &el_9, &el_10 ,&el_l1, &el_u1, &el_l2, &el_u2 };
M2_GRIDLIST(el_gridlist, "c2", list);
M2_ALIGN(top_menu, "-0|1W64H64", &el_gridlist);

// m2 object and constructor
// Note: Use the "m2_eh_4bd" handler, which fits better to the "m2_es_arduino_rotary_encoder"
M2tk m2(&top_menu, m2_es_arduino_rotary_encoder, m2_eh_4bd, m2_gh_nlc);

//=================================================
// Arduino Setup & Loop

void setup() {
  m2_SetNewLiquidCrystal(&lcd, 16, 2);

  // define button for the select message
  m2.setPin(M2_KEY_SELECT, 2);

  // The incremental rotary encoder is conected to these two pins
  m2.setPin(M2_KEY_ROT_ENC_A, 3);
  m2.setPin(M2_KEY_ROT_ENC_B, 4);
}

void loop() {
  m2.checkKey();
 m2.checkKey();
  if ( m2.handleKey() )
    m2.draw();
  m2.checkKey();
   m2.checkKey();
    m2.checkKey();
}

ProjectMenuStruktur.pdf (125 KB)

ProjectMenuStrukturSetupPicture.pdf (454 KB)

Hi,

here are some links which might help you:
link1
link2

Hey,

thank you, I will have a look at that Post's. Haven't seen them before!

Meanwhile I was continueing with m2tklib. My question is: Is it right that when you use STRLIST, 2LMENU or X2LMENU that your able to scroll thru the menu but can't change value. When you want to input value you have to use a Sub with M2_LABEL and U8NUM and ROOT to go back?

Or is it possible to have a list just with LABEL and U8NUM? I tried that actuelle, but it only shows the first an the last enty an screen.

Thanks!

Sorry, but I never used this library, so I can't help with that.
Some months ago I tried to understand the library as I was looking for a solution for my rotary menu but at that time (still today) this library was too much informatic style for me.

As I am only a diy programmer I prefer self explaining code with variables which can "speak" to me close to my normal language. I admire the work of Oli Kraus as his lib is aiming to serve for quite a broad range of displays, but my approach, much simpler and only dedicated to my given environment, was quite easier to achieve.

Hey,

yeah sometimes it's easier and faster to write own code than try understand someone elses code. But the good thing about the different LCD Menu libs is that you get a pretty good idea how it work's.

I guess the normal Arduino User (like me) grabs here and there a bit code and put's it together to a more or less working Project. I intendet to do so :wink:

I had a quick look into your code postet in the other Threads, also in this one SimpleRotaryEncoderTutorial

I like the CocktailMaster idea :smiley:

I looks like my biggest problem is that I'd like to change values in the Menu. Without that it would be less hard. So I have to digg truh more code. Maybe I will have a try with "phi_prompt user interface library".

Currently I am a bit tight in time.
I do have a menu working which is able to adjust values in submenus.

Will come back to you tomorrow when I have more time (hopefully).

I have found my favorit lib for I2C LCD with Rotary Encoder.

Have a look at ArduinoMenu on GitHub. It's simple, takes not to much memory and most impotent it's easy to change values direct in the menu. Also it uses the ClickEncoder lib.

But the best thing about it is that the Autor is actually doing support on GitHub. It's great!

I attached my first working sketch. If you want use it you have to copy the additional ClickEncoderStream.h file to the lib folder or copy the whole lib. It's all in there.

@neu-rah on GitHub: Thank's Dude for creating the Menu lib!

@christophepersoz on GitHub: Thank's for implementing the ClickEncoderStream.h lib!

ArduinoMenu_I2C_LCD_16x2_RotaryEncoder.zip (308 KB)

Actually this is quite nice; will give it a try and if it eats less resources than my today's implementation of a LCD menu - that would give me a bit room for implementing new features in my project.

Thanks for sharing this information - you deserve a Karma point :slight_smile: