Show Posts
Pages: 1 ... 43 44 [45] 46 47 ... 83
661  Using Arduino / Displays / Re: Need Help>> How to display Arabic Character on LCD with Arduino>> on: January 22, 2013, 02:48:46 pm
Unicode has defined chars from 0x0600 to 0x06ff as arabic chars: http://www.unicode.org/charts/PDF/U0600.pdf.
Assuming that this is almost complete, then the range from  0x0600 to 0x06ff can be mapped to 0 to 255 (well from 1 to 255, because in C the 0 usually terminates a string).

Unifont claims that the arabic glyphs from 0x0600 to 0x06ff are included: http://unifoundry.com/unifont.html.

So, the following steps will provide arabic chars with u8glib

1. Download unifont BDF
2. Download bdf2u8g font converter from here: http://code.google.com/p/u8glib/downloads/list
3. Create a u8g font with arabic glyphs: bdf2u8g -l 12 -u 13 -b 0 -e 255 <bdf-file> <u8g_font_arabic> <u8g_font_filename>
4. Use the new font in your project

Oliver
662  Using Arduino / Programming Questions / Re: Menu for Display on: January 20, 2013, 04:44:27 pm
Quote
- If i need print something like data and time (now printed in serial) how I can do ? I can print directly on lcd ? this is a general question for example a result of procedure or something else ...

To print the menu on the LCD, just replace the serial graphics handler with the graphics handler for the character lcd. In order to show something, you could design a menu, with read only fields and only one selectable ok button. Any element can made "read only" by adding "r1" to the format string, so

Code:
M2_U8NUM(el_dt_year, "c2r1", 0,99,&dt_year);
M2_LABEL(el_dt_sep1, "b1", "-");
M2_U8NUM(el_dt_month, "c2r1", 1,12,&dt_month);
M2_LABEL(el_dt_sep2, "b1", "-");
M2_U8NUM(el_dt_day, "c2r1", 1,31,&dt_day);

