Menu for Display

Thanks Oliver however great :slight_smile: !

so from my point of view i think that the best could be "Method 2" or "Method 3" if not understood bad the difference is that with the "Method 3" is possible run a procedure ?

with this method for example could i do a cycle for change the "linebuf" ? I will be update automatically on display ? or each time will be necessary press button for update it ?

another thing that I would like to ask you is that ... on my menu now for example when I entry into the menu for "turn on" or "turn off" off the devices I see a strange value example:

Actually Menu:

Dev: 85 State: 255
back ok zero

How should be:

Dev: 00 State: 0
back ok zero

when I press select button the value come back to 0 like should be and also the state after press select button come back to 0 like should be ...

for sure the variable are initialized to 0 before entry into the menu

Thanks 1000
Andrea

with this method for example could i do a cycle for change the "linebuf" ? I will be update automatically on display ? or each time will be necessary press button for update it ?

The content of linebuf will be displayed whenever you execute m2.draw(). Anything else is under your control. This means: If you update linebuf you should call m2.draw() to make your changes visiable.

Actually Menu:

Dev: 85 State: 255
back ok zero

M2tklib will display the value of the "connected" variable. Nothing else. Are you sure that there is no programming error, assigning 85 to the device value?

Oliver

Thanks for the information,
I've intercept the issues ... I've change the type of variable from uint8_t to byte ...
the logical part was ok, but probably there was a "memory overlapping" between variable ... is possible ?

Thanks I'll let you know about the next steps :slight_smile:

ps it's pleasure working with your library :slight_smile:

thanks
gnux

Ciao Oliver,
during the weekend, I've thought how to use ... so I'll try to use a mixed mode to put &null element to display for disable the menu and then enable the menu again ...

So, Id like to do is also ... so now i didn't have the exit button ... and for didn't wasting memory I was thing to this:

I want that when I'm inside my menu when I click on something the menu will go on the welcome screen ...
for do that I've thing to put a "Exit" voices into the menu is possible ? Is possible also do something without didn't a sub menu ? so for example to the voice exit when I click the select but will go directly to welcome screen ...

Thanks for the information :slight_smile:

warm regards,
gnux

Hi

This should work with the "HOME" button. This means, do not use the Exit button, but instead the HOME button (M2_KEY_HOME). Assign the "home" menu with setHome(). This also could be the &null element.

Oliver

Good Morning Oliver,
And for do that I need physically another button correct ? :slight_smile: so it's very complete your menu ! Many Congratulations ... !!! :slight_smile: So I promise to you that when I'll finish the project I'll send to you a gift :slight_smile: please send to me in private if you want without you I was completely lost ...

So the final things that I want do for the moment is that ... in attachment you can see a a combo menu ... I've take this simple example from a library ... one time that i will press ok I will store the value devices and the "Is" name (only the index) inside my array ... for example like this:

array[0][13] = idx;
array[0][0] = &u8num;

Then I would like retrieve this value inside another menù:
I would like that for example when I'm inside the menu device when I click on "Dev: 01" Will appear kitchen ...
In this way I can say what Im managing ...

Could be possible for you ? make sense ? :slight_smile:

Thanks again :slight_smile:
gnux

Schermata 2013-02-20 a 07.19.48.png

I think can I use
M2_LABELFN();
:slight_smile:

looking the tutorial seems fine :slight_smile:
correct ?

regards,
gnux

Hi

You do not need another button. Replace the one for the Exit with the Home Button: Exchange EXIT with HOME...

And yes, M2_LABELFN will do the job.
A one or two pictures of your device would be the best reward that i can imagine.

Oliver

hi Oliver,
i will add another button like home button because at the moment im using only next and select pin :slight_smile:

so now after a few times that i use the tutorial it's more clear it a very good library :slight_smile:

for is there a way for calculate how many variable can i use and in which part of memory are stored ? for example u8int ?
thanks 100000 :slight_smile:

Hi

You can calculate the amount of initially occupied RAM and ROM memory.
Use "avr-size" for this task. You need to locate and find the .elf file on your file system.

Also, have a look here: avr-libc: Memory Areas and Using malloc()
Variables are usually stored in .data or .bss area. This depends on there init value.

Oliver

