Помогите разобраться с библиотекой LCDMenuLib

dimontau
Offline
Зарегистрирован: 17.02.2016

Помогите разобраться с библиотекой 

LCDMenuLib  https://github.com/Jomelo/LCDMenuLib

не могу разобраться как сделать выход из меню

dimontau
Offline
Зарегистрирован: 17.02.2016

Плата arduino Due

Дисплей st7920

ЕвгенийП
ЕвгенийП аватар
Offline
Зарегистрирован: 25.05.2015

dimontau пишет:

не могу разобраться как сделать выход из меню

Это не вопрос, а утверждение и ответить на него невозможно. Вот как бы Вы сами ответили? Ну, не может человек, ну, "принято к сведению". Или Вы думаете, тут сейчас полноценные курсы пользования библиотекой откроются?

Если хотите помощи, то поступите так:

1. Опубликуйте пример, который Вы пробовали и напишите

2. Хочу сделать так, а работает эдак, подскажите как победить.

В таком виде, Вам, возможно, помогут.

dimontau
Offline
Зарегистрирован: 17.02.2016

Здесь проект.(пока очень сырой)

https://cloud.mail.ru/public/29TE/nieSx3dBH

Так вот, как зайти в меню разобрался. Когда выхожу из меню и пытаюсь снова зайти в меню энкодер перестает работать. При входе в меню стартует не главная страница, а вложеное подменю. И проблемма с отоброжением русских шрифтов

dimontau
Offline
Зарегистрирован: 17.02.2016

Сделал управление твердотопливным котлом. Было с дисплеем 2004, все работае отлично ( меню было на другой библиотеке). Сейчас хочу сделать по симпатичней, с графическим дисплеем. Завис с этой библиотекой. Кстати попутно проблема с русскими шрифтами. Если редактирую что то в скетче, то после загрузки в ардуину эти шрифты не выбодятся, но если сохранить скетч, снова открыть и тутже загрузить в ардуину, то все шрифты отображаются нормально.

ЕвгенийП
ЕвгенийП аватар
Offline
Зарегистрирован: 25.05.2015

Да, не, ну Вы скетч здесь публикуйте (только правильно). Ну подумйте сами, кто полезет что-то скачивать, устанавливать.

dimontau
Offline
Зарегистрирован: 17.02.2016

скетч состоит из пяти файлов

dimontau
Offline
Зарегистрирован: 17.02.2016

вот основной сетч

// include libs
#include <LCDMenuLib.h>
#include <U8glib.h>
#include <rus5x7.h>
#include <rus6x10.h>
#include <rus6x13.h>
// lib config
#define _LCDML_DISP_cfg_button_press_time          200    // button press time in ms
#define u8g_logo_height 24
// *********************************************************************
// U8GLIB
// *********************************************************************
// setup u8g object, please remove comment from one of the following constructor calls
// IMPORTANT NOTE: The following list is incomplete. The complete list of supported
// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device
//U8GLIB_ST7920_128X64 u8g(51, 49, 47,45);
U8GLIB_ST7920_128X64_4X u8g(28, 30, 32, 34, 36, 38, 40, 42, 26, 22, 24);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, rs=17,rw=16

// settings for u8g lib and lcd
#define _LCDML_DISP_w                 128            // lcd width
#define _LCDML_DISP_h                 64             // lcd height
// font settings
#define _LCDML_DISP_font              rus6x13  // u8glib font (more fonts under u8g.h line 1520 ...)
#define _LCDML_DISP_font_w            6              // font width
#define _LCDML_DISP_font_h            13             // font heigt  
// cursor settings
#define _LCDML_DISP_cursor_char       ">"            // cursor char
#define _LCDML_DISP_cur_space_before  2              // cursor space between
#define _LCDML_DISP_cur_space_behind  4              // cursor space between  
// menu position and size
#define _LCDML_DISP_box_x0            0              // start point (x0, y0)
#define _LCDML_DISP_box_y0            0              // start point (x0, y0)
#define _LCDML_DISP_box_x1            128            // width x  (x0 + width)
#define _LCDML_DISP_box_y1            64             // hight y  (y0 + height)
#define _LCDML_DISP_draw_frame        1              // draw a box around the menu
// scrollbar width
#define _LCDML_DISP_scrollbar_w       6  // scrollbar width (if this value is < 3, the scrollbar is disabled)    