will show the date but will not allow to enter any data (M2_LABEL is always read only).
Of course you can also write directly to the LCD screen, no problem.
Tutorial 6 might give a some ideas here (http://code.google.com/p/m2tklib/wiki/t06glcd)

Oliver


663  Using Arduino / Programming Questions / Re: Menu for Display on: January 20, 2013, 10:00:54 am
Code looks quite good now. Let me know if you need more assistance.

Oliver
664  Using Arduino / Programming Questions / Re: Menu for Display on: January 20, 2013, 07:26:22 am
The hierarchie for the date input is like this:

VLIST
  HLIST
    U8NUM - year
    LABEL
    U8NUM - month
    LABEL
    U8NUM - day
  HLIST
    ROOT - cancel button
    BUTTON - ok button

Code:
+-VLIST---------------------------------+
|                                       |
|  +-HLIST----------------------------+
|  |  YYYY-MM-DD                      | |
|  +----------------------------------+
|                                       |
|  +-HLIST----------------------------+
|  |  cancel                  ok       | |
|  +----------------------------------+
|                                       |
+---------------------------------------+

The hierarchie is important. Nested lists are used to get the layout done. For the time dialog this is almost the same, but the upper HLIST needs to be exchanged (from a layout perspective).

What you did is this:
VLIST
  U8NUM - hour
  LABEL
  U8NUM - minutes
  ROOT - cancel
  BUTTON - ok

The VLIST element renders everything from top to down. All in all the VLIST has a height of 5 rows, the upper most disapearing, because the LCD simulator only uses 4 rows (like your display also).
You need the same structure with two horizontal lists like in the date dialog.

Oliver
665  Using Arduino / Programming Questions / Re: Menu for Display on: January 20, 2013, 05:10:38 am
Hi

So far your code seems quite ok. The callback procedure will store the date into the RTC once the ok button is pressed.

For the time menu, you probably need to consider which elements are needed on your menu.
If you need only hour and minutes than two U8NUM elements will do the job (similar to the data entry, but different ranges)
Of course you will need again a cancel and an ok button.

You can takeover the date code and transform it like this:
Code:
M2_U8NUM(el_dt_hour, "c2", 0,23,&dt_hour);
M2_LABEL(el_dt_c, "b1", ":");
M2_U8NUM(el_dt_min, "c2", 0,59,&dt_min);

M2_LIST(list_time) = { &el_dt_hour, &el_dt_c, &el_dt_min};

The rest should be almost identical to the date menu. Of course element and procedure names need to be renamend.

Oliver

Edit: Hour and Minute ranges
666  Using Arduino / Programming Questions / Re: Menu for Display on: January 19, 2013, 12:22:59 pm
Hi

Well, ".net". You have unlimited memory for data and code. But here on the Arduino... everything has to fit into a very small amount of RAM and ROM. In fact, M2tklib puts all of the elements into PROGMEM to save RAM area. This makes the menu definition look a little bit strange.

Code:
void dt_ok_fn(m2_el_fnarg_p fnarg)
{
  m2_SetRoot(&top_el_expandable_menu);
}

"m2_el_fnarg_p fnarg" can be ignored. But it is importent to have a proper function definition for the BUTTON callback, so for the BUTTON callback it must be there. There are some m2tklib procedures, which might get use of the fnarg pointer.
This callback is described here:
http://code.google.com/p/m2tklib/wiki/elref#BUTTON

"m2_SetRoot(&top_el_expandable_menu);" is the C interface. It is fully equivalent to m2.setRoot(&top_el_expandable_menu).
The set root procedure is described here:
http://code.google.com/p/m2tklib/wiki/fnref#setRoot

Code:
M2_U8NUM(el_dt_year, "c2", 0,99,&dt_year);

"c2" is the so called format string. It is described here: http://code.google.com/p/m2tklib/wiki/elref#Element_Format_String

The format option "c", which is used here depends on the actual element. Overview is given here: http://code.google.com/p/m2tklib/wiki/elref#Overview. But in this case we have a unsigned 8 bit data entry field, which is described (along with the "c2" format option) here: http://code.google.com/p/m2tklib/wiki/elref#U8NUM. Especially the last link explains "c2": It tells the element to display two digits.
"0,99" is the range (also described in the wiki)
"&dt_year" is a reference to the variable, so that m2tklib can modify the variable directly. Any user input is directly written into this variable.

Code:
M2_LIST(list_date) = { &el_dt_year, &el_dt_sep1, &el_dt_month, &el_dt_sep2, &el_dt_day };
M2_HLIST(el_date, NULL, list_date);

M2_LIST is not an element. It defines a list for a container element.
M2_HLIST is a container element. Elements refered in the corresponding list, are shown from left to right in a row. Again full description to gether with example is here: http://code.google.com/p/m2tklib/wiki/elref#HLIST

M2_LIST and all other elements are macros (no function calls). They have all file local scope, but can be made global visible with the extern macro: M2_EXTERN_HLIST

BTW: Is the documentation clearly enough? Or do you see some optimization? For sure there is some optimization possible, but probably i need some advice how to improve the documentation.


Quote
M2_ROOT(el_dt_cancel, NULL, "cancel", &top_el_expandable_menu);  --> Call something that bring you to the root ?
M2_ROOT appears as a push button. Once selected by the user it assignes the provided root element to the display. This makes top_el_expandable_menu visible to the user.

Quote
M2_BUTTON(el_dt_ok, NULL, "ok", dt_ok_fn);  --> Call something that confirm the date and bring you to root ?
Same as M2_ROOT, but calls a procedure once selected. This is more flexible than M2_ROOT.

Hope this clarifies things a little bit

Oliver




667  Using Arduino / Displays / Re: Pervasive Displays [no power displays - e-paper] on: January 19, 2013, 10:38:11 am
Under the current conditions it is impossible to add e-paper support to u8glib. Additionally i was told that controlling an e-paper device is very different to OLED or GLCD devices. If the documentation is available to the public, then i need time to get one of these devices, understand the concept and implement something to u8glib. Especially time is a rare resource for me at the moment. So, i would suggest not to wait for u8glib supporting e-paper, but instead look for some different display type.
 
Oliver (u8glib)
668  Using Arduino / Programming Questions / Re: Menu for Display on: January 19, 2013, 10:20:32 am
Your menu is working great. Here is a log file with your menu and my key strokes ('s' and 'n'):

m2tklib serial (press 'h' for help)

m2tklib LCD simulator

[+Date/Time 1 ]                         
  Radio                                 
  Combo                                 
                                       
s
[-Date/Time 1 ]                         
   Set Date 1-1                         
   Set Time 1-2                         
   View Date 1-3                       
n
 -Date/Time 1                           
[  Set Date 1-1                         
   Set Time 1-2                         
   View Date 1-3                       
n
 -Date/Time 1                           
   Set Date 1-1                         
[  Set Time 1-2                         
   View Date 1-3                       
s
                                       
                                       
[12]- 01 - 01                           
 cancel  ok                             
n
                                       
                                       
 12 -[01]- 01                           
 cancel  ok                             
s
                                       
                                       
 12 -[02]- 01                           
 cancel  ok                             
s
                                       
                                       
 12 -[03]- 01                           
 cancel  ok                             
n
                                       
                                       
 12 - 03 -[01]                         
 cancel  ok                             
n
                                       
                                       
 12 - 03 - 01                           
[cancel] ok                             
n
                                       
                                       
 12 - 03 - 01                           
 cancel [ok]                           
s
[-Date/Time 1 ]                         
   Set Date 1-1                         
   Set Time 1-2                         
   View Date 1-3                       



Quote
Could you kindly clean up the code in order to have only one menu with only one sub menu ...
Not sure if i understood you correctly, but you could simply remove most of the lines from the m2_menu_entry array:

Instead of
Code:
m2_menu_entry m2_2lmenu_data[] =
{
  { "Date/Time 1", NULL },
  { ". Set Date 1-1", &el_num_menu },
  { ". Set Time 1-2", &el_top_dt },
  { ". View Date 1-3", &el_top_dt },
  { ". View Time 1-4", &el_top_dt },
  { "Radio", &top_el_radio },
  { "Combo", &top_el_combo },
  { NULL, NULL },
};

use

Code:
m2_menu_entry m2_2lmenu_data[] =
{
  { "Date/Time 1", NULL },
  { ". Set Date 1-1", &el_num_menu },
  { NULL, NULL },
};

Of course you probably want to call the date entry if you pess the "set date" menu:

Code:
m2_menu_entry m2_2lmenu_data[] =
{
  { "Date/Time 1", NULL },
  { ". Set Date 1-1", &el_top_dt },
  { NULL, NULL },
};

Does this answer your question?

Oliver
669  Using Arduino / Programming Questions / Re: Menu for Display on: January 18, 2013, 02:11:04 pm
Here is an example for a date entry dialog box:
Code:
/*=========================================================================*/
/* edit date dialog */

uint8_t dt_day;
uint8_t dt_month;
uint8_t dt_year;

void dt_get_from_RTC(void)
{
  RTC.getTime();
  dt_day = RTC.day;
  dt_month = RTC.month;
  dt_year = (RTC.year-2000);
}

void dt_put_to_RTC(void)
{
  RTC.getTime();
  RTC.fillByYMD(dt_year+2000, dt_month, dt_day);
  RTC.setTime();
  RTC.startClock(); 
}

void dt_ok_fn(m2_el_fnarg_p fnarg)
{
  dt_put_to_RTC();
  m2.setRoot(&el_top);
}

M2_U8NUM(el_dt_day, "c2", 1,31,&dt_day);
M2_LABEL(el_dt_sep1, NULL, ".");
M2_U8NUM(el_dt_month, "c2", 1,12,&dt_month);
M2_LABEL(el_dt_sep2, NULL, ".");
M2_U8NUM(el_dt_year, "c2", 0,99,&dt_year);

M2_LIST(list_date) = { &el_dt_day, &el_dt_sep1, &el_dt_month, &el_dt_sep2, &el_dt_year };
M2_HLIST(el_date, NULL, list_date);

M2_ROOT(el_dt_cancel, NULL, "cancel", &el_top)
M2_BUTTON(el_dt_ok, NULL, "ok", dt_ok_fn);
M2_LIST(list_dt_buttons) = {&el_dt_cancel, &el_dt_ok };
M2_HLIST(el_dt_buttons, NULL, list_dt_buttons);

M2_LIST(list_dt) = {&el_date, &el_dt_buttons };
M2_VLIST(el_top_dt, NULL, list_dt);

The "dt_put_to_RTC" procedure will be different for your, but the element hierarchy might be the same.
The top level element is "el_top_dt".

This means that your data for the 2L-Menu might look like this:

Code:
m2_menu_entry m2_2lmenu_data[] =
{
  { "Date/Time 1", NULL },
   { ". Set Date 1-1", &el_top_dt },
  ...
  { NULL, NULL },
};

The 2L-Menu is another element hierarchy. For example:

Code:
M2_2LMENU(el_2lmenu,"l4F3e15W43",&m2_2lmenu_first,&m2_2lmenu_cnt, m2_2lmenu_data,65,102,'\0');
M2_SPACE(el_space, "W1h1");
M2_VSB(el_vsb, "l4W2r1", &m2_2lmenu_first, &m2_2lmenu_cnt);
M2_LIST(list_2lmenu) = { &el_2lmenu, &el_space, &el_vsb };
M2_HLIST(el_hlist, NULL, list_2lmenu);
M2_ALIGN(top_el_expandable_menu, "-1|1W64H64", &el_hlist);

The toplevel (root) element is "top_el_expandable_menu".

Oliver
670  Using Arduino / Programming Questions / Re: Menu for Display on: January 18, 2013, 01:46:44 pm
Hi

M2tklib requires at least 2 buttons. Make sure that you use the correct event handler. With two buttons, the "2bs" handler.
Existing event handler are described here http://code.google.com/p/m2tklib/wiki/fnref#M2tk.

With M2tklib you can describe a dialog / user entry form. Such a form is composed of several elements. These elements have a hierarchie, including one element, which is the root element.

In tutorial 2 (http://code.google.com/p/m2tklib/wiki/t03) you see the following user entry form:

Code:
void fn_ok(m2_el_fnarg_p fnarg) {
  /* do something with the number */
}
M2_LABEL(el_label, NULL, "Num: ");
M2_U32NUM(el_num, "a1c4", &number);
M2_BUTTON(el_ok, "", " ok ", fn_ok);
M2_LIST(list) = { &el_label, &el_num, &el_ok };
M2_HLIST(top_el_hlist, NULL, list);

The root element is "top_el_hlist", it contains "list" and list contains "el_label", "el_num" and "el_ok". So, basically it looks like this:
HLIST
  - LABEL
  - U32NUM
  - BUTTON

The toplevel element "top_el_hlist" is the most important element. If you want to display this complete dialog  box, you must make the toplevel element "top_el_hlist" the so called "root" element.

Making a toplevel element as a root element is just like jumping to this dialog box. There are several ways to make an element the root element: M2_ROOT or m2.setRoot() are two common options. The 2L-Menu element is another option to make other elements the root element. Just add the root element next to the menu title (including &). See the example pde.

Oliver






671  Using Arduino / Programming Questions / Re: Menu for Display on: January 18, 2013, 02:10:24 am
Hi

Input:

By default M2tklib supports aktive low push buttons: Connect an Arduino pin to a push button and the other end of the push button to ground.

A keypad can be used, but you need to define your own "event source", which is not really described at the moment. Let me know if your really want to use your keypad. In this case we need to study the datasheet for the keypad and write a specific event source.

Another way is to simulate input by using the serial monitor.
With the serial monitor you can test your menus without extra input hardware. Instead, input on the serial monitor is used to navigate through the menues. For example look at the Combo.pde:
You will find the following line:
Code:
M2tk m2(&list_element, m2_es_arduino, m2_eh_2bs, m2_gh_lc);
Add "_serial" to the event source:
Code:
M2tk m2(&list_element, m2_es_arduino_serial, m2_eh_2bs, m2_gh_lc);
This enables the serial monitor to navigate through the menu. Remember to activate the serial monitor in your Arduino IDE.
This can be done for all examples, and of course it might be a good starting point for your projects, if you have not yet decided which hardware buttons to use.

Learning M2tklib:

Looking at the examples is a good starting point. And it seems that the examples are already working (I am glad the M2tklib works in your environment). I also suggest to look at the first three tutorials:

Tutorial 1: General setup
Tutorial 2: How to apply the above mentioned push buttons
Tutorial 3: How to build a simple menu/dialog
I also suggest to read
Tutorial 7: How to use the serial monitor interface
as mentioned above for quick success without additional input hardware

Oliver
672  Using Arduino / Programming Questions / Re: Menu for Display on: January 18, 2013, 01:35:52 am
With M2tklib only LiquidCrystal lib is supported, so you need to use your 7 pin 4x20 LCD.
Also take care to download M2tklib for LiquidCrystal.

Oliver
673  Using Arduino / Programming Questions / Re: Menu for Display on: January 17, 2013, 03:54:06 pm
liudr has once started a new section in playground:
http://playground.arduino.cc//Main/InterfacingWithHardware#ui

I also made a list of menu tools some time ago:
Library Name:             LCDMenu2
Download:             http://arduino.cc/forum/index.php/topic,73816.0.html

Library Name:             LCDMenu
Download:             http://arduino.cc/forum/index.php/topic,96104.0.html

Library Name:             MenuBackend
Download:             http://wiring.uniandes.edu.co/source/trunk/wiring/firmware/libraries/MenuBackend/

Library Name:             LCDMenu
Download:             http://www.metalgecko.com/arduino/LCDMenu.zip (does not exist any more)

Library Name:             Arduino_LCD_Menu
Download:             https://github.com/DavidAndrews/Arduino_LCD_Menu

Library Name:             MENWIZ
Download:             https://github.com/brunialti/MENWIZ

Library Name:             phi_prompt
Download:             http://liudr.wordpress.com/libraries/phi_prompt/

Library Name:             MenuSample
Download:             http://sourceforge.net/projects/arduinowifly/files/MenuSample/

Library Name:             M2tklib
Download:             http://code.google.com/p/m2tklib/

Library Name:             OpenMoCo Menu Manager
Download:             http://arduino.cc/forum/index.php/topic,131614.0.html, http://dynamicperception.com/software/openmoco-avr-libraries


I can say that discussions on MENWIZ and phi_prompt had been very active on the Display forum. I also get a lot of feedback on my own menu lib (M2tklib) and you are always wellcome to contact me if you have any trouble with M2tklib.

Oliver
674  Using Arduino / Displays / Re: Arteffects! 128x64 LCD ST7920 on: January 16, 2013, 04:03:08 pm
I can confirm that I have seen similar pictures during development of u8glib. While i also think that some of these results would make nice looking pictures, they are usually not intended.

The ST7920 controller is probably the device which consumed most of my attension during u8glib development and support. Here are my suggestions (from endless discussions with other users):
- Use the latest u8glib version. Nearly all recent updates of u8glib include fixes for the ST7920
- Solder your wires.
- Use short wires (less than 10cm)

Which serial interface did you test? HW SPI or SW SPI?

Oliver
675  Using Arduino / Displays / Re: Trouble with Menus and Analog buttons. on: January 15, 2013, 02:36:49 pm
General problems:
- There is no information about the external hardware (how are buttons connected)
- Code style could be better and leads to visually wrong assumtions. All in all code reviews get difficult with the current code layout.
- A single procedure has to do the debouncing, buttons state detection (which is missing and btw is probably at least one of the problems) and menu cursor change. This also makes separate testing nearly impossible.

Specific problems:
- If your button press will produce the adc value 900, then nothing will happen.
- Similar, if the adc value 100 is produced, BtnUp() will be executed twice, which is probably not intended.
- As mentioned above, there is no key state handling: You do not wait until the key is not pressed any more. Menu cursor is increased every 350ms because of this. It was not described if this is an intended behavior.
- BtnDown() is not part of the code, but it might get called. So how do BtnDown and BtnUp interact with each other (for example if the adc value is 100, the sequence is BtnUp, BtnDown, BtnUp). Do these procs share variables? Can these procs influence each other?
- As long as the button is pressed, the text "Over" will be overwritten immediatly by "Under". This would explain the visual feedback you explained and is a result of the missing key state handling. Probably there is an "else" missing in the "BtnUp" procedure for the "TrackUP == 0" condition.

Oliver




Pages: 1 ... 43 44 [45] 46 47 ... 83