Very basic menu.

BenI2C: I think the cursor appears ONLYy if editor is activated.

That's correct: The cursor appear ONLY if the item editor is activated.

And in my demo the item editor can only be activated if the menu item is of type "D" (date editor) or "T" (time editor).

BenI2C: I cant activate the editor :confused: .

Did you do any changes to the demo code that I provided?

If so: Which changes?

The only i have changed:

LiquidCrystal lcd(12,11, 10, 9,8, 7); // initialization for LCD Keypad Shield
  #define LCDWIDTH 16
  #define ENCODERPIN_A 3
  #define ENCODERPIN_B 2
  #define BUTTONPIN 4

BenI2C: The only i have changed:

LiquidCrystal lcd(12,11, 10, 9,8, 7); // initialization for LCD Keypad Shield
  #define LCDWIDTH 16
  #define ENCODERPIN_A 3
  #define ENCODERPIN_B 2
  #define BUTTONPIN 4

So you are using the default LiquidCrystal library, too. So the results should also be the same, too.

I just looked up the Arduino release notes for v.1.6.5 and found that:

ARDUINO 1.6.5 - 2015.06.15 ... [libraries] * LiquidCrystal fixes. Thanks @newbie15

Possibly that were "bad fixes" done. Do you possibly also have an older Arduino version you can test? The code I posted was tested with IDE v1.0.5 and v.1.6.4, so I think, everything in between should be OK.

But after I see this weird "LiquidCrystal fixes. Thanks @newbie15" in the release notes for v1.6.5, I possibly have to install and check my code and hardware with v.1.6.5, too.

I'll have to install v1.6.5 and then search and install some LCD and encoder to an Arduino board, as the hardware is currently not ready here.

So stay tuned - may take a day or two to test it with v1.6.5 and the "fixed" Liquidcrystal library in that version.

Thanks so far. Can i enter/test the editor mode whithout a the cursor ?

jurs: Oh, miracle! At least one person has actually loaded AND tested the rotary encoder menu code I posted

I have loaded both codes you posted and work well, I've did some testing but found I selected to set date but nothing happened scrolled through got exit which worked. I used the I2C LCD library. I will see about getting it loaded back up over the next couple of days and start playing again. I did read it quite a lot to get a better understanding how your codes work and managed to add a couple of extra menus to your first sample

I should have replied earlier but been playing with another project will post results soon

Great share Jurs and I've learnt a lot from your sample

Steve

The same problem ?

I'm not sure if it was would have to reload code and see what happens and record it so I can report here has I can't quite remember the problem

BenI2C:
Thanks so far.
Can i enter/test the editor mode whithout a the cursor ?

Editing values without a visible cursor doesn’t make much sense.
So you’d need a visible cursor to mark the digit that is actually editable.

Do you have an RTC connected to the I2C bus?
Tested with an RTC test sketch and fully working?
The sketch is intended for an DS1307 or DS3231 RTC.

If you have no RTC, you’d better deactivate the RTC option.
Replace line defined option 1:

#define RTCOPTION 1  // 1= use RTC (DS1307 or DS3231 possible), 0= no RTC

with line defined option 0:

#define RTCOPTION 0  // 1= use RTC (DS1307 or DS3231 possible), 0= no RTC

In that case the sketch doesn’t try to use any RTC in the sketch.

I’m not able to create a test environment today. No hardware ready for testing.

The 1602 LCDs also offer two types of cursors: Underline cursor (non blinking) and block cursor (blinking).

My sketch currently uses the underline cursor only. But it should also be possible to use the blinking block cursor to indicate the digit that is currently active for editing. But that would require a small change in the code.

Perhaps tomorrow I can do some tests with hardware, the new Arduino 1.6.5 IDE and the menu code.

Stay tuned!

Yes, i did set the RTCOPTION to 0. I am waiting :)

BenI2C:
Yes, i did set the RTCOPTION to 0.
I am waiting :slight_smile:

I’ve just checked with my original download file that was attached to reply #15
and I must admit: You are right, this programming example is NOT fully working with value editing.

Somehow I must have managed to upload a wrong file. Sorrry, I don’t know how it could happen.

I include new rotary menu code (tested with Arduino 1.0.5, 1.6.4 and 1.6.5r5) with this posting.

To get things working for you easily, I’ve included your changed LCD and button settings as USEROPTION 2.

So if you like to test without RTC, set:

#define RTCOPTION 0  // 1= use RTC (DS1307 or DS3231 possible), 0= no RTC

And to create code for your LCD and button settings, set:

#define USEROPTION 2

With this code, the date an time editors should activate with a visible “underline” cursor at the position that is editable.

When in edit mode rotate cursor right to abort edit mode (value not saved)
When in edit mode to SAVE value, rotate to “OK” and press button

Is that code working?

menuRotary.zip (6.29 KB)

YES YES it's working! so far. Now i will look how the menu structure. Thanks

There is a little mistake in your new code :
line 57

#include <LiquidCrystal.h>

must before line 55.

A possible menu for doing settings, adapted for your application would be perhaps (not implemented yet, but could be done):