// nothing change here
#define _LCDML_DISP_cols_max          ((_LCDML_DISP_box_x1-_LCDML_DISP_box_x0)/_LCDML_DISP_font_w)
#define _LCDML_DISP_rows_max          ((_LCDML_DISP_box_y1-_LCDML_DISP_box_y0-((_LCDML_DISP_box_y1-_LCDML_DISP_box_y0)/_LCDML_DISP_font_h))/_LCDML_DISP_font_h)

// rows and cols
// when you use more rows or cols as allowed change in LCDMenuLib.h the define "_LCDML_DISP_cfg_max_rows" and "_LCDML_DISP_cfg_max_string_length"
// the program needs more ram with this changes
#define _LCDML_DISP_rows              _LCDML_DISP_rows_max  // max rows 
#define _LCDML_DISP_cols              20                   // max cols

static unsigned char u8g_logo_bits[] U8G_PROGMEM = {
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x80,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80,
  0x21, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x84, 0x90,
  0x71, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x01, 0x00, 0xC0, 0x06, 0x00, 0x00, 0xC8, 0x89,
  0x59, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0x08, 0x00, 0x00, 0x30, 0x86,
  0x51, 0x00, 0x00, 0x04, 0x51, 0x00, 0x00, 0x08, 0x01, 0x00, 0x18, 0x30, 0x00, 0x00, 0x10, 0x84,
  0x59, 0x00, 0x00, 0x0A, 0x59, 0x00, 0x00, 0x14, 0x01, 0x00, 0x04, 0x40, 0x00, 0x00, 0x08, 0x88,
  0x51, 0x00, 0x00, 0x04, 0x51, 0x00, 0x00, 0x08, 0x01, 0x00, 0x03, 0x80, 0x01, 0x00, 0x0E, 0xB8,
  0x59, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x02, 0x00, 0x08, 0x88,
  0x51, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x01, 0x60, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x84,
  0x59, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x01, 0xF0, 0xFF, 0xFF, 0x1F, 0x00, 0x30, 0x86,
  0x71, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0xC8, 0x89,
  0x79, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x84, 0x90,
  0x71, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0xB1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x80, 0x80,
  0x79, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0xA1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x71, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0xB1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x71, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0xA1, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x81,
  0x71, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0xB1, 0x00, 0x00, 0x50, 0x01, 0x00, 0x80, 0x82,
  0xF9, 0x00, 0x00, 0x00, 0xF9, 0x00, 0x00, 0x00, 0xA1, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x81,
  0xFD, 0x01, 0x00, 0x00, 0xFD, 0x01, 0x00, 0x00, 0xB1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0xFD, 0x01, 0x00, 0x00, 0xFD, 0x01, 0x00, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0xFD, 0x01, 0x00, 0x00, 0xFD, 0x01, 0x00, 0x00, 0xF1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0xF9, 0x00, 0x00, 0x00, 0xF9, 0x00, 0x00, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x71, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0xF1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xF1, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xF9, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xF9, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xF9, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xF1, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};
void draw(void) {
  // graphic commands to redraw the complete screen should be placed here
  u8g.drawXBMP( 0, 0, 128, 64, u8g_logo_bits);
}

// *********************************************************************
// LCDML MENU/DISP
// *********************************************************************
// create menu
// menu element count - last element id
// this value must be the same as the last menu element
#define _LCDML_DISP_cnt    18

// LCDML_root        => layer 0
// LCDML_root_X      => layer 1
// LCDML_root_X_X    => layer 2
// LCDML_root_X_X_X  => layer 3
// LCDML_root_... 	 => layer ...

