Pages: 1 ... 6 7 [8] 9 10 ... 13   Go Down
Author Topic: Menu for Display  (Read 10752 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :-( so could be more useful :-) 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 ...


Code:
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
Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1232
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I do not see the declaration of "label"
Did you try this?
Code:
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
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ciao Oliver :-) , so now it's ok I'm working directly on lcd ...maybe it's better ...this was the code that I've used :
Code:
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
Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1232
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No problem :-) was just investigating for optimize at the top my code ... right now I'm using 28.200 byte on 32000 available ... :-) 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 :-) 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 :-) ... anyway i will try to read again ...


Thanks :-)
Gnux
« Last Edit: February 23, 2013, 08:49:27 am by gnusso » Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1232
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

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

Oliver
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ciao Oliver in attachment the result :-)

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 (6.43 KB, 413x31 - viewed 12 times.)
Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1232
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Oliver thanks for this first explanation very useful ...

looking my avr-size result if I not understood bad kindly correct me if i wrong :-):


  text              data       bss       dec       hex   filename
  27502       698      1078     29278      725e   FinalRinse.cpp.elf

 a) .text: is said the Software Code without Variable (function, case, loop,setup, cicles etc etc) - Maximum
     size - 32.000 byte

 b) .data: is said the space for variable (SRAM) that the maximum size is ?

 c) .bss: is said the space for variable (SRAM) that the maximum size is ?

 SRAM for Atmega328 is 2000 bytes --> correct ?

 d) .dex: is the sum of a + b + c in decimal

 e) .hex: is d in hex

Then:

Flash-ROM(PROGMEM) size = text + bss = 27502 + 698 = 28.200 bytes must be < 2^15 = 28.200 < 32.000 --> it's ok

Required SRAM: (.data + .bss + stack) < 2048 = 698 + 1078 + 200 =   1976 < 2048 --> I'm at the limit of Ram used.

Is there a way for see which variable are into .data memory and which into .bss zone and in my case moving the variable that are into .data zones into the .bss zone I could use the space for the code correct ?

Sorry if I have specified point to point but I think is better way to understand, so then you are very good teacher :-) thanks you again,
gnux
« Last Edit: February 24, 2013, 02:04:53 am by gnusso » Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1232
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

We are leaving the area of menu programming, my knowledge is not that good here, but i do my best to answer this question.

Quote
a) .text: is said the Software Code without Variable (function, case, loop,setup, cicles etc etc) - Maximum
     size - 32.000 byte
Flash-ROM is the code size including variables which have none-zero init values.
.text is the value for the the pure code


Quote
b) .data: is said the space for variable (SRAM) that the maximum size is ?
.data is the size of the variables which have none-zero default value such as "int x = 4;"
This value counts against flash-rom AND ram (SRAM) area size.

Quote
c) .bss: is said the space for variable (SRAM) that the maximum size is ?
This is the size of those variables, which have a zero default value, such as "int y = 0;"

The stack size is not listed here, because it grows during runtime.
Conclusion for overall memory consumption:
Flash-Rom = .text + .data
SRAM = .data + .bss + stack

Quote
SRAM for Atmega328 is 2000 bytes --> correct ?
Well yes, the datasheet will be a more reliable source, but if i remember correctly then it is 2048.

Quote
Flash-ROM(PROGMEM) size = text + bss = 27502 + 698 = 28.200 bytes must be < 2^15 = 28.200 < 32.000 --> it's ok
You took the right numbers, but your text is wrong: "size = text + data"

Quote
Required SRAM: (.data + .bss + stack) < 2048 = 698 + 1078 + 200 =   1976 < 2048 --> I'm at the limit of Ram used.
Yes, i think so too. Especially i do not know if stack needs 100, 200 or 300 bytes.
If you need a precise answer, you will need tools like this: http://www.absint.com/stackanalyzer/index.htm

You can also do a runtime analysis by your own. I found the following threads also:

This is a nice idea for fully automatic runtime calculation:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=52249

This also has several links and lot of information:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=78518

Have fun,
Oliver











« Last Edit: February 24, 2013, 02:54:31 am by olikraus » Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Oliver for the Information,
with you I've learned a lot of things :-) ... So, I think that very soon I will pass to Arduino Mega 2560 because the menu is very useful and I will introduce more menu ...

What I was thinking for the future is use another kind of Display (maybe touch) to use with your great library ...

So from your experience could you kindly advise me, which kind of display to use ?

thanks again for your support :-) !
Gnux
Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1232
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Which display? Well i like graphics displays. ST7565 based display are usually a good choice, because you can use 4 wire SPI. Unfortunately they can not be connected directly to a 5V board like the Arduino Uno or Mega (level translation needed).

Oliver

Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's nice ! and give you a lot's of choice vs lcd 20 x 4 :-) ... the power is not a big issues because I've another circuit that give power to lcd ... the important thing that is possible to work with your library ... :-) because now that I've understand the logical... :-)

Thanks you :-)
gnux
Logged

Germany
Offline Offline
Edison Member
*
Karma: 100
Posts: 1232
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

3v3 displays not only require 3v3 power supply, but also need logic levels, that do not exceed 3v3.
This means, you need a level translation on each communication pin

Oliver
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Oliver, I will tell this to my friend that is project the hardware :-)

So, just to be sure that I've develop the code with "awareness" I report to you how I've implement my code i'd like to know from your stand point and experience if I've wrong did some errors and have lose precious memory ... Yestarday after a lots of hour of code I've tried with ATMEGA328PU was like size but was not working. Then I've tried with ATMEGA2560 and was working without problem....

For the menu standpoint:

- I've try to design a menu with the element in the same position in special way for the label, in this way I can instance only one time the object and call it without loose a lot's of space.
- Where possible I've re-use the function passing parameter in order to re-use everything without any problem.

From the other code-stand point:
- I've try to do a general procedure where possible in order to re-use everything and just call the procedure with different parameter and use less global variable in order to save the space ...

So, if you have suggestion or tip please kindly let know,

So, from the display stand point unknowing all the library but just using it i don't know if are possible more optimization :-)

how ever thanks for the support and patience :-)

regards,
gnux
Logged

Pages: 1 ... 6 7 [8] 9 10 ... 13   Go Up
Jump to: