Show Posts
Pages: 1 ... 31 32 [33] 34 35 ... 83
481  Using Arduino / Displays / Re: Simple menu m2tklib with example. on: April 14, 2013, 12:10:21 am
Hi

If you are working with the Arduino IDE, then unused procedures and data will be removed.
Both, u8glib and m2tklib, are already optimized for size. Here are some general ideas for the users of these libs:
- Avoid large fonts in u8glib. Use fonts with end in "r". The size of the font in bytes is always given in the overview picture.
- Only use a small number of fonts or only one font.
- Do not use large functions like drawLine or drawCircle
- Restrict yourself on a subset of elements in m2tklib: Maybe only use the XYLIST container.
- Reuse the format option string
- Reuse complete elements: For example a cancel button can be defined once and placed on all of the sub-menues.

Oliver
482  Using Arduino / Displays / Re: initialization process of NHD‐2.8‐25664UMB3 on: April 13, 2013, 12:51:00 am
Although you refer to the new multi-font version for the display, it should be supported by U8glib (which had been tested with the NHD-2.8-25664UCY2). Init code is here:

http://code.google.com/p/u8glib/source/browse/csrc/u8g_dev_ssd1322_nhd31oled_gr.c

The default mode for u8glib will only show 248x64 pixel for this display. To see all pixel you need to enable u8glib 16 bit mode (uncomment the constant in u8g.h)

There is also an app note on this display, including the init sequence: http://www.newhavendisplay.com/app_notes/OLED_25664.txt

Oliver

Update: I think u8glib was tested with NHD-3.12-25664UCY2 and not with  NHD-2.8-25664UCY2. But i do not see a difference between these display types, except for their dimensions.
483  Using Arduino / Displays / Re: Crius OLED display on: April 12, 2013, 11:30:37 pm
Quote
Is there a way to set the I2C speed to a lower (but more reliable) rate ?

This must be programmed into the ATMega. For example see lines 120ff in http://code.google.com/p/u8glib/source/browse/csrc/u8g_com_i2c.c

Oliver
484  Using Arduino / Displays / Re: Simple menu m2tklib with example. on: April 12, 2013, 01:46:51 pm
I would suggest to use low level graphics commands to display the measurement date.
Use M2_XYLIST() go get full controll of the placement of your buttons and other M2tklib elements.
Tutorial on low level graphics: http://code.google.com/p/m2tklib/wiki/t06u8g

Oliver
485  Using Arduino / Displays / Re: Crius OLED display on: April 12, 2013, 01:35:53 pm
When i worked with u8glib on a Seeedstudio 96x96 OLED, i noticed that the chip is very sensitive to wire size and I2C speed. 100kHz is already the limit for this controller. I2C fast mode (400kHz?)was never working with my OLED.

Another reason for not beeing able to communicate with the controller could be the look state. A library should send an unlook sequence (0x0fd, 0x012) as first command.

Oliver
486  Using Arduino / Displays / Re: LCD ST7565 on: April 11, 2013, 11:49:52 pm
Hi

Have a look at the XBM example code in the IDE: You need to copy the content of the file (car.xbm) into your .ino file. See also http://code.google.com/p/u8glib/wiki/userreference#drawXBM.

Oliver
487  Using Arduino / Displays / Re: Simple menu m2tklib with example. on: April 11, 2013, 05:44:02 pm
'el_backlight_menu' is used before it is defined. This is a common problem in C and C++. Use a forward declaration and place the command
M2_EXTERN_ALIGN(el_backlight_menu);
next to
M2_EXTERN_ALIGN(top_el_menu);

See also: http://code.google.com/p/m2tklib/wiki/elref#Forward_Declaration

Oliver
488  Using Arduino / Displays / Re: I2C SSD1306 library. on: April 11, 2013, 05:39:48 pm
A quite old thread. To update myself: U8glib now also supports I2C for the SSD1306 controller.

Oliver
489  Using Arduino / Displays / Re: Crius OLED display on: April 11, 2013, 05:35:57 pm
Hi

http://code.google.com/p/u8glib/ might work. Uncomment
Code:
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
in the examples.

Ensure that you correctly connect the display to the HW I2C lines of your board.

Oliver
490  Using Arduino / Displays / Re: LCD ST7565 on: April 11, 2013, 05:29:43 pm
You need to convert the bitmap to black/white XBM format (for example with gimp). This XBM format actually is an array of bytes which can be used as argument for drawXBM or drawXBMP.

Oliver
491  Using Arduino / Programming Questions / Re: An every X-days alarm/output, suggestions? on: April 11, 2013, 05:27:23 pm
Quote
So, it looks like the DS1307new.h library is also aware of Daylight Saving Time, the 'isMEZSummerTime'.  True?

Yes, but only the European rule is implemented here.

Oliver
492  Using Arduino / Displays / Re: LCD ST7565 on: April 11, 2013, 05:52:37 am
You must apply a suitable print position. To draw a string at position 10,10 use

Code:
u8g.setPrintPos(10, 10)

Use this just before the print command.

Oliver
493  Using Arduino / Displays / Re: glcd from dx.com on: April 11, 2013, 05:49:49 am
Ok, i see your problem. Nevertheless: Please measure the voltage at Vout. If it is negative you will probably need two suitable resistors to get the correct negative voltage which must be applied to v0.

In general: By applying some different voltage, you must be able to see and not see all the pixel.

