M2TKLIB - A User-Interface-Toolkit for the Arduino Hardware

Hi All

I have released a first version of M2TKLIB, a graphical and character user interface library for the Arduino Environment.
M2TKLIB is portable und uses existing libraries to build menues and dialog boxes. Supported libraries are

  • LiquidCrystal (so M2TKLIB should work with any Character LCD which is supported by the LiquidCrystal library),
  • GLCDv3 Library,
  • DOGM128 Library.

Project URL: Google Code Archive - Long-term storage for Google Code Project Hosting.

Please let us know

  • which output devices are working and not working,
  • what is missing (elements, output devices, touchpanel, docs, tutorials, examples, ...).

Oliver

Oliver,
I added a link to your library on the main glcd-arduino code page (it's there now) and I've also updated
the glcd library's included html documentation to include a link to it as well in a new "resources" section.
It will show up in the next glcd library release.

--- bill

Thanks,
A link to glcd-arduino is part if the install instructions (Google Code Archive - Long-term storage for Google Code Project Hosting.)
Oliver

Created v1.01 for GLCD.
Includes "read-only" option for fields and a frequency generator (http://arduino.cc/forum/index.php/topic,66088.0.html)

Oliver

Very nice! I am going to try it on my displays!

Oliver,

Thanks for killing another one of my projects (no, really... I can get on with what I need to do rather than write yet another semi-custom form handler).

One thing that seems to be missing is a way to send input events to M2TLKLIB from e.g. an interrupt handler connected to a rotary encoder or a custom keypad matrix.

Here are a couple of tiny diffs that add an event source message that soft-presses any of the keys, so that platform-specific input handling code can be used instead of hard buttons. I've only added support for the message to the Arduino eventsource, but I'm sure it would be portable.

= Mike

--- ../orig/m2tklib/src/m2.h	2011-07-09 20:09:56.000000000 -0700
+++ m2tklib/src/m2.h	2011-07-09 20:01:03.000000000 -0700
@@ -712,6 +712,8 @@
 /* first call to the event source handler is this message */
 #define M2_ES_MSG_INIT 1
 
+/* events in this range are a request to soft-press M2_KEY_* (event - M2_ES_MSG_SET_KEY) */
+#define M2_ES_MSG_SET_KEY 100
 
 /*==============================================================*/
 uint8_t m2_nav_user_up(m2_nav_p nav) M2_NOINLINE;						/* m2usrupdn.c */
--- ../orig/m2tklib/dev/arduino/m2esarduino.c	2011-07-09 20:09:56.000000000 -0700
+++ m2tklib/src/m2esarduino.c	2011-07-09 20:08:57.000000000 -0700
@@ -32,6 +32,8 @@
 static uint8_t m2_arduino_check_key(uint8_t key) M2_NOINLINE;
 static uint8_t m2_arduino_get_key(void) M2_NOINLINE;
 
+static uint8_t m2_arduino_soft_keys;
+
 static void m2_arduino_setup_key(uint8_t key)
 {
   uint8_t pin;
@@ -65,10 +67,20 @@
 
 static uint8_t m2_arduino_get_key(void)
 {
+  uint8_t key;
+
   if ( m2_arduino_check_key(M2_KEY_SELECT) ) return M2_KEY_SELECT;
   if ( m2_arduino_check_key(M2_KEY_EXIT) ) return M2_KEY_EXIT;
   if ( m2_arduino_check_key(M2_KEY_NEXT) ) return M2_KEY_NEXT;
   if ( m2_arduino_check_key(M2_KEY_PREV) ) return M2_KEY_PREV;
+
+  for (key = 0; key <= M2_KEY_CNT; key++) {
+    if (m2_arduino_soft_keys & (1<<key)) {
+      m2_arduino_soft_keys &= ~(1<<key);
+      return M2_KEY_EVENT(key);
+    }
+  }
+
   return M2_KEY_NONE;
 }
 
@@ -83,6 +95,13 @@
       m2_arduino_setup();
       return 0;
   }
+  if (msg >= M2_ES_MSG_SET_KEY) {
+    msg -= M2_ES_MSG_SET_KEY;
+    if (msg <= M2_KEY_CNT) {
+      m2_arduino_soft_keys |= (1<<msg);
+    }
+  }
+
   return 0;
 }

Hi All

Version 1.02 has been released.
http://code.google.com/p/m2tklib/

  • New GLCD graphics handler with setFont() support
  • Bugfix for KEY_PREV
  • Display "." with M2_U32NUM
  • Documentation completed and updated
  • Read-only option (v1.01)

Thanks to MikeSmith for the bug reports and enhancement requests.

Oliver

New release v1.03 of M2tklib is available:
http://code.google.com/p/m2tklib/

It contains two new elements (widgets) and a scrollbar:

The new INFO and INFOP elements show a string (RAM or PROGMEM) with up to 254 lines. The scrollbar is also available:

The STRLIST element allows the selection of one line out of up to 254 lines:

The library is available for the dogm128 library, for the GLCDv3 library and the LiquidCrystal library. For the LiquidCrystal library, M2tklib redefines up to 4 characters to display a scrollbar:

Oliver

Hahaha! Good work! I had the info as text_area to align with Java names and I had scroll bar too. Both elements were big pains to debug for me I bet the same for you!

Here is my recent work: a serial LCD keypad panel

It also has a full size 20X4 cousin. They're both sold on inmojo.com

blog:

Arduino forum thread:

http://arduino.cc/forum/index.php/topic,72206.0.html

Ahh, yes, after a lot of debugging, i decided to write a SDL interface for the graphics output. So now i can debug most of the M2TKLIB code with classical unix tools (gdb and friends). Still the remaining (hardware dependent) software parts make me trouble enough: it took me some hours to make the character redefinition correct :~

Oliver

olikraus:
Ahh, yes, after a lot of debugging, i decided to write a SDL interface for the graphics output. So now i can debug most of the M2TKLIB code with classical unix tools (gdb and friends). Still the remaining (hardware dependent) software parts make me trouble enough: it took me some hours to make the character redefinition correct :~

Oliver

My biggest headache was integer math in the calculations. I realized that I was never used to it. Maybe should have taken a discrete math in college but too busy with other stuff and didn't taken any class from CSCI.

Hi

M2tklib has been updated to v1.05.

Project Home: Google Code Archive - Long-term storage for Google Code Project Hosting.

At the moment, I have uploaded the GLCD version only. Please let me know, if there is need for the LiquidCrystal or dogm128 release.

Oliver

Hi All

Topic 1:

I have released M2tklib (Google Code Archive - Long-term storage for Google Code Project Hosting.) for U8glib (Google Code Archive - Long-term storage for Google Code Project Hosting.).

M2tklib builds menus and dialog windows on top of an existing graphics or
character library. Currently, M2tklib supports the following libraries:

  • Graphic LCDs:
    GLCDv3
    dogm128 lib
    U8glib

  • Character LCDs:
    LiquidCrystal
    DogLcd lib (send PM)

Other character LCD libraries could be added on request.

Dialog elements include: Radio Buttons, Toggle Button, Combo Box, Text Entry,
Number Entry, Push Buttons, Dynamic length menues, Scrollbar (also for character LCDs),
Container Widgets (Grid, XY-List, ...)

With U8glib as graphics subsystem, M2tklib can be used on a large number of
displays (Google Code Archive - Long-term storage for Google Code Project Hosting.). This includes Adafruit
and DFRobot displays.

Topic 2: M2tklib for character LCDs

Related to the current discussion on character menues: I recently developed a small menu for a user in the international part of this forum: http://arduino.cc/forum/index.php/topic,99105.0.html
Here are some screenshots of the character version of M2tklib:

Main menu with four entries, focus on the first:

A single selection menu with scrollbar (the scrollbar is composed of 4 user defined characters with pixel exact resolution):

A simple number entry dialog, focus on the number:

Same dialog, focus on the ok button:

The source code for these dialog entry screens is very simple and portable betwen graphics and character LCDs.

Oliver

Great work! I posted some features of my library in the products forum. These are the features that need programming, other than just calling library functions.

Hello, I'm starting with this.
I'm testing the library and it seems to work great with GLCD

But I find the following difficulties.

M2_COMBO want the number of elements is dynamic from another variable to change at any time. For example from a configuration menu.
U8NUM (32) is the same with min and max value.

I miss an item type M2_DUMMY , that does not perform visual nothing but only to call a function.

That improvements could be made?

Thanks

Hi

M2_STRLIST with the "l" format option set to 1 could replace M2_COMBO. M2_STRLIST is more powerful and has a dynamic number of elements. Let me know if M2_STRLIST will be ok for your application.

I miss an item type M2_DUMMY , that does not perform visual nothing but only to call a function.

I do not fully understand this. You need something which does not display anything, but will call a function.
Maybe you can describe your desired application for this so that i get a better understanding for this. Also note that there is now an additional callback procedure which might help: Google Code Archive - Long-term storage for Google Code Project Hosting.

Oliver

Thanks, I will try your suggestions.
I will update the library (was with 1.08.1)

Thank's

I have added an issue on the project page to implement M2_COMBO with changeable number of elements. Hope this is what you have requested.
M2_STRLIST is close to your request, but maybe an improved M2_COMBO might be better.

Oliver

M2_STRLIST, ok the msg parameter and operation.
But he is in between of other elements, and I can not move to the next or previous item.

In COMBO would be interesting to know if the value of combo has changed by a msg in cb function.

setRootChangeCallback , i think not server:

m2_menu_entry m2_2lmenu_data[] = 
{
  { "Menu 1", NULL },
  { "Menu 2", NULL },
  { "Execute", &top_el_dummy },
  { NULL, NULL },
};

void dummy_fn(m2_el_fnarg_p fnarg)
{
  arr = (TimeAlarmsClass *) malloc(sizeof(TimeAlarmsClass) * 10);
  for(int i = 0; i < 10; i++)
	Serial.println(arr[i].getTriggeredAlarmId());
        digitalWrite(RL1,ON);
	delay (1000);
	digitalWrite(RL1,OFF);

	m2.setRoot(&m2_null_element);
}

M2_BUTTON(top_el_dummy,NULL,"CONFIRMAR",dummy_fn);

From a menu item. I want to execute a function
It is made with a button but I do not want to use the button.
I need an item that does not show anything and know that the menu item was who called

Thanks very much by the interest

Best Regards

Hi

M2_STRLIST: Yes, M2_STRLIST is more like a toplevel element and is difficult to use in between other elements.
I will add a more flexible M2_COMBO with dynamic number of elements.

In COMBO would be interesting to know if the value of combo has changed by a msg in cb function.

There is no value change callback. Instead you can observe the value, which is modified by M2_COMBO

uint8_t var_for_m2_combo;  // adr of this var is given to M2_COMBO
uint8_t prev_value;             // this is a backup value to detect changes by M2_COMBO
...
void loop(void)
{
   ...
   if ( prev_value != var_for_m2_combo )
  {
     // value has changed, do some action
    ...
    prev_value = var_for_m2_combo;
  }
}

From a menu item. I want to execute a function

With M2_2LMENU you can only call other menus. Use M2_STRLIST, which allows you to call other menues or execute procedures.

BTW: You should free the allocated memory in your callback proc.

Oliver