menuitem_t menuitems[]={
  {10, '2', ' ', (char*)"Set Voltage-1"}, // 2-digit voltage (V?) editing
  {11, '3', ' ', (char*)"Set Current-1"}, // 3-digit current (mA?) editing
  {20, '2', ' ', (char*)"Set Voltage-2"},
  {21, '3', ' ', (char*)"Set Current-2"},
  {30, '2', ' ', (char*)"Set Voltage-3"},
  {31, '3', ' ', (char*)"Set Current-3"},
  {40, '2', ' ', (char*)"Set Voltage-4"},
  {41, '3', ' ', (char*)"Set Current-4"},
  {50, '2', ' ', (char*)"Set Voltage-5"},
  {51, '3', ' ', (char*)"Set Current-5"},
  {88, 'B', ' ', (char*)"Emergency OFF: false"}, // boolean option setting (true/false)
  {99, ' ', ' ', (char*)"Exit"},        // exit menu option
};

That would require to add some new editors to the menu: - a 2-digit editor for volts - a 3-digit editor for milliamperes - a boolean value editor

Edited values are to be saved to EEPROM, so that the current settings are to be loaded after a power failure from EEPROM, before the program starts executing again, correct?

Such like that? Or can you better explain the details about what you want? [/quote]

Almost such like that. :) The voltage 3 digit like: 21.7 V 0-35.0 V The current also 3 digit like: 1.25 A 0-4.00 A

Is that possible ? Can / will you help me with that (the basic) ? :(

BenI2C:
There is a little mistake in your new code :
line 57

#include <LiquidCrystal.h>

must before line 55.

Yes, indeed. Either before the #if section, or within the branch of each USEROPTION like

#elif (USEROPTION==2)
  #include <LiquidCrystal.h>
  LiquidCrystal lcd(12,11, 10, 9,8, 7); // initialization for LCD Keypad Shield
  ...

I’d prefer to include the library within the USEROPTION, that way it would be easy to include and provide different “alternative” LiquidCrystal libraries in one source codes. Some programmers prefer the original LiquidCrystal library as provided by Arduino. Others may prefer an I2C-LCD and like it more to include an alternative LiquidCrystal_I2C library in some cases.

BenI2C:
Almost such like that. :slight_smile:
The voltage 3 digit like: 21.7 V 0-35.0 V
The current also 3 digit like: 1.25 A 0-4.00 A

Is that possible ?

Many things are possible. So from what you tell you rather need

  • editors for floating point numbers and
  • some possibility for range validation (that the user can only enter values in the valid range)

I will have to think a bit about it.

Most likely, the code needs some heavy rewrite to become a bit more structured when adding different new features, like editing whole numbers, float numbers with different digits, and range check validation.

BenI2C:
Can / will you help me with that (the basic) ? :frowning:

That should be possible. If I find some time the next days, I’ll give it a try to do some extended version with some features added. But as I told, the data structures and the code possibly need a heavy rewrite when adding features.

I have tested your last code tonight, and charmed of the really smooth control. So i wait till you have some extended version. I stay tuned :)

I can also confirm that it now works flawlessly and smooth, I tested it with ds3221, now it's easier to set the time rather than hooking it up to pc to reset. It would be a nice option to be able to adjust other stuff and a great learning curve I love reading other people's code this enables me to learn and progress more and get better at understanding and making tidier code. Thanks Jurs for sharing and taking the time and effort to help all of us

@jurs

That should be possible. If I find some time the next days, I'll give it a try to do some extended version with some features added. But as I told, the data structures and the code possibly need a heavy rewrite when adding features.

Is there some progress ? Can i help maybe ?

hi,

i was searching and found it here i think… :slight_smile: :slight_smile:

i was using this code and want to use the encoder make a volume bigger by rotating.

encoderButtonInput();  // read and update button input
  encoderRotaryInput();  // read and update rotary input
      
        if(encoder.rotaryResult!=1 && volume <100)
          volume+=1;
        if(encoder.rotaryResult!=0 && volume>0)
          volume-=1;
        
        if(volumeOld != volume)//update  u8x8 when got new volume
        {
             u8x8.setCursor(8,0);
             u8x8.print(volume);
             u8x8.print("ml ");
           
            volumeOld = volume; 
             
        }
        
        if(encoder.buttonResult==SHORTCLICK )
        {
            RunPump(volume);

but when i start the count goes to the roof…
mabe there is someone who can give me a hint?

edensan:
hi,

i was searching and found it here i think… :slight_smile: :slight_smile:

i was using this code and want to use the encoder make a volume bigger by rotating.

encoderButtonInput();  // read and update button input

encoderRotaryInput();  // read and update rotary input
     
        if(encoder.rotaryResult!=1 && volume <100)
          volume+=1;
        if(encoder.rotaryResult!=0 && volume>0)
          volume-=1;
       
        if(volumeOld != volume)//update  u8x8 when got new volume
        {
            u8x8.setCursor(8,0);
            u8x8.print(volume);
            u8x8.print("ml ");
         
            volumeOld = volume;
           
        }
       
        if(encoder.buttonResult==SHORTCLICK )
        {
            RunPump(volume);




but when i start the count goes to the roof..
mabe there is someone who can give me a hint?

Make your own thread. It’s bad etiquette to resurrect an old thread with a new problem, especially on the 3rd page.