#include <Arduino.h>
#include <U8g2lib.h>
#include <MUIU8g2.h>
#include <Versatile_RotaryEncoder.h>
// Buttons
#define BUTT_L 12 // timer
#define BUTT_R 14 // tare
// Set encoder reading pins
#define ENC_A 34
#define ENC_B 35
#define ENC_BUTT 32
// Create encoder object
Versatile_RotaryEncoder versatile_encoder(ENC_A, ENC_B, ENC_BUTT);
// U8g2 Contructor
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
// Create MUI object
MUIU8G2 mui;
static const unsigned char image_Ok_btn_pressed_bits[] = {0xf8,0x03,0xfc,0x07,0x0e,0x0e,0xf7,0x1d,0xfb,0x1b,0xfb,0x1b,0xfb,0x1b,0xfb,0x1b,0xfb,0x1b,0xf7,0x1d,0x0e,0x0e,0xfc,0x07,0xf8,0x03};
static const unsigned char image_Percent_bits[] = {0x0c,0x03,0x1e,0x03,0x33,0x03,0xb3,0x03,0xde,0x01,0xec,0x00,0x70,0x00,0x38,0x00,0xdc,0x00,0xee,0x01,0x37,0x03,0x33,0x03,0xe3,0x01,0xc3,0x00};
static const unsigned char image_ArrowUpEmpty_bits[] = {0xc0,0x00,0x20,0x01,0x10,0x02,0x08,0x04,0x04,0x08,0x02,0x10,0x01,0x20,0x0f,0x3c,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0xf8,0x07};
static const unsigned char image_clock_quarters_bits[] = {0xe0,0x03,0x98,0x0c,0x84,0x10,0x02,0x20,0x82,0x20,0x81,0x40,0x81,0x40,0x87,0x70,0x01,0x41,0x01,0x42,0x02,0x20,0x02,0x20,0x84,0x10,0x98,0x0c,0xe0,0x03,0x00,0x00};
// '981def6784c549119025c0432ef3a543', 128x64px
const unsigned char coffe_man_bitmap[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0xa4, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x67, 0x6f, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x3c, 0xd9, 0xba, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x21, 0x44, 0x44, 0x82, 0x37, 0xfb, 0xb7, 0xdd, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x11, 0x00, 0x00, 0x00, 0x20, 0xe5, 0xcb, 0xfc, 0xd7, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x21, 0x22, 0x60, 0x6f, 0x36, 0xd3, 0x76, 0xfb, 0x03, 0x80, 0x10, 0x02, 0x00,
0x40, 0x80, 0x00, 0x00, 0x00, 0x82, 0xc9, 0xd4, 0xb6, 0xbd, 0x6d, 0x03, 0x21, 0x00, 0x20, 0x00,
0x01, 0x04, 0x40, 0x08, 0x11, 0x98, 0x90, 0xcd, 0x6e, 0xeb, 0xfe, 0x0d, 0x00, 0x00, 0x00, 0x00,
0x10, 0x40, 0x08, 0x00, 0x80, 0x60, 0x26, 0x29, 0xdb, 0x4e, 0xdb, 0x1b, 0x00, 0x40, 0x00, 0x04,
0x00, 0x01, 0x02, 0x42, 0x08, 0x08, 0x60, 0xb2, 0xfd, 0x76, 0xed, 0x27, 0x00, 0x02, 0x04, 0x00,
0x04, 0x10, 0x40, 0x10, 0x42, 0x24, 0x89, 0xc6, 0xb6, 0xb7, 0xb5, 0x3f, 0x08, 0x20, 0x00, 0x00,
0x41, 0x00, 0x01, 0x04, 0x00, 0x24, 0xc8, 0x5c, 0x6e, 0xdd, 0xd6, 0x5e, 0x80, 0x00, 0x40, 0x40,
0x00, 0x04, 0x10, 0x80, 0x10, 0x12, 0x10, 0xb1, 0xd9, 0xdf, 0xdb, 0xdf, 0x00, 0x08, 0x10, 0x00,
0x20, 0x40, 0x80, 0x20, 0x04, 0x01, 0x40, 0x66, 0xb6, 0x3a, 0x2b, 0xff, 0x06, 0x80, 0x00, 0x04,
0x08, 0x02, 0x04, 0x04, 0x40, 0x08, 0x48, 0xc8, 0xed, 0xe6, 0xe6, 0x7c, 0x86, 0x00, 0x08, 0x00,
0x02, 0x20, 0x40, 0x00, 0x11, 0x20, 0x80, 0x1c, 0x90, 0xcd, 0xdc, 0xdb, 0x01, 0x08, 0x02, 0x02,
0x00, 0x01, 0x02, 0x48, 0x04, 0x01, 0x80, 0xf6, 0x73, 0x3a, 0x1b, 0x7b, 0x06, 0x80, 0x80, 0x40,
0x40, 0x10, 0x20, 0x02, 0x40, 0x12, 0x00, 0xa0, 0xcd, 0xbb, 0xe9, 0x6e, 0x06, 0x21, 0x20, 0x00,
0x10, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x19, 0x0d, 0xe6, 0xe6, 0x32, 0x0c, 0x08, 0x00, 0x00,
0x04, 0x08, 0x10, 0x90, 0x10, 0x44, 0x00, 0xd0, 0xe0, 0xcc, 0x9e, 0x3d, 0x09, 0x02, 0x04, 0x04,
0x01, 0x02, 0x00, 0x01, 0x40, 0x10, 0xa0, 0x96, 0x86, 0xb9, 0x5b, 0x67, 0x0b, 0x80, 0x80, 0x20,
0x80, 0x40, 0x08, 0x08, 0x02, 0x00, 0xbc, 0x2f, 0x1c, 0xa0, 0x5d, 0x9b, 0x03, 0x10, 0x08, 0x00,
0x20, 0x00, 0x80, 0x40, 0x88, 0x00, 0x10, 0x00, 0x18, 0x00, 0x60, 0xda, 0x86, 0x00, 0x01, 0x04,
0x08, 0x20, 0x02, 0x00, 0x21, 0x10, 0x02, 0x00, 0x70, 0x00, 0x88, 0x69, 0x02, 0x08, 0x40, 0x80,
0x00, 0x04, 0x20, 0x24, 0x00, 0x01, 0x00, 0x04, 0xf8, 0x21, 0x1b, 0x66, 0x0b, 0x00, 0x00, 0x20,
0x00, 0x01, 0x00, 0x00, 0x44, 0x40, 0x00, 0x00, 0xe8, 0x07, 0xf0, 0x96, 0xd8, 0x22, 0x10, 0x00,
0x40, 0x80, 0x10, 0x01, 0x11, 0x02, 0x40, 0x32, 0x64, 0x46, 0xa4, 0xf9, 0x51, 0xc9, 0x01, 0x04,
0x04, 0x00, 0x00, 0x48, 0x80, 0x20, 0x00, 0x00, 0xf8, 0xf9, 0x3f, 0x6b, 0x31, 0x4d, 0xbe, 0x01,
0x00, 0x10, 0x84, 0x00, 0x24, 0x00, 0x02, 0x08, 0xb0, 0x83, 0xd9, 0xec, 0x8c, 0x20, 0x22, 0x13,
0x00, 0x04, 0x00, 0x24, 0x01, 0x00, 0x00, 0x03, 0xe4, 0x1e, 0x00, 0xfc, 0xc2, 0xca, 0x20, 0xec,
0x20, 0x00, 0x21, 0x00, 0x00, 0x00, 0x11, 0x00, 0xc8, 0x13, 0x00, 0x5b, 0x12, 0x19, 0x29, 0x0b,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x44, 0x04, 0x00, 0x61, 0xa0, 0x7d, 0x6c, 0x22, 0x8c, 0x20,
0x00, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x11, 0x30, 0x6c, 0xa0, 0xb6, 0x25, 0x82, 0x90, 0x4c,
0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x12, 0x40, 0x02, 0x18, 0xa3, 0x9e, 0x90, 0x45, 0x33, 0x41,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x80, 0x8d, 0x85, 0x49, 0x26, 0x34, 0x86, 0x0c,
0x00, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0xe0, 0x5c, 0x2f, 0x53, 0x12, 0x30, 0x91,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x34, 0x02, 0x00, 0x9e, 0xcf, 0x62, 0x94, 0x41, 0x44, 0xc4,
0x40, 0x80, 0x08, 0x04, 0x00, 0x00, 0x40, 0x08, 0xc8, 0x30, 0xbb, 0x89, 0x09, 0x99, 0x11, 0x4c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x02, 0xf7, 0x3f, 0x30, 0x49, 0x32, 0x30, 0x02,
0x00, 0x00, 0x40, 0x82, 0x00, 0x00, 0x00, 0x22, 0xf9, 0xcc, 0x06, 0xcc, 0x44, 0x42, 0x86, 0x20,
0x00, 0x20, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xc8, 0x8c, 0xf3, 0xce, 0x04, 0x90, 0x0c, 0x49, 0x22,
0x00, 0x00, 0x30, 0x08, 0x00, 0x00, 0x00, 0x00, 0xd2, 0x96, 0x11, 0x00, 0x1b, 0x61, 0x42, 0x80,
0x00, 0x00, 0x20, 0x80, 0x01, 0x00, 0x00, 0x00, 0x12, 0x64, 0x12, 0x20, 0x4c, 0x05, 0x11, 0x96,
0x00, 0x02, 0x08, 0x25, 0x24, 0x00, 0x00, 0x00, 0x24, 0x2d, 0x82, 0x24, 0x13, 0x31, 0x89, 0x21,
0x00, 0x00, 0x50, 0x04, 0x91, 0x09, 0x00, 0x09, 0x00, 0x80, 0xac, 0xce, 0xc4, 0x84, 0x4c, 0x24,
0x00, 0x00, 0x08, 0x49, 0x44, 0xc0, 0xff, 0xff, 0xff, 0xd1, 0x2f, 0x92, 0x10, 0x23, 0x41, 0x10,
0x00, 0xfb, 0xff, 0x19, 0x42, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0xf0, 0x31, 0x0d, 0x48, 0x08, 0x82,
0xc0, 0x4f, 0xf0, 0x06, 0x0a, 0xfe, 0xff, 0xbf, 0xdd, 0xe6, 0xd8, 0x8f, 0xe0, 0xc4, 0x44, 0x30,
0x00, 0x1d, 0x00, 0x23, 0x10, 0xff, 0xdb, 0xf6, 0x37, 0xf9, 0x00, 0x7b, 0x86, 0x30, 0x12, 0x85,
0x00, 0xfc, 0x00, 0x20, 0x05, 0x3c, 0x02, 0x00, 0x80, 0x7d, 0x00, 0xf8, 0x99, 0x84, 0x10, 0x19,
0x00, 0x60, 0x07, 0x8c, 0x21, 0xc0, 0x7d, 0x4b, 0xfb, 0x5f, 0x00, 0xc0, 0x47, 0x02, 0x11, 0x80,
0x30, 0x0b, 0xcf, 0x2d, 0x00, 0x00, 0xd0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x9c, 0x30, 0x93, 0x04,
0x40, 0x00, 0x00, 0x80, 0xf8, 0x00, 0x82, 0xfc, 0xff, 0xb7, 0xfd, 0x03, 0x6c, 0x02, 0x81, 0x24,
0x00, 0xa4, 0x04, 0x10, 0x80, 0x4b, 0x28, 0xd3, 0x6e, 0xdf, 0x60, 0x9f, 0xe0, 0x34, 0x98, 0x08,
0x00, 0x00, 0x10, 0x30, 0x00, 0x08, 0x20, 0xdd, 0xfe, 0x4d, 0x00, 0xf4, 0x13, 0x84, 0x12, 0x33,
0xb0, 0x00, 0xdb, 0x20, 0x00, 0x20, 0x41, 0x64, 0xdb, 0x02, 0x00, 0x50, 0x5f, 0x50, 0x26, 0x04,
0xa0, 0x44, 0xc0, 0x83, 0x00, 0x40, 0x96, 0xb2, 0x6d, 0x82, 0x09, 0x00, 0x59, 0x06, 0xc8, 0x04,
0x00, 0x10, 0x00, 0x24, 0x04, 0x00, 0x90, 0x9a, 0x2d, 0x31, 0xfe, 0x03, 0x84, 0x88, 0x10, 0x33,
0x00, 0x01, 0x00, 0xe0, 0x01, 0x00, 0x24, 0x49, 0x12, 0x10, 0xb0, 0xff, 0x27, 0x62, 0xcc, 0x20,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xed, 0x06, 0x00, 0x00, 0x6c, 0x0b, 0x90, 0x21, 0x84,
0x00, 0x02, 0xa0, 0x89, 0x01, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x48, 0x81, 0x12, 0x00,
0x00, 0x00, 0x00, 0x36, 0x9f, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0x80, 0x40, 0x02, 0x1e, 0x00,
0x00, 0x84, 0x54, 0x40, 0xfe, 0x37, 0x01, 0xe6, 0xff, 0x09, 0xfe, 0xff, 0x03, 0x04, 0x60, 0x60
};
void drawBrewAssist(void) {
u8g2.drawLine(0, 8, 127, 8);
u8g2.drawLine(23, 55, 106, 55);
u8g2.drawFrame(107, 55, 21, 9);
u8g2.drawFrame(0, 55, 23, 9);
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(110, 62, "Tare");
u8g2.drawStr(1, 6, "Simple Scale");
u8g2.drawStr(2, 62, "Enter");
u8g2.drawStr(25, 18, "timer");
u8g2.drawStr(25, 37, "target");
u8g2.drawStr(88, 18, "mass");
u8g2.drawStr(88, 38, "flow");
u8g2.drawStr(108, 6, "12:25");
u8g2.setFont(u8g2_font_5x7_tr);
u8g2.drawStr(60, 63, "0%");
u8g2.setFont(u8g2_font_6x12_tr);
u8g2.drawStr(24, 28, "00:15");
u8g2.drawStr(26, 48, "300 g");
u8g2.drawStr(87, 28, "0.0 g");
u8g2.drawStr(87, 48, "0 g/s");
u8g2.drawXBM(72, 14, 13, 13, image_Ok_btn_pressed_bits);
u8g2.drawXBM(74, 34, 10, 14, image_Percent_bits);
u8g2.drawXBM(9, 33, 14, 15, image_ArrowUpEmpty_bits);
u8g2.drawXBM(8, 13, 15, 16, image_clock_quarters_bits);
}
void drawSplashScreenAnim(void) {
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
u8g2.drawXBM(0, 0, 128, 64, coffe_man_bitmap);
u8g2.sendBuffer();
delay(2000);
//u8g2.clearBuffer();
u8g2.drawBox(16, 18, 95, 30);
u8g2.setDrawColor(2);
u8g2.setFont(u8g2_font_t0_11b_tr);
u8g2.drawStr(33, 43, "Super Scale");
u8g2.drawStr(19, 30, "The Real Kawosz");
u8g2.drawFrame(17, 19, 93, 28);
u8g2.sendBuffer();
delay(2000);
}
/*
global variables which form the communication gateway between the user interface and the rest of the code
*/
// uint8_t num_value = 0;
// uint8_t bar_value = 0;
// uint16_t animal_idx = 0;
// /*
// list of animal names
// */
// const char *animals[] = { "Bird", "Bison", "Cat", "Crow", "Dog", "Elephant", "Fish", "Gnu", "Horse", "Koala", "Lion", "Mouse", "Owl", "Rabbit", "Spider", "Turtle", "Zebra" };
// uint16_t animal_name_list_get_cnt(void *data) {
// return sizeof(animals)/sizeof(*animals); /* number of animals */
// }
// const char *animal_name_list_get_str(void *data, uint16_t index) {
// return animals[index];
// }
uint16_t scale_mode_idx = 0;
const char *scale_modes[] = {"Simple", "Count", "Brew Assist", "Extraction", "Settings"};
uint16_t scale_modes_list_get_cnt(void *data) {
return sizeof(scale_modes)/sizeof(*scale_modes);
}
const char *scale_modes_list_get_str(void *data, uint16_t index) {
return scale_modes[index];
}
// uint8_t mui_hrule(mui_t *ui, uint8_t msg) {
// if ( msg == MUIF_MSG_DRAW ) {
// u8g2.drawHLine(0, mui_get_y(ui), u8g2.getDisplayWidth());
// }
// return 0;
// }
// uint8_t show_my_data(mui_t *ui, uint8_t msg) {
// if ( msg == MUIF_MSG_DRAW ) {
// u8g2_uint_t x = mui_get_x(ui);
// u8g2_uint_t y = mui_get_y(ui);
// u8g2.setCursor(x+5, y);
// u8g2.print("Num:");
// u8g2.setCursor(x+50, y);
// u8g2.print(num_value);
// u8g2.setCursor(x+5, y+12);
// u8g2.print("Bar:");
// u8g2.setCursor(x+50, y+12);
// u8g2.print(bar_value);
// u8g2.setCursor(x+5, y+24);
// u8g2.print("Animal:");
// u8g2.setCursor(x+50, y+24);
// u8g2.print(animal_idx);
// u8g2.print("=");
// u8g2.print(animals[animal_idx]);
// }
// return 0;
// }
muif_t muif_list[] = {
MUIF_U8G2_FONT_STYLE(0, u8g2_font_helvR08_tr), /* regular font */
MUIF_U8G2_FONT_STYLE(1, u8g2_font_helvB08_tr), /* bold font */
// MUIF_RO("HR", mui_hrule),
// MUIF_U8G2_LABEL(),
// MUIF_RO("GP",mui_u8g2_goto_data),
// MUIF_BUTTON("GC", mui_u8g2_goto_form_w1_pi),
// MUIF_U8G2_U8_MIN_MAX("NV", &num_value, 0, 99, mui_u8g2_u8_min_max_wm_mud_pi),
// MUIF_U8G2_U8_MIN_MAX_STEP("NB", &bar_value, 0, 16, 1, MUI_MMS_2X_BAR, mui_u8g2_u8_bar_wm_mud_pf),
// MUIF_U8G2_U16_LIST("NA", &animal_idx, NULL, animal_name_list_get_str, animal_name_list_get_cnt, mui_u8g2_u16_list_line_wa_mud_pi),
// /* register custom function to show the data */
// MUIF_RO("SH", show_my_data),
// /* a button for the menu... */
// //MUIF_BUTTON("GO", mui_u8g2_btn_goto_wm_fi)
// MUIF_EXECUTE_ON_SELECT_BUTTON("GO", mui_u8g2_btn_goto_wm_fi)
};
// fds_t fds_data[] =
// MUI_FORM(1)
// MUI_STYLE(1)
// MUI_LABEL(5, 8, "VersatileRotaryEncoder")
// MUI_STYLE(0)
// MUI_XY("HR", 0,11)
// MUI_DATA("GP",
// MUI_10 "Enter Data|"
// MUI_12 "Show Data")
// MUI_XYA("GC", 5, 24, 0)
// MUI_XYA("GC", 5, 36, 1)
// MUI_FORM(10)
// MUI_STYLE(1)
// MUI_LABEL(5, 8, "Enter Data")
// MUI_XY("HR", 0,11)
// MUI_STYLE(0)
// MUI_LABEL(5,23, "Num:")
// MUI_LABEL(5,36, "Bar:")
// MUI_LABEL(5,49, "Animal:")
// MUI_XY("NV", 50, 23)
// MUI_XY("NB", 50, 36)
// MUI_XYA("NA", 50, 49, 44)
// MUI_XYAT("GO", 114, 60, 1, " Ok ")
// MUI_FORM(12)
// MUI_STYLE(1)
// MUI_LABEL(5, 8, "Show Data")
// MUI_XY("HR", 0,11)
// MUI_STYLE(0)
// MUI_XY("SH", 0, 23)
// MUI_XYAT("GO", 114, 60, 1, " Ok ")
// ;
// global variables for menu redraw and input event handling
uint8_t is_redraw = 1;
uint8_t rotate_event = 0; // 0 = not turning, 1 = CW, 2 = CCW
uint8_t press_event = 0; // 0 = not pushed, 1 = pushed
uint8_t long_press_event = 0; // 0 = not pushed, 1 = pushed
void handle_events(void) {
// 0 = not pushed, 1 = pushed
if ( press_event == 1 ) {
mui.sendSelect();
is_redraw = 1;
press_event = 0;
}
// 0 = not pushed, 1 = pushed
if ( long_press_event == 1 ) {
mui.sendSelectWithExecuteOnSelectFieldSearch();
is_redraw = 1;
long_press_event = 0;
}
// 0 = not turning, 1 = CW, 2 = CCW
if ( rotate_event == 1 ) {
mui.nextField();
is_redraw = 1;
rotate_event = 0;
}
if ( rotate_event == 2 ) {
mui.prevField();
is_redraw = 1;
rotate_event = 0;
}
}
// Functions prototyping to be handled on each Encoder Event
void handleRotate(int8_t rotation) {
if ( rotation > 0 )
rotate_event = 2; // CW
else
rotate_event = 1; // CCW
}
void handlePressRelease() {
press_event = 1;
}
void handleLongPressRelease() {
long_press_event = 1;
}
void setup() {
pinMode(BUTT_L, INPUT_PULLUP);
pinMode(BUTT_R, INPUT_PULLUP);
// Load to the encoder all nedded handle functions here (up to 9 functions)
versatile_encoder.setHandleRotate(handleRotate);
versatile_encoder.setHandlePressRelease(handlePressRelease);
versatile_encoder.setHandleLongPressRelease(handleLongPressRelease);
u8g2.begin();
// mui.begin(u8g2, fds_data, muif_list, sizeof(muif_list)/sizeof(muif_t));
// mui.gotoForm(/* form_id= */ 1, /* initial_cursor_position= */ 0);
drawSplashScreenAnim();
}
void loop() {
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
drawBrewAssist();
u8g2.sendBuffer();
delay(1000);
}
// void loop(void) {
// /* check whether the menu is active */
// if ( mui.isFormActive() ) {
// /* update the display content, if the redraw flag is set */
// if ( is_redraw ) {
// u8g2.firstPage();
// do {
// versatile_encoder.ReadEncoder(); // Do the encoder reading and processing
// mui.draw();
// versatile_encoder.ReadEncoder(); // Do the encoder reading and processing
// } while( u8g2.nextPage() );
// is_redraw = 0; /* clear the redraw flag */
// }
// versatile_encoder.ReadEncoder(); // Do the encoder reading and processing
// handle_events();
// } else {
// /* the menu should never become inactive, but if so, then restart the menu system */
// mui.gotoForm(/* form_id= */ 1, /* initial_cursor_position= */ 0);
// }
// }