If all this is ok, then another idea is to send a picture of your setup, so we can have a look at it.

Oliver
494  Using Arduino / Displays / Re: glcd from dx.com on: April 10, 2013, 11:53:15 pm
Quote
Am I right with the 52, 51, 53 pins ?
I did not see a mistake here.

Quote
analogWrite(3, brightness);
I do not think that this will work at all. The contrast pin of the LCD often requires a voltage outside the range of 0..5V. This can not be generated by analogWrite(). Use a var. pot. instead!

Oliver
495  Using Arduino / Displays / Re: Simple menu m2tklib with example. on: April 10, 2013, 05:07:40 pm
Hi

All good questions. Let me try to explain some of these m2tklib things.

I decided to let users define a static menu structure, which is located in flash-rom area at startup. Basically the menues are just global variables. To hide the complexity of these data structures, I invented macros (usually called elements in m2tklib).
Such a global variable is:

Code:
M2_LABEL(el_a0_label, NULL, "A0");

This macro gets expanded and will look like this:

Code:
label_strcture el_a0_label = { magic_argument, NULL, "A0" } PROGMEM_BLABLA;

So, el_a0_label is a variable name (in fact it is a structure). It will represent an element within m2tklib, which just displays a text ("A0" in this example). Usually you will need the address of this "element". In fact all other procedures or elements just expect the address:
Code:
M2_LIST(list_a0) = { &el_a0_label, &el_a0_u32, &el_a0_ok };
This defines a group of three elements (the label is the first element of that group) and calls this group "list_a0". So list_a0 is another variable name.

Conclusion: The first argument to any of the M2_xxx macros is a variable name.
For elements like M2_LABEL, use &<variablename>, for M2_LIST variables just use the name without "&".

Please also have look here: http://code.google.com/p/m2tklib/wiki/elref#Use_of_Elements

Quote
So I was figuring that the menu would at some point execute a loop to keep filling the display wit the mesurement data.

You can let m2tklib display the content of a global variable. Whenever you refresh the menu (m2.draw()), then m2tklib will take the value from that global variable. It is really like connecting your menu with some outside data: Whenever the value somewhere in the memory changes, m2tlib will display the current value (once updated with m2.draw())

Let us have a look at your example:
Code:
M2_U32NUM(el_a0_u32, "c4r1", &value_from_A0);
The menu will display the value of variable "value_from_A0". "value_from_A0" is a global variable. Whenever you put data into it, it will get displayed. For example like this:
Code:
void loop(void)
{
  value_from_A0 = get_adc_value_from_a0();
  m2.draw();
}
Whatever is measured via ADC gets shown in the menu.

Quote
Exept for the callback function in the MenuX2L example I have not found a way to do that yet. Is the callback the best way or is there a better way to execute code that is not part of the menu?

Another good question and i do not know the answer. It depends on your personal preference. There are two ways to display measured data:
- global variables (as discussed above)
- callback procedures

MenuX2L is not the only element which provides callback procedures. For example also all elements ending with M2_...FN() get their values from callback procedures. But also other elements like M2_COMBO expect a callback procedure. Let us solve the same problem from above with a callback procedure. We need to use M2_U32NUMFN (http://code.google.com/p/m2tklib/wiki/elref#U32NUMFN). It expects a callback procedure:

Code:
uint32_t u32numcb(m2_rom_void_p element, uint8_t msg, uint32_t val) {
  if ( msg == M2_U32_MSG_GET_VALUE )
   return get_adc_value_from_a0();
  return 0;
}
M2_U32NUM(el_a0_u32, "c4r1", u32numcb);

And the main loop will look like this:
Code:
void loop(void)
{
  m2.draw();
}

Might look simpler, but there is a drawback with the callback procedure: They might get called more than once during one call to "m2.draw()". For that reason i would suggest to start with the "global variable" approach.

Conclusion: There are two ways to display data in a menu:
- connected global variables (prefered method)
- values returned from global variables (optional, if you accept the drawbacks)

Quote
Then I would like a status bar on top of the display. It wil show waht tle last received navtex message type is and should be visible in all menus. Is there a way to do that?
No, there is not only one way but probably a many ways to do this  smiley-wink

1. Method: M2_COMBO
M2_COMBO will display a string, given by an index number from a list of strings (here: navtex messages types). Mark this element as read-only ("r1" format option)
Place this element at the beginning of each menu. Please note that you can reuse elements. Define it once , use it oftern.
Also note, that you usuallly will need a "container" element like XYLIST. XYLIST will allow you to place M2_COMBO at specific xy position on the screen.

2. Method: M2_LABELPTR
Similar to M2_COMBO, but you have to copy the type name into a string buffer. M2_LABELPTR is already read-only, so "r1" is not required.

3. Method: GLCD low level graphics commands
You can always draw a string directly to the screen. Just ensure that menu and your low level output do not overlap. In this case you would use the GLCD string draw procedure to output the navtex message type. A tutorial on this topic is here: http://code.google.com/p/m2tklib/wiki/t06glcd

4. Method: M2_X2LMENU
Thinkable, if you intend to build all menus just with X2LMENU (but this will restrict you a lot). In this case, just make the toplevel menu line of X2LMENU a callback procedure which returns a string with the name of the message type.

So, i will finish for now and I hope that i was able to clarify things a little bit.

Oliver






Pages: 1 ... 31 32 [33] 34 35 ... 83