// LCDMenuLib_add(id, group, prev_layer_element, new_element_num, lang_char_array, callback_function)
LCDML_DISP_init(_LCDML_DISP_cnt);
LCDML_DISP_add      (0  , _LCDML_G1  , LCDML_root      , 1  , "Tемпературa"              , LCDML_FUNC);
LCDML_DISP_add      (1  , _LCDML_G1  , LCDML_root      , 2  , "Fan set"                  , LCDML_FUNC);
LCDML_DISP_add      (2  , _LCDML_G1  , LCDML_root      , 3  , "Clear Boiler set"         , LCDML_FUNC);
LCDML_DISP_add      (3  , _LCDML_G1  , LCDML_root     , 4  , "Clock set"                , LCDML_FUNC);
LCDML_DISP_add      (4 , _LCDML_G1  , LCDML_root      , 5  , "Exit"                     , LCDML_FUNC_to_exit);
LCDML_DISP_add      (5  , _LCDML_G1  , LCDML_root_1    , 1  , "Water max temp"           , LCDML_FUNC);
LCDML_DISP_add      (6  , _LCDML_G1  , LCDML_root_1    , 2  , "Water min temp"           , LCDML_FUNC);
LCDML_DISP_add      (7  , _LCDML_G1  , LCDML_root_1    , 3  , "Home temp"                , LCDML_FUNC);
LCDML_DISP_add      (8 , _LCDML_G1  , LCDML_root_1     , 4  , "Back"                     , LCDML_FUNC_to_back);
LCDML_DISP_add      (9  , _LCDML_G1  , LCDML_root_2    , 1  , "Fan max speed"            , LCDML_FUNC);
LCDML_DISP_add      (10  , _LCDML_G1  , LCDML_root_2    , 2  , "Fan min speed"            , LCDML_FUNC);
LCDML_DISP_add      (11 , _LCDML_G1  , LCDML_root_2     , 3  , "Back"                     , LCDML_FUNC_to_back);
LCDML_DISP_add      (12  , _LCDML_G1  , LCDML_root_3   , 1  , "Time clear"               , LCDML_FUNC);
LCDML_DISP_add      (13 , _LCDML_G1  , LCDML_root_3    , 2  , "Timer clear"              , LCDML_FUNC);
LCDML_DISP_add      (14 , _LCDML_G1  , LCDML_root_3    , 3  , "Back"                     , LCDML_FUNC_to_back);
LCDML_DISP_add      (15 , _LCDML_G1  , LCDML_root_4    , 1  , "Hour"                     , LCDML_FUNC);
LCDML_DISP_add      (16 , _LCDML_G1  , LCDML_root_4    , 2  , "Minute"                   , LCDML_FUNC);
LCDML_DISP_add      (17 , _LCDML_G1  , LCDML_root_4    , 3  , "Second"                   , LCDML_FUNC);
LCDML_DISP_add      (18 , _LCDML_G1  , LCDML_root_4    , 4  , "Back"                     , LCDML_FUNC_to_back);
LCDML_DISP_createMenu(_LCDML_DISP_cnt);



// *********************************************************************
// LCDML BACKEND (core of the menu, do not change here anything yet)
// *********************************************************************
// define backend function
#define _LCDML_BACK_cnt    1  // last backend function id

LCDML_BACK_init(_LCDML_BACK_cnt);
LCDML_BACK_new_timebased_dynamic (0  , ( 20UL )         , _LCDML_start  , LCDML_BACKEND_control);
LCDML_BACK_new_timebased_dynamic (1  , ( 10000000UL )   , _LCDML_stop   , LCDML_BACKEND_menu);
LCDML_BACK_create();
// *********************************************************************
//                              Переменные
// *********************************************************************
int t_water = 0;
int t_max = 0;
int t_min = 0;
int t_dalas1 = 0;
int t_dalas2 = 0;
int t_dalas3 = 0;
int t_dalas4 = 0;
int t_podacha = 0;
int t_obrat = 0;
int t_out = 0;
int t_in = 0;
int fan_max = 0;
int fan_min = 0;
int time_clear = 0;
int timemer_clear = 0;
int hours = 0;
int minute = 0;
int seconds = 0;
int botton=0;
int var=0;
// Used for generating interrupts using CLK signal
const int PinA = 35; 

// Used for reading DT signal
const int PinB = 37;  

// Used for the push button switch
const int PinSW = 39;  

// Keep track of last rotary value
int lastCount = 100;

