This commit is contained in:
olikraus
2016-12-20 22:10:09 +01:00
parent 9464f0612d
commit 594fc22031
5 changed files with 34 additions and 15 deletions
@@ -111,10 +111,10 @@
void setup(void) {
// DOGS102 Shield (http://shieldlist.org/controlconnection/dogs102)
// u8x8.begin(/* menu_select_pin= */ 5, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 2, /* menu_home_pin= */ 3);
// u8g2.begin(/* menu_select_pin= */ 5, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 2, /* menu_up_pin= */ U8X8_PIN_NONE, /* menu_down_pin= */ U8X8_PIN_NONE, /* menu_home_pin= */ 3);
// DOGM128 Shield (http://shieldlist.org/schmelle2/dogm128) + DOGXL160 Shield
// u8x8.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 3, /* menu_prev_pin= */ 7, /* menu_home_pin= */ 8);
//u8g2.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 3, /* menu_prev_pin= */ 7, /* menu_up_pin= */ U8X8_PIN_NO NE, /* menu_down_pin= */ U8X8_PIN_NONE, /* menu_home_pin= */ 8);
// Arduboy
//u8g2.begin(/*Select=*/ A0, /*Right/Next=*/ 5, /*Left/Prev=*/ 9, /*Up=*/ 8, /*Down=*/ 10, /*Home/Cancel=*/ A1); // Arduboy DevKit
@@ -135,7 +135,7 @@ const char *string_list =
"Stratocumulus\n"
"Stratus";
uint8_t current_selection = 0;
uint8_t current_selection = 1;
void loop(void) {
@@ -145,11 +145,19 @@ void loop(void) {
current_selection,
string_list);
u8g2.userInterfaceMessage(
"Selection:",
u8x8_GetStringLineStart(current_selection, string_list ),
"",
" ok \n cancel ");
if ( current_selection == 0 ) {
u8g2.userInterfaceMessage(
"Nothing selected.",
"",
"",
" ok ");
} else {
u8g2.userInterfaceMessage(
"Selection:",
u8x8_GetStringLineStart(current_selection-1, string_list ),
"",
" ok \n cancel ");
}
}
+7
View File
@@ -91,6 +91,13 @@
void setup(void)
{
// DOGS102 Shield (http://shieldlist.org/controlconnection/dogs102)
// u8x8.begin(/* menu_select_pin= */ 5, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 2, /* menu_up_pin= */ U8X8_PIN_NONE, /* menu_down_pin= */ U8X8_PIN_NONE, /* menu_home_pin= */ 3);
// DOGM128 Shield (http://shieldlist.org/schmelle2/dogm128) + DOGXL160 Shield
//u8x8.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 3, /* menu_prev_pin= */ 7, /* menu_up_pin= */ U8X8_PIN_NONE, /* menu_down_pin= */ U8X8_PIN_NONE, /* menu_home_pin= */ 8);
// Arduboy
//u8x8.begin(/*Select=*/ A0, /*Right/Next=*/ 5, /*Left/Prev=*/ 9, /*Up=*/ 8, /*Down=*/ 10, /*Home/Cancel=*/ A1); // Arduboy DevKit
u8x8.begin(/*Select=*/ 7, /*Right/Next=*/ A1, /*Left/Prev=*/ A2, /*Up=*/ A0, /*Down=*/ A3, /*Home/Cancel=*/ 8); // Arduboy 10 (Production)
}
+2 -2
View File
@@ -66,8 +66,8 @@ https://github.com/olikraus/u8g2 ChangeLog
* Speed improvement (issue 96)
2016-12-12 v2.8.5 olikraus@gmail.com
* Bugfix for issue 96 (issue 106)
2016-12-18 v2.9.0 olikraus@gmail.com
2016-12-20 v2.9.1 olikraus@gmail.com
* Speed improvement for AVR/KS0108 (issue 104)
* Support for UC1604 (issue 111)
* Support for PCD8544/Nokia Display (issue 107)
* Change/fixed behavior of userInterfaceSelectionList (issue 112)
+1 -1
View File
@@ -1,5 +1,5 @@
name=U8g2
version=2.9.0
version=2.9.1
author=oliver <olikraus@gmail.com>
maintainer=oliver <olikraus@gmail.com>
sentence=Library for monochrome LCDs and OLEDs. Supported controller: SSD1306, SSD1322, SSD1325, SH1106, T6963, RA8835, PCD8544, UC1604, UC1608, UC1610, UC1611, UC1701, ST7565, ST7920, LD7032, KS0108.
+8 -4
View File
@@ -191,9 +191,9 @@ void u8g2_DrawSelectionList(u8g2_t *u8g2, u8sl_t *u8sl, u8g2_uint_t y, const cha
/*
title: NULL for no title, valid str for title line. Can contain mutliple lines, separated by '\n'
start_pos: default position for the cursor
start_pos: default position for the cursor, first line is 1.
sl: string list (list of strings separated by \n)
returns start_pos if user has pressed the home key
returns 0 if user has pressed the home key
returns the selected line if user has pressed the select key
side effects:
u8g2_SetFontDirection(u8g2, 0);
@@ -212,6 +212,10 @@ uint8_t u8g2_UserInterfaceSelectionList(u8g2_t *u8g2, const char *title, uint8_t
uint8_t title_lines = u8x8_GetStringLineCnt(title);
uint8_t display_lines;
if ( start_pos > 0 ) /* issue 112 */
start_pos--; /* issue 112 */
if ( title_lines > 0 )
{
@@ -262,9 +266,9 @@ uint8_t u8g2_UserInterfaceSelectionList(u8g2_t *u8g2, const char *title, uint8_t
{
event = u8x8_GetMenuEvent(u8g2_GetU8x8(u8g2));
if ( event == U8X8_MSG_GPIO_MENU_SELECT )
return u8sl.current_pos;
return u8sl.current_pos+1; /* +1, issue 112 */
else if ( event == U8X8_MSG_GPIO_MENU_HOME )
return start_pos;
return 0; /* issue 112: return 0 instead of start_pos */
else if ( event == U8X8_MSG_GPIO_MENU_NEXT || event == U8X8_MSG_GPIO_MENU_DOWN )
{
u8sl_Next(&u8sl);