-
Notifications
You must be signed in to change notification settings - Fork 11
u8gref
This page describes special procedures for the U8g subsystem. These procedures are only available for the u8g device driver.
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 |
The m2_gh_u8g_cffs
handler is available with v1.11 of M2tklib.
- 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
forM2_TOGGLE
andM2_RADIO
: Values are:m2_u8g_font_icon
(Icons are taken from a font) orm2_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
- 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.
- 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:
- 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:
- 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
- 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
/* 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)