// Updated by the ISR (Interrupt Service Routine)
volatile int virtualPosition = 100;
// ------------------------------------------------------------------
// INTERRUPT     INTERRUPT     INTERRUPT     INTERRUPT     INTERRUPT 
// ------------------------------------------------------------------
void isr ()  {
  static unsigned long lastInterruptTime = 0;
  unsigned long interruptTime = millis();

  // If interrupts come faster than 5ms, assume it's a bounce and ignore
  if (interruptTime - lastInterruptTime > 5) {
    if (digitalRead(PinB) == LOW)
    {
      virtualPosition-- ; // Could be -5 or -10
    }
    else {
      virtualPosition++ ; // Could be +5 or +10
    }

    // Restrict value from 0 to +100
    virtualPosition = min(200, max(100, virtualPosition));

    // Keep track of when we were here last (no more than every 5ms)
    lastInterruptTime = interruptTime;
  }
}
// *********************************************************************
// SETUP
// *********************************************************************
void setup()
{
  pinMode(12, OUTPUT);
  digitalWrite(12, HIGH);
  volatile int virtualPosition = 100;
  // serial init; only be needed if serial control is used
  while (!Serial);                   // wait until serial ready
  Serial.begin(115200);                // start serial
  Serial.println(F(_LCDML_VERSION)); // only for examples
  LCDML_DISP_groupEnable(_LCDML_G1); // enable group 1

  // LCDMenu Setup
  LCDML_setup(_LCDML_BACK_cnt);
  // Rotary pulses are INPUTs
  pinMode(PinA, INPUT);
  pinMode(PinB, INPUT);

  // Switch is floating so use the in-built PULLUP so we don't need a resistor
  pinMode(PinSW, INPUT_PULLUP);

  // Attach the routine to service the interrupts
  attachInterrupt(digitalPinToInterrupt(PinA), isr, LOW);
  // Enable all items with _LCDML_G1
  
}

// *********************************************************************
// LOOP
// *********************************************************************
void loop()
{
 
// Is someone pressing the rotary switch?
 /* if ((!digitalRead(PinSW))) {
    //virtualPosition = 100;
    while (!digitalRead(PinSW))
      delay(10);
    Serial.println("Reset");
  }
*/
  // If the current rotary switch position has changed then update everything
  if (virtualPosition != lastCount) {    
       Serial.print(virtualPosition > lastCount ? "Up  :" : "Down:");
       Serial.println(virtualPosition);
       Serial.println(botton);
       Serial.println(var);

    // Keep track of this new value
    lastCount = virtualPosition ;
  }
  
 
if (virtualPosition==101){
  // put your main code here, to run repeatedly:
  u8g.firstPage();
  do {
    u8g.setColorIndex(1);
    draw();
    u8g.setFont(rus5x7);
    u8g.drawStr(4, 48, "Выход");
    u8g.drawStr(38, 48, "Вход");
    u8g.setFont(rus6x10);
    u8g.drawStr(2, 11, "Режим: Стандарт");
    u8g.drawStr(95, 11, "23:45");
    u8g.setFont(rus6x13);
    u8g.drawStr(13, 32, "78");
    u8g.drawStr(46, 32, "58");
    u8g.drawStr(80, 44, "23");
    u8g.drawStr(102, 44, "-26");
    u8g.drawStr(66, 61, "СТАРТ");
    u8g.drawStr(101, 61, "МЕНЮ");
    u8g.drawStr(3, 61, "Работа");
 } while( u8g.nextPage() );
}
 
    if (virtualPosition==102) {
  u8g.firstPage();  
  do {
    u8g.setColorIndex(1);
     draw();
    u8g.setFont(rus5x7);
    u8g.drawStr(4, 48, "Выход");
    u8g.drawStr(38, 48, "Вход");
    u8g.setFont(rus6x10);
    u8g.drawStr(2, 11, "Режим: Стандарт");
    u8g.drawStr(95, 11, "23:45");
    u8g.setFont(rus6x13);
    u8g.drawStr(13, 32, "78");
    u8g.drawStr(46, 32, "58");
    u8g.drawStr(80, 44, "23");
    u8g.drawStr(102, 44, "-26");
    u8g.drawStr(66, 61, "СТАРТ");
    u8g.drawStr(101, 61, "МЕНЮ");
    u8g.drawStr(3, 61, "Работа");
   
    u8g.drawBox(65, 50, 31, 13);
    u8g.setColorIndex(0);
    u8g.drawStr(66, 61, "СТАРТ"); 
  } while( u8g.nextPage() );
  }
  if (virtualPosition ==103) {
  u8g.firstPage();  
  do {
    u8g.setColorIndex(1);
     draw();
    u8g.setFont(rus5x7);
    u8g.drawStr(4, 48, "Выход");
    u8g.drawStr(38, 48, "Вход");
    u8g.setFont(rus6x10);
    u8g.drawStr(2, 11, "Режим: Стандарт");
    u8g.drawStr(95, 11, "23:45");
    u8g.setFont(rus6x13);
    u8g.drawStr(13, 32, "78");
    u8g.drawStr(46, 32, "58");
    u8g.drawStr(80, 44, "23");
    u8g.drawStr(102, 44, "-26");
    u8g.drawStr(66, 61, "СТАРТ");
    u8g.drawStr(101, 61, "МЕНЮ");
    u8g.drawStr(3, 61, "Работа");   
    u8g.drawBox(97, 50, 31, 13);
    u8g.setColorIndex(0);
    u8g.drawStr(101, 61, "МЕНЮ"); 
  } while( u8g.nextPage() );
if ((!digitalRead(PinSW))) {
  detachInterrupt(35);  
  delay(10);
   while (!digitalRead(PinSW))    
         botton=1;
       virtualPosition=106;
      // _LCDML_DISP_cnt;
      // LCDML.goRoot();
    }
  }
  
  if(virtualPosition==104){
    virtualPosition=101;
  }
  if(virtualPosition==100){
    virtualPosition=103;
  }
 if (virtualPosition==106 && botton==1&& var==0) {
 
      LCDML_run(_LCDML_priority);
            
     }
    if (virtualPosition==106 && botton==1&& var==1) {
 
     LCDML.goRoot();
      
     }
 
  }
  

  
  // this function must called here, do not delete it
  