Great Thanks you !

So, I did you this questions because this morning i was doing the final menu and one time that I've the third menu the has stop to work ... I've tried both in serial and on lcd ... removing this menu everything was working ok ... and my sketch is only 25000 I've avaiable again 8000 byte if i not wrong ... also taking another menu from an example is the same ...

do you have any suggest for fix it ?

thanks
gnux

for sure the code seems correct ... I didn't see any big changes between the other only I've used 2 Label function ... so in 4 hour that im working on that I've tried a lot's of thing change variable type from u8int to char ... but nothing to do ... Now I go for launch because Im completely fuse ...
thanks for help me,
gnux

Also I've looked inside the tutorial for pass value to the call back procedure for M2_LABELFN I but I didn't find a way :frowning: so could be more useful :slight_smile: below you can find the code ...
if i try to pass parameter I've back a issues with the conversion for sure i wrong to pass it ...

const char *label_what(m2_rom_void_p element)
{  

  switch (array[u8dev][13]) {
    case 0: 
         label = "Bathroom";
         break;
    case 1:
          label = "Kitchen";
          break;
    case 2:
          label = "Garage";
          break;
   }    
  return  label;
}
M2_LABELFN(el_labefn2, "x10y3", label_what);

Thanks for your help,
gnux

Hi

I do not see the declaration of "label"
Did you try this?

const char *label_what(m2_rom_void_p element)
{  

  switch (array[u8dev][13]) {
    case 0: return "Bathroom";
    case 1: return "Kitchen";
    case 2: return "Garage";
   }    
  return  "";
}
M2_LABELFN(el_labefn2, "x10y3", label_what);

Oliver

Ciao Oliver :slight_smile: , so now it's ok I'm working directly on lcd ...maybe it's better ...this was the code that I've used :

const char *linebuf = "";

const char *label_cb(m2_rom_void_p element)
{  
  switch (array[u8dev][12]) {
    case 0: 
         linebuf = "TurnedOff";
         break;
    case 2:
          linebuf = "BadState";
          break;
    case 32:
          linebuf = "TurnedOn";
          break;
   }    
  return linebuf;
}

M2_LABELFN(el_labefn2, "x10y3", label_what);

So, now I'd like to re-use the procedure above and pass like parameter "linebuf" is there a way to pass parameter ? I've tried but without success ...
I think it's possible, I've tried in several way but I've issues in "M2_LABELFN(el_labefn2, "x10y3", label_what);"

Thanks for the support,
have nice week end,
Gnux

Hi

You can not change the prototype for the callback procedure. So, you can not pass additional arguments. You need to use global variables.

Sure, this is not a good programming style...

Oliver

No problem :slight_smile: was just investigating for optimize at the top my code ... right now I'm using 28.200 byte on 32000 available ... :slight_smile: I need to look your link that you have sent to me in order to understand how to put the global variable in SRAM in order to use all Flash Memory for the program :slight_smile: I think that after that i will manage correctly my at328pu ... make sense for you ?

So, in a previous post you was mentioning this :
"You can calculate the amount of initially occupied RAM and ROM memory.
Use "avr-size" for this task. You need to locate and find the .elf file on your file system."

I've found .elf file for my sketch now is there a software to download for see how are located the variable ?

because looking the documentation it's a little bit difficult to understand sorry... i need to be little bit confident with it like did for display library :slight_smile: ... anyway i will try to read again ...

Thanks :slight_smile:
Gnux

Hi

avr-size should be part of the Arduino Distribution:
./hardware/tools/avr/bin/avr-size

Oliver

Ciao Oliver in attachment the result :slight_smile:

I need to understand now this data ... are express in byte ?

Which is the maximum limit that I've have ? So I would like to understand if I've use correctly the space for the program memory and the space for the variable ...

thanks for the information,
Gnux

Schermata 2013-02-23 a 17.49.15.png

Hi

text data bss dec hex filename
27502 698 1078 29278 1da5 spacetrash.elf

Flash-ROM (PROGMEM) size: 27502 + 698 : This must be lower than 2^15
Required RAM: 698 + 1078 + stack : This must be lower than 2048

The problem is the required stack size. It can not be calculated, but i guess it is around 200 Bytes or more.

Oliver