#include "U8glib.h"
//U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_FAST); // Pro skutecne zapojeni
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Pro simulaci
// U8GLIB_SSD1306_128X64 u8g(13, 11, 8, 9, 10); // SPI connection
// for SPI connection, use this wiring:
// GND > GND
// VCC > 5V
// SCL > 13
// SDA > 11
// RES > 10
// DC > 9
// CS > 8
// 'dino_splash', 128x64px
const unsigned char dino_splash [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00,
0x08, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x60, 0x00, 0x00, 0x00,
0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x00, 0x00, 0x00,
0x3f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00,
0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x00,
0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xff, 0xff, 0xfe, 0x00,
0x20, 0xfe, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xff, 0xff, 0xfe, 0x00,
0x21, 0x83, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xc1, 0x00, 0x06, 0x00,
0x23, 0x01, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0xc0, 0x80, 0x07, 0x00,
0x22, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0xc0, 0x7c, 0x07, 0x80,
0x23, 0x8c, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0f, 0xff, 0xcf, 0xff, 0xe0,
0x23, 0xac, 0x88, 0x00, 0x07, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x08, 0x0f, 0xff, 0xe7, 0xff, 0xe0,
0x22, 0x01, 0x88, 0x00, 0x07, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x08, 0x03, 0xe0, 0x7c, 0x0f, 0x80,
0x23, 0x07, 0x88, 0x00, 0x1e, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x08, 0x01, 0xc0, 0x10, 0x07, 0x00,
0x21, 0x57, 0x08, 0x00, 0x1e, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x08, 0x00, 0xc0, 0x00, 0x06, 0x00,
0x21, 0xfe, 0x08, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x06, 0x00,
0x20, 0x00, 0x08, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x06, 0x00,
0x20, 0x00, 0x08, 0x00, 0x1f, 0xff, 0xf8, 0x30, 0x00, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x06, 0x00,
0x20, 0x00, 0x08, 0x00, 0x1f, 0xff, 0xf8, 0x78, 0x00, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x06, 0x00,
0x3f, 0xff, 0xf8, 0x00, 0x1f, 0xff, 0xf8, 0x30, 0x00, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x06, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xf0, 0x48, 0x00, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x06, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0x00, 0x48, 0x00, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x06, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0x00, 0x84, 0x00, 0x00, 0x13, 0x80, 0xc0, 0x00, 0x06, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x80, 0x84, 0x00, 0x00, 0x0f, 0xe0, 0xc0, 0x00, 0x06, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x80, 0x84, 0x00, 0x00, 0x1d, 0x70, 0xc0, 0x00, 0x06, 0x00,
0x00, 0x04, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x84, 0x00, 0x00, 0x19, 0x30, 0xdf, 0xff, 0xf6, 0x00,
0x00, 0x04, 0x00, 0x00, 0xff, 0x80, 0x00, 0x84, 0x00, 0x00, 0x31, 0x18, 0xc4, 0x38, 0x46, 0xf8,
0x00, 0x06, 0x00, 0x03, 0xff, 0x80, 0x00, 0x84, 0x70, 0x00, 0x3e, 0xf8, 0xce, 0x28, 0xe6, 0x88,
0x00, 0x06, 0x00, 0x0f, 0xff, 0x80, 0x00, 0x84, 0x20, 0x00, 0x31, 0x18, 0xc0, 0x38, 0x06, 0x88,
0x00, 0x07, 0x80, 0x3f, 0xff, 0xf0, 0x00, 0x84, 0x70, 0x00, 0x19, 0x30, 0xc0, 0x10, 0x06, 0x88,
0x00, 0x07, 0x80, 0x7f, 0xff, 0xf8, 0x00, 0x84, 0x78, 0x00, 0x1d, 0x71, 0xff, 0xff, 0xff, 0x88,
0x00, 0x07, 0xe0, 0xff, 0xff, 0x98, 0x00, 0x87, 0xfa, 0xaa, 0xaf, 0xe1, 0xff, 0xff, 0xff, 0xf8,
0x00, 0x07, 0xe1, 0xff, 0xff, 0x98, 0x00, 0x78, 0x70, 0x00, 0x03, 0x81, 0xc0, 0x00, 0x07, 0x00,
0x00, 0x07, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0xff, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfe, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
0x00, 0x07, 0xff, 0xff, 0xff, 0x80, 0x07, 0xff, 0xfe, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
0x00, 0x03, 0xff, 0xff, 0xff, 0x00, 0x01, 0xc0, 0x38, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x03, 0xc0,
0x00, 0x01, 0xff, 0xff, 0xff, 0x00, 0x01, 0x80, 0x18, 0x00, 0x38, 0x00, 0x00, 0x00, 0x01, 0xc0,
0x00, 0x01, 0xff, 0xff, 0xfe, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x7f, 0xff, 0xfe, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x7f, 0xff, 0xfc, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x07, 0xff, 0xe0, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x07, 0xff, 0xe0, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x01, 0xf9, 0xe0, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x01, 0xf9, 0xe0, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x01, 0xe0, 0x60, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x01, 0xe0, 0x60, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x01, 0x80, 0x60, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x01, 0x80, 0x60, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x01, 0xf8, 0x78, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x00, 0xf8, 0x38, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'scrollbar_background', 8x64px
const unsigned char bitmap_scrollbar_background [] PROGMEM = {
0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02,
0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02,
0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02,
0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00
};
// 'item_sel_outline', 128x21px
const unsigned char bitmap_item_sel_outline [] PROGMEM = {
0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0,
0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0
};
// 'icon_dashboard', 16x16px
const unsigned char icon_dashboard [] PROGMEM = {
0x07, 0xe0, 0x18, 0x18, 0x21, 0x24, 0x50, 0x02, 0x48, 0x0a, 0x84, 0x01, 0x83, 0x81, 0xa2, 0x45,
0x82, 0x41, 0x81, 0x81, 0xa0, 0x05, 0x40, 0x02, 0x4b, 0xd2, 0x23, 0xc4, 0x18, 0x18, 0x07, 0xe0
};
// 'paska', 16x16px
const unsigned char icon_paska [] PROGMEM = {
0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80, 0x00, 0x00, 0xff, 0xff, 0x80, 0x01, 0x40, 0x02, 0x20, 0x04,
0x20, 0x04, 0x40, 0x02, 0x80, 0x01, 0xff, 0xff, 0x00, 0x00, 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0
};
// 'teplomer', 16x16px
const unsigned char icon_teplomer [] PROGMEM = {
0x00, 0x0e, 0x00, 0x11, 0x00, 0x21, 0x00, 0x51, 0x00, 0x82, 0x01, 0x44, 0x02, 0x08, 0x05, 0x10,
0x08, 0x20, 0x14, 0x40, 0x10, 0x80, 0x19, 0x00, 0x3e, 0x00, 0x70, 0x00, 0xe0, 0x00, 0xc0, 0x00
};
// 'teplomer_set', 16x16px
const unsigned char icon_teplomer_set [] PROGMEM = {
0x00, 0x0e, 0x00, 0x11, 0x00, 0x21, 0x00, 0x51, 0x00, 0x82, 0x01, 0x44, 0x02, 0x08, 0x05, 0x10,
0x08, 0x20, 0x14, 0x40, 0x10, 0x00, 0x19, 0xb7, 0x3d, 0x22, 0x71, 0xb2, 0xe0, 0xa2, 0xc1, 0xb2
};
// 'zamek', 16x16px
const unsigned char icon_zamek [] PROGMEM = {
0x00, 0x00, 0x07, 0xe0, 0x0c, 0x30, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x3f, 0xfc, 0x7f, 0xfe,
0x7e, 0x7e, 0x7c, 0x3e, 0x7c, 0x3e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7f, 0xfe, 0x3f, 0xfc
};
// 'zamek_unl', 16x16px
const unsigned char icon_zamek_unl [] PROGMEM = {
0x07, 0xe0, 0x0c, 0x30, 0x08, 0x10, 0x08, 0x10, 0x08, 0x00, 0x08, 0x00, 0x3f, 0xfc, 0x7f, 0xfe,
0x7e, 0x7e, 0x7c, 0x3e, 0x7c, 0x3e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7f, 0xfe, 0x3f, 0xfc
};
// 'diameter', 16x16px
const unsigned char icon_diameter [] PROGMEM = {
0x00, 0x04, 0x03, 0xc6, 0x0c, 0x37, 0x10, 0x08, 0x20, 0x14, 0x20, 0x24, 0x40, 0x42, 0x40, 0x82,
0x41, 0x02, 0x42, 0x02, 0x24, 0x04, 0x28, 0x04, 0x10, 0x08, 0xec, 0x30, 0x63, 0xc0, 0x20, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 192)
const unsigned char* bitmap_icons[7] = {
icon_dashboard,
icon_paska,
icon_teplomer,
icon_zamek,
icon_zamek_unl,
icon_teplomer_set,
icon_diameter
};
// ------------------ end generated bitmaps from image2cpp ---------------------------------
#define BUTTON_SELECT_PIN 4 // pin for SELECT button
bool button_select_clicked = 0;
const int NUM_ITEMS = 5; // number of items in the list and also the number of screenshots and screenshots with QR codes (other screens)
const int MAX_ITEM_LENGTH = 20; // maximum characters for the item name
char menu_items [NUM_ITEMS] [MAX_ITEM_LENGTH] = { // array with item names
{ "Temperature" },
{ "Rotation speed" },
{ "Strip Width" },
{ "Preset" },
{ "<- Back" }
};
int parameters [NUM_ITEMS-1] = {
64, //Temperature
20, //Rotation speed
11, //Strip Width
69 //Preset
};
//---------------------Rotacni enkoder
int rot_encoder_counter = 0;
void isr1(){
if (digitalRead(3)){
rot_encoder_counter++;
}
else
{
rot_encoder_counter--;
}
}
//---------------------END Rotacni enkoder
int item_selected = 0; // which item in the menu is selected
int item_sel_previous; // previous item - used in the menu screen to draw the item before the selected one
int item_sel_next; // next item - used in the menu screen to draw next item after the selected one
int current_screen = 2; // 0 = menu, 1 = val. set, 2 = info screen
int teplota2 = 240;
int diameter = 10;
bool error_flag = false;
void draw_info_screen() { //PREHLEDOVA OBRAZOVKA
int a = 0;
int b = 0;
if (parameters[0] < 10){a = 14;}else if (parameters[0] < 100){a = 7;} else{a = 0;}
if (teplota2 < 10){b = 14;}else if (teplota2 < 100){b = 7;} else{b = 0;}
u8g.setFont(u8g_font_7x14r);
u8g.setPrintPos(20+a,15);
u8g.print(parameters[0]);
u8g.drawStr(42, 15, "'C");
u8g.setPrintPos((20+60+b),15);
u8g.print(teplota2);
u8g.drawStr(42+60, 15, "'C");
u8g.setPrintPos(20,(15+23));
u8g.print(parameters[2]);
u8g.drawStr(35, 15+23, "mm");
u8g.setPrintPos(20+60,(15+23));
u8g.print(diameter);
u8g.drawStr(35+60, 15+23, "mm");
u8g.setPrintPos((20),(15+23+23));
u8g.print(parameters[1]);
u8g.drawStr(35, 15+23+23, "rpm");
u8g.setPrintPos((20+60),(15+23+23));
u8g.print(parameters[3]);
u8g.drawStr(35+60, 15+23+23, "mm");
u8g.drawBitmapP( 0, 2, 16/8, 16, bitmap_icons[5]);
u8g.drawBitmapP( 60, 2, 16/8, 16, bitmap_icons[2]);
u8g.drawBitmapP( 0, 25, 16/8, 16, bitmap_icons[1]);
u8g.drawBitmapP( 60, 25, 16/8, 16, bitmap_icons[6]);
u8g.drawBitmapP( 0, 48, 16/8, 16, bitmap_icons[0]);
u8g.drawBitmapP( 60, 48, 16/8, 16, bitmap_icons[4]);
}
void setup() {
attachInterrupt(digitalPinToInterrupt(2), isr1, RISING);
u8g.setColorIndex(1); // set the color to white
pinMode(BUTTON_SELECT_PIN, INPUT_PULLUP); // select button
u8g.firstPage();
do {
u8g.drawBitmapP( 0, 0, 128/8, 64, dino_splash);
} while( u8g.nextPage() );
delay(1000);
}
void loop() {
teplota2 = random(200);
diameter = random(80);
if (current_screen == 0) { // MENU SCREEN
// up and down buttons only work for the menu screen
if (rot_encoder_counter < 0){ // up button clicked - jump to previous menu item
item_selected = item_selected - 1; // select previous item
if (item_selected < 0) { // if first item was selected, jump to last item
item_selected = NUM_ITEMS-1;
}
rot_encoder_counter++;
}
if (rot_encoder_counter > 0){ // down button clicked - jump to next menu item
item_selected = item_selected + 1; // select next item
if (item_selected >= NUM_ITEMS) { // last item was selected, jump to first menu item
item_selected = 0;
}
rot_encoder_counter--;
}
}
if (current_screen == 1) { // Individual item settings screen
if (rot_encoder_counter > 0){ // up button clicked - jump to previous menu item
parameters[item_selected] = parameters[item_selected] +1; // select previous item
rot_encoder_counter--;
}
if (rot_encoder_counter < 0){ // down button clicked - jump to next menu item
parameters[item_selected] = parameters[item_selected] -1; // select next item
rot_encoder_counter++;
}
}
if ((digitalRead(BUTTON_SELECT_PIN) == LOW) && (button_select_clicked == 0)) { // select button clicked, jump between screens
button_select_clicked = 1; // set button to clicked to only perform the action once
if ((current_screen == 0) && (item_selected == 4)){current_screen = 2;}
else if (current_screen == 0) {current_screen = 1;} // menu items screen --> screenshots screen
else {current_screen = 0;} // qr codes screen --> menu items screen
}
if ((digitalRead(BUTTON_SELECT_PIN) == HIGH) && (button_select_clicked == 1)) { // unclick
button_select_clicked = 0;
}
// set correct values for the previous and next items
item_sel_previous = item_selected - 1;
if (item_sel_previous < 0) {item_sel_previous = NUM_ITEMS - 1;} // previous item would be below first = make it the last
item_sel_next = item_selected + 1;
if (item_sel_next >= NUM_ITEMS) {item_sel_next = 0;} // next item would be after last = make it the first
u8g.firstPage(); // required for page drawing mode for u8g library
do {
if (current_screen == 0) { // MENU SCREEN
// selected item background
u8g.drawBitmapP(0, 22, 128/8, 21, bitmap_item_sel_outline);
// draw previous item as icon + label
u8g.setFont(u8g_font_7x14);
u8g.drawStr(5, 15, menu_items[item_sel_previous]);
// draw selected item as icon + label in bold font
u8g.setFont(u8g_font_7x14B);
u8g.drawStr(10, 15+20+2, menu_items[item_selected]);
// draw next item as icon + label
u8g.setFont(u8g_font_7x14);
u8g.drawStr(5, 15+20+20+2+2, menu_items[item_sel_next]);
// draw scrollbar background
u8g.drawBitmapP(128-8, 0, 8/8, 64, bitmap_scrollbar_background);
// draw scrollbar handle
u8g.drawBox(125, 64/NUM_ITEMS * item_selected, 3, 64/NUM_ITEMS);
}
else if (current_screen == 1) { // Individual item settings screen
u8g.setFont(u8g_font_7x14B);
u8g.drawStr(5, 12, menu_items[item_selected]);
u8g.setFont(u8g_font_7x14);
u8g.setPrintPos(10,30);
u8g.print(parameters[item_selected]);
}
else if (current_screen == 2) { // Info screen
item_selected = 0;
rot_encoder_counter = 0;
draw_info_screen();
}
} while ( u8g.nextPage() ); // required for page drawing mode with u8g library
}