Skip to content
olikraus edited this page Oct 24, 2016 · 3 revisions

Introduction

This page describes special procedures for the U8g subsystem. These procedures are only available for the u8g device driver.

Graphics Handler

The graphics handler must be provided to M2tklib. Within the Arduino Environment this is the last argument to the M2tk Constructor.

Handler Library Include Focus Highlight Font Description
m2_gh_u8g_bf U8glib m2ghu8g.h Box Frame setFont B/W Handler
m2_gh_u8g_bfs U8glib m2ghu8g.h Box Shadow Frame setFont B/W Handler
m2_gh_u8g_fb U8glib m2ghu8g.h Frame Box setFont B/W Handler
m2_gh_u8g_ffs U8glib m2ghu8g.h Shadow Frame Shadow Frame setFont B/W Handler
m2_gh_u8g_cffs U8glib m2ghu8g.h Shadow Frame Shadow Frame setFont Color Handler

m2_gh_u8g_bf

http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_style_bf.png

m2_gh_u8g_bfs

http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_style_bfs.png

m2_gh_u8g_fb

http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_style_fb.png

m2_gh_u8g_ffs

http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_style_ffs.png

m2_gh_u8g_cffs

http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_style_cffs.png

The m2_gh_u8g_cffs handler is available with v1.11 of M2tklib.

Function Reference

m2_SetU8g

  • C Prototype
void m2_SetU8g(u8g_t *u8g, m2_gfx_fnptr gh_icon_draw)
  • Description

Connect U8g library to the M2tk graphics subsystem for U8g. Also define the icon style (radio and toggle buttons)

  • Arguments
    • u8g: Pointer to the u8g structure
    • gh_icon_draw for M2_TOGGLE and M2_RADIO: Values are: m2_u8g_font_icon (Icons are taken from a font) or m2_u8g_box_icon (Icon is a box with the size of the current font)
  • Return: -
  • See also: M2tk m2_SetU8gToggleFontIcon m2_SetU8gRadioFontIcon
  • Example: Setup sequence for Arduino Environment:
// Arduino setup procedure (called only once)
void setup() {
  // Connect u8glib with m2tklib
  m2_SetU8g(u8g.getU8g(), m2_u8g_box_icon);

  // Assign u8g font to index 0
  m2.setFont(0, u8g_font_6x13);

  // Setup keys
  m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
  m2.setPin(M2_KEY_NEXT, uiKeyDownPin);
  m2.setPin(M2_KEY_PREV, uiKeyUpPin);
}

The

m2_SetU8gAdditionalReadOnlyXBorder

  • C Prototype
void m2_SetU8gAdditionalReadOnlyXBorder(uint8_t w)
  • Description

Define additional space on the left and right side of a label field. The term "ReadOnly" referes to an internal message to the graphics subsystem and is not related to the read only flag.

  • Arguments
    • w: Number of pixel, added to the left and right side of a label (read only element). Default is 1.
  • Return: -
  • See also: m2_SetU8g
  • Examples: The effect is similar to m2_SetU8gInvisibleFrameXBorder, only for label elements. The left picture shows the value 0 (no space between ":" and "N"). The right picture shows the default value 1. http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_strlist_ro_adj_0.png http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_strlist_ro_adj_1.png

m2_SetU8gAdditionalTextXBorder

  • C Prototype
void m2_SetU8gAdditionalTextXBorder(uint8_t w)
  • Description

Define additional space on the left and right side of a text.

  • Arguments
    • w: Number of pixel, added to the left and right side of a text. Default is 1.
  • Return: -
  • See also: m2_SetU8g
  • Examples: From left to right, values are 0, 1 and 2:

http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_adj_style_0_0.png http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_adj_style_0_1.png http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_adj_style_0_2.png

m2_SetU8gInvisibleFrameXBorder

  • C Prototype
void m2_SetU8gInvisibleFrameXBorder(uint8_t w)
  • Description

Define additional space on the left and right side of a frame box.

  • Arguments
    • w: Number of pixel, added to the left and right side of a frame box. Default is 1.
  • Return: -
  • See also: m2_SetU8g
  • Examples: From left to right, values are 0, 1 and 2:

http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_adj_style_0_0.png http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_adj_style_1_0.png http://wiki.m2tklib.googlecode.com/hg/pic/u8g/u8g_adj_style_2_0.png

m2_SetU8gRadioFontIcon

  • C Prototype
void m2_SetU8gRadioFontIcon(const u8g_fntpgm_uint8_t *font, uint8_t active, uint8_t inactive)
  • Description

Defines the font and the character for the radio buttons

  • Arguments
    • font: A font of the u8g library.
    • active: Character code of the active radio button.
    • inactive: Character code of the inactive radio button.
  • Return: -
  • See also: m2_SetU8g m2_SetU8gToggleFontIcon

m2_SetU8gToggleFontIcon

  • C Prototype
void m2_SetU8gToggleFontIcon(const u8g_fntpgm_uint8_t *font, uint8_t active, uint8_t inactive)
  • Description

Defines the font and the character for the toggle buttons

  • Arguments
    • font: A font of the u8g library.
    • active: Character code of the active toggle button.
    • inactive: Character code of the inactive toggle button.
  • Return: -
  • See also: m2_SetU8g m2_SetU8gRadioFontIcon

Global Variables

/* bg and fg colors for all modes */
extern uint8_t m2_u8g_fg_text_color;
extern uint8_t m2_u8g_bg_text_color;

/* bg and fg colors for 332 color mode (m2_gh_u8g_cffs) */
extern uint8_t m2_u8g_highlight_shadow_color;
extern uint8_t m2_u8g_highlight_frame_color;
extern uint8_t m2_u8g_highlight_bg_color;

extern uint8_t m2_u8g_highlight_focus_shadow_color;
extern uint8_t m2_u8g_highlight_focus_frame_color;
extern uint8_t m2_u8g_highlight_focus_bg_color;

extern uint8_t m2_u8g_normal_focus_shadow_color;
extern uint8_t m2_u8g_normal_focus_frame_color;
extern uint8_t m2_u8g_normal_focus_bg_color;

extern uint8_t m2_u8g_small_focus_bg_color;		
extern uint8_t m2_u8g_exit_data_entry_color;

extern uint8_t m2_u8g_background_color;

For the m2_gh_u8g_cffs handler, the values must be 8 bit values, with

  • 3 bit for red (bit position 5-7)
  • 3 bit for green (bit position 2-4)
  • 2 bit for blue (bit position 0-1)
Clone this wiki locally