// *********************************************************************
// check some errors - do not change here anything
// *********************************************************************
# if(_LCDML_DISP_rows > _LCDML_DISP_cfg_max_rows)
# error change value of _LCDML_DISP_cfg_max_rows in LCDMenuLib.h
# endif

# if(_LCDML_DISP_cols > _LCDML_DISP_cfg_max_string_length)
# error change value of _LCDML_DISP_cfg_max_string_length in LCDMenuLib.h
# endif

# if(_LCDML_glcd_tft_box_x1 > _LCDML_glcd_tft_w)
# error _LCDML_glcd_tft_box_x1 is to big
# endif

# if(_LCDML_glcd_tft_box_y1 > _LCDML_glcd_tft_h)
# error _LCDML_glcd_tft_box_y1 is to big
# endif

Вот работа подменю

функция exit должна делать выход из меню

/* ===================================================================== *
 *                                                                       *
 * DISPLAY SYSTEM                                                        *
 *                                                                       *
 * ===================================================================== *
 * every "disp menu function" needs three functions 
 * - void LCDML_DISP_setup(func_name)    
 * - void LCDML_DISP_loop(func_name)     
 * - void LCDML_DISP_loop_end(func_name)
 *
 * EXAMPLE CODE:
    void LCDML_DISP_setup(..menu_func_name..) 
    {
      // setup
      // is called only if it is started

      // starts a trigger event for the loop function every 100 millisecounds
      LCDML_DISP_triggerMenu(100);  
    }
    
    void LCDML_DISP_loop(..menu_func_name..)
    { 
      // loop
      // is called when it is triggert
      // - with LCDML_DISP_triggerMenu( millisecounds ) 
      // - with every button status change

      // check if any button is presed (enter, up, down, left, right)
      if(LCDML_BUTTON_checkAny()) {         
        LCDML_DISP_funcend();
      } 
    }
    
    void LCDML_DISP_loop_end(..menu_func_name..)
    {
      // loop end
      // this functions is ever called when a DISP function is quit
      // you can here reset some global vars or do nothing  
    } 
 * ===================================================================== * 
 */

// *********************************************************************
void LCDML_DISP_setup(LCDML_FUNC_information)
// *********************************************************************
{
  // setup function
  u8g.setFont(_LCDML_DISP_font);
  u8g.firstPage();  
  do {
    u8g.drawStr( 0, 13, F("To close this"));
    u8g.drawStr( 0, 26, F("function press"));
    u8g.drawStr( 0, 39, F("any button or use"));
    u8g.drawStr( 0, 52, F("back button"));
  } while( u8g.nextPage() );
}

void LCDML_DISP_loop(LCDML_FUNC_information) 
{
  // loop function, can be run in a loop when LCDML_DISP_triggerMenu(xx) is set
  // the quit button works in every DISP function without any checks; it starts the loop_end function   
  if(LCDML_BUTTON_checkAny()) { // check if any button is presed (enter, up, down, left, right)
    // LCDML_DISP_funcend calls the loop_end function
    LCDML_DISP_funcend();
  } 
}

void LCDML_DISP_loop_end(LCDML_FUNC_information)
{
  // this functions is ever called when a DISP function is quit
  // you can here reset some global vars or do nothing    
}  


// *********************************************************************
uint8_t g_func_timer_info = 0;  // time counter (global variable)
unsigned long g_timer_1 = 0;    // timer variable (globale variable)
void LCDML_DISP_setup(LCDML_FUNC_timer_info)
// *********************************************************************
{
  // setup function
  char buf[20];
  sprintf (buf, "wait %d secounds", 10);
  
  u8g.setFont(_LCDML_DISP_font);
  u8g.firstPage();  
  do {
    u8g.drawStr( 0, 13, buf);
    u8g.drawStr( 0, 26, F("or press back button"));
  } while( u8g.nextPage() );

     
  g_func_timer_info = 10;       // reset and set timer    
  LCDML_DISP_triggerMenu(100);  // starts a trigger event for the loop function every 100 millisecounds
}

void LCDML_DISP_loop(LCDML_FUNC_timer_info)
{ 
  // loop function, can be run in a loop when LCDML_DISP_triggerMenu(xx) is set
  // the quit button works in every DISP function without any checks; it starts the loop_end function 
  
  // this function is called every 100 millisecounds
  
  // this timer checks every 1000 millisecounds if it is called
  if((millis() - g_timer_1) >= 1000) {
    g_timer_1 = millis();   
    g_func_timer_info--;                // increment the value every secound
    char buf[20];
    sprintf (buf, "wait %d secounds", g_func_timer_info);
    
    u8g.setFont(_LCDML_DISP_font);
    u8g.firstPage();  
    do {
      u8g.drawStr( 0, 13, buf);
      u8g.drawStr( 0, 26, F("or press back button"));
    } while( u8g.nextPage() );   
  }
  
  // reset the initscreen timer
  LCDML_DISP_resetIsTimer();
  
  // this function can only be ended when quit button is pressed or the time is over
  // check if the function ends normaly
  if (g_func_timer_info <= 0)
  {
    // end function for callback
    LCDML_DISP_funcend();  
  }   
}

void LCDML_DISP_loop_end(LCDML_FUNC_timer_info) 
{
  // this functions is ever called when a DISP function is quit
  // you can here reset some global vars or do nothing
}


// *********************************************************************
void LCDML_DISP_setup(LCDML_FUNC_to_back)
// *********************************************************************
{
  LCDML.goRoot();
}

void LCDML_DISP_loop(LCDML_FUNC_to_back)
{
}

void LCDML_DISP_loop_end(LCDML_FUNC_to_back)
{
  // this functions is ever called when a DISP function is quit
  // you can here reset some global vars or do nothing
}
void LCDML_DISP_setup(LCDML_FUNC_to_exit)
// *********************************************************************
{
//LCDML.display();
//botton=0;
virtualPosition=101;
var=1;
attachInterrupt(digitalPinToInterrupt(PinA), isr, LOW);
}

void LCDML_DISP_loop(LCDML_FUNC_to_exit)
{
 // loop();
}

void LCDML_DISP_loop_end(LCDML_FUNC_to_exit)
{
  // this functions is ever called when a DISP function is quit
  // you can here reset some global vars or do nothing
}

 

b707
Offline
Зарегистрирован: 26.05.2017

очень сильно сомневаюсь, что кто-то захочет копаться в 600 строках кода, когда вы сами не в состоянии ясно обьяснить, что именно не работает. Тем более что библиотека, судя по всему, написана любителем усложнять простые вещи до неузнаваемости - у нас тут тоже есть такой.

Единственная ваша надежда. что найдется человек, уже разобравшийся с этой библиотекой...

dimontau
Offline
Зарегистрирован: 17.02.2016

так и интересуюсь. может кто сталкивался с этой библиотекой

ЕвгенийП
ЕвгенийП аватар
Offline
Зарегистрирован: 25.05.2015

А Вы примеры к библиотеке пробовали? Они не из 5-ти файлов - намного компактнее. Выделите проблему в обозримом по размеру примере. (пока всё это делаете - сами и решите всё, собственно так мы и работаем :)))