first commit
This commit is contained in:
@@ -0,0 +1,546 @@
|
||||
// =====================================================================
|
||||
//
|
||||
// CONTROL
|
||||
//
|
||||
// =====================================================================
|
||||
// *********************************************************************
|
||||
// *********************************************************************
|
||||
// content:
|
||||
// (0) Control over serial interface
|
||||
// (1) Control over one analog input
|
||||
// (2) Control over 4 - 6 digital input pins (internal pullups enabled)
|
||||
// (3) Control over encoder (internal pullups enabled)
|
||||
// (4) Control with Keypad
|
||||
// (5) Control with an ir remote
|
||||
// (6) Control with a youstick
|
||||
// *********************************************************************
|
||||
|
||||
#define _LCDML_CONTROL_cfg 0
|
||||
|
||||
|
||||
// therory:
|
||||
// "#if" is a preprocessor directive and no error, look here:
|
||||
// (english) https://en.wikipedia.org/wiki/C_preprocessor
|
||||
// (german) https://de.wikipedia.org/wiki/C-Pr%C3%A4prozessor
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// CONTROL TASK, DO NOT CHANGE
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_control)
|
||||
// *********************************************************************
|
||||
{
|
||||
// call setup
|
||||
LCDML_CONTROL_setup();
|
||||
}
|
||||
// backend loop
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_control)
|
||||
{
|
||||
// call loop
|
||||
LCDML_CONTROL_loop();
|
||||
|
||||
// go to next backend function and do not block it
|
||||
return true;
|
||||
}
|
||||
// backend stop stable
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_control)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// *************** (0) CONTROL OVER SERIAL INTERFACE *******************
|
||||
// *********************************************************************
|
||||
#if(_LCDML_CONTROL_cfg == 0)
|
||||
// settings
|
||||
# define _LCDML_CONTROL_serial_enter 'e'
|
||||
# define _LCDML_CONTROL_serial_up 'w'
|
||||
# define _LCDML_CONTROL_serial_down 's'
|
||||
# define _LCDML_CONTROL_serial_left 'a'
|
||||
# define _LCDML_CONTROL_serial_right 'd'
|
||||
# define _LCDML_CONTROL_serial_quit 'q'
|
||||
// *********************************************************************
|
||||
// setup
|
||||
void LCDML_CONTROL_setup()
|
||||
{
|
||||
}
|
||||
// *********************************************************************
|
||||
// loop
|
||||
void LCDML_CONTROL_loop()
|
||||
{
|
||||
// check if new serial input is available
|
||||
if (Serial.available()) {
|
||||
// read one char from input buffer
|
||||
switch (Serial.read())
|
||||
{
|
||||
case _LCDML_CONTROL_serial_enter: LCDML_BUTTON_enter(); break;
|
||||
case _LCDML_CONTROL_serial_up: LCDML_BUTTON_up(); break;
|
||||
case _LCDML_CONTROL_serial_down: LCDML_BUTTON_down(); break;
|
||||
case _LCDML_CONTROL_serial_left: LCDML_BUTTON_left(); break;
|
||||
case _LCDML_CONTROL_serial_right: LCDML_BUTTON_right(); break;
|
||||
case _LCDML_CONTROL_serial_quit: LCDML_BUTTON_quit(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// *********************************************************************
|
||||
// ******************************* END *********************************
|
||||
// *********************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// *************** (1) CONTROL OVER ONE ANALOG PIN *********************
|
||||
// *********************************************************************
|
||||
#elif(_LCDML_CONTROL_cfg == 1)
|
||||
// settings
|
||||
#define _LCDML_CONTROL_analog_pin 0
|
||||
// when you did not use a button set the value to zero
|
||||
#define _LCDML_CONTROL_analog_enter_min 850 // Button Enter
|
||||
#define _LCDML_CONTROL_analog_enter_max 920
|
||||
#define _LCDML_CONTROL_analog_up_min 520 // Button Up
|
||||
#define _LCDML_CONTROL_analog_up_max 590
|
||||
#define _LCDML_CONTROL_analog_down_min 700 // Button Down
|
||||
#define _LCDML_CONTROL_analog_down_max 770
|
||||
#define _LCDML_CONTROL_analog_back_min 950 // Button Back
|
||||
#define _LCDML_CONTROL_analog_back_max 1020
|
||||
#define _LCDML_CONTROL_analog_left_min 430 // Button Left
|
||||
#define _LCDML_CONTROL_analog_left_max 500
|
||||
#define _LCDML_CONTROL_analog_right_min 610 // Button Right
|
||||
#define _LCDML_CONTROL_analog_right_max 680
|
||||
// *********************************************************************
|
||||
// setup
|
||||
void LCDML_CONTROL_setup()
|
||||
{
|
||||
}
|
||||
// *********************************************************************
|
||||
// loop
|
||||
void LCDML_CONTROL_loop()
|
||||
{
|
||||
// check debounce timer
|
||||
if((millis() - g_LCDML_DISP_press_time) >= _LCDML_DISP_cfg_button_press_time) {
|
||||
g_LCDML_DISP_press_time = millis(); // reset debounce timer
|
||||
|
||||
uint16_t value = analogRead(_LCDML_CONTROL_analog_pin); // analogpin for keypad
|
||||
|
||||
if (value >= _LCDML_CONTROL_analog_enter_min && value <= _LCDML_CONTROL_analog_enter_max) { LCDML_BUTTON_enter(); }
|
||||
if (value >= _LCDML_CONTROL_analog_up_min && value <= _LCDML_CONTROL_analog_up_max) { LCDML_BUTTON_up(); }
|
||||
if (value >= _LCDML_CONTROL_analog_down_min && value <= _LCDML_CONTROL_analog_down_max) { LCDML_BUTTON_down(); }
|
||||
if (value >= _LCDML_CONTROL_analog_left_min && value <= _LCDML_CONTROL_analog_left_max) { LCDML_BUTTON_left(); }
|
||||
if (value >= _LCDML_CONTROL_analog_right_min && value <= _LCDML_CONTROL_analog_right_max) { LCDML_BUTTON_right(); }
|
||||
if (value >= _LCDML_CONTROL_analog_back_min && value <= _LCDML_CONTROL_analog_back_max) { LCDML_BUTTON_quit(); }
|
||||
}
|
||||
}
|
||||
// *********************************************************************
|
||||
// ******************************* END *********************************
|
||||
// *********************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// *************** (2) CONTROL OVER DIGITAL PINS ***********************
|
||||
// *********************************************************************
|
||||
#elif(_LCDML_CONTROL_cfg == 2)
|
||||
// settings
|
||||
#define _LCDML_CONTROL_digital_low_active 0 // (1 = low active (pullup), 0 = high active (pulldown) button
|
||||
// http://playground.arduino.cc/CommonTopics/PullUpDownResistor
|
||||
#define _LCDML_CONTROL_digital_enable_quit 1
|
||||
#define _LCDML_CONTROL_digital_enable_lr 1
|
||||
#define _LCDML_CONTROL_digital_enter 8
|
||||
#define _LCDML_CONTROL_digital_up 9
|
||||
#define _LCDML_CONTROL_digital_down 10
|
||||
#define _LCDML_CONTROL_digital_quit 11
|
||||
#define _LCDML_CONTROL_digital_left 12
|
||||
#define _LCDML_CONTROL_digital_right 13
|
||||
// *********************************************************************
|
||||
// setup
|
||||
void LCDML_CONTROL_setup()
|
||||
{
|
||||
// init buttons
|
||||
pinMode(_LCDML_CONTROL_digital_enter , INPUT_PULLUP);
|
||||
pinMode(_LCDML_CONTROL_digital_up , INPUT_PULLUP);
|
||||
pinMode(_LCDML_CONTROL_digital_down , INPUT_PULLUP);
|
||||
# if(_LCDML_CONTROL_digital_enable_quit == 1)
|
||||
pinMode(_LCDML_CONTROL_digital_quit , INPUT_PULLUP);
|
||||
# endif
|
||||
# if(_LCDML_CONTROL_digital_enable_lr == 1)
|
||||
pinMode(_LCDML_CONTROL_digital_left , INPUT_PULLUP);
|
||||
pinMode(_LCDML_CONTROL_digital_right , INPUT_PULLUP);
|
||||
# endif
|
||||
}
|
||||
// *********************************************************************
|
||||
// loop
|
||||
void LCDML_CONTROL_loop()
|
||||
{
|
||||
#if(_LCDML_CONTROL_digital_low_active == 1)
|
||||
# define _LCDML_CONTROL_digital_a !
|
||||
#else
|
||||
# define _LCDML_CONTROL_digital_a
|
||||
#endif
|
||||
|
||||
uint8_t but_stat = 0x00;
|
||||
|
||||
bitWrite(but_stat, 0, _LCDML_CONTROL_digital_a(digitalRead(_LCDML_CONTROL_digital_enter)));
|
||||
bitWrite(but_stat, 1, _LCDML_CONTROL_digital_a(digitalRead(_LCDML_CONTROL_digital_up)));
|
||||
bitWrite(but_stat, 2, _LCDML_CONTROL_digital_a(digitalRead(_LCDML_CONTROL_digital_down)));
|
||||
#if(_LCDML_CONTROL_digital_enable_quit == 1)
|
||||
bitWrite(but_stat, 3, _LCDML_CONTROL_digital_a(digitalRead(_LCDML_CONTROL_digital_quit)));
|
||||
#endif
|
||||
#if(_LCDML_CONTROL_digital_enable_lr == 1)
|
||||
bitWrite(but_stat, 4, _LCDML_CONTROL_digital_a(digitalRead(_LCDML_CONTROL_digital_left)));
|
||||
bitWrite(but_stat, 5, _LCDML_CONTROL_digital_a(digitalRead(_LCDML_CONTROL_digital_right)));
|
||||
#endif
|
||||
|
||||
if (but_stat > 0) {
|
||||
if((millis() - g_LCDML_DISP_press_time) >= _LCDML_DISP_cfg_button_press_time) {
|
||||
g_LCDML_DISP_press_time = millis(); // reset press time
|
||||
|
||||
if (bitRead(but_stat, 0)) { LCDML_BUTTON_enter(); }
|
||||
if (bitRead(but_stat, 1)) { LCDML_BUTTON_up(); }
|
||||
if (bitRead(but_stat, 2)) { LCDML_BUTTON_down(); }
|
||||
if (bitRead(but_stat, 3)) { LCDML_BUTTON_quit(); }
|
||||
if (bitRead(but_stat, 4)) { LCDML_BUTTON_left(); }
|
||||
if (bitRead(but_stat, 5)) { LCDML_BUTTON_right(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
// *********************************************************************
|
||||
// ******************************* END *********************************
|
||||
// *********************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// *************** (3) CONTROL WITH ENCODER ****************************
|
||||
// *********************************************************************
|
||||
#elif(_LCDML_CONTROL_cfg == 3)
|
||||
// settings
|
||||
#define _LCDML_CONTROL_encoder_pin_a 4 // pin encoder b
|
||||
#define _LCDML_CONTROL_encoder_pin_b 5 // pin encoder a
|
||||
#define _LCDML_CONTROL_encoder_pin_button 7 // pin taster
|
||||
#define _LCDML_CONTROL_encoder_high_active 0 // (0 = low active (pullup), 1 = high active (pulldown)) button
|
||||
// http://playground.arduino.cc/CommonTopics/PullUpDownResistor
|
||||
|
||||
#define _LCDML_CONTROL_encoder_refresh_time 5UL // 5ms
|
||||
#define _LCDML_CONTROL_encoder_switch_time 75UL // 75 ms
|
||||
|
||||
// macros which define the functionality
|
||||
#define _LCDML_CONTROL_encoder_switch_press_short() LCDML_BUTTON_enter()
|
||||
#define _LCDML_CONTROL_encoder_rotary_a() LCDML_BUTTON_up()
|
||||
#define _LCDML_CONTROL_encoder_rotary_b() LCDML_BUTTON_down()
|
||||
|
||||
#define _LCDML_CONTROL_encoder_advanced_switch 1
|
||||
#define _LCDML_CONTROL_encoder_switch_press_long() LCDML_BUTTON_quit()
|
||||
|
||||
#define _LCDML_CONTROL_encoder_advanced_rotary 1
|
||||
#define _LCDML_CONTROL_encoder_rotary_a_and_press() LCDML_BUTTON_left()
|
||||
#define _LCDML_CONTROL_encoder_rotary_b_and_press() LCDML_BUTTON_right()
|
||||
|
||||
#define _LCDML_CONTROL_encoder_t_long_press 1000 // maximum is 1275 (5*255)
|
||||
|
||||
// global defines
|
||||
uint8_t g_LCDML_CONTROL_encoder_t_prev = 0;
|
||||
uint8_t g_LCDML_CONTROL_encoder_a_prev = 0;
|
||||
uint8_t g_LCDML_CONTROL_t_pressed = 0;
|
||||
uint8_t g_LCDML_CONTROL_t_press_time = 0;
|
||||
|
||||
// *********************************************************************
|
||||
// setup
|
||||
void LCDML_CONTROL_setup()
|
||||
{
|
||||
// set encoder update intervall time
|
||||
LCDML_BACK_dynamic_setLoopTime(LCDML_BACKEND_control, _LCDML_CONTROL_encoder_refresh_time); // 5ms
|
||||
|
||||
// init pins
|
||||
if(_LCDML_CONTROL_encoder_high_active == 0)
|
||||
{
|
||||
pinMode(_LCDML_CONTROL_encoder_pin_a , INPUT_PULLUP);
|
||||
pinMode(_LCDML_CONTROL_encoder_pin_b , INPUT_PULLUP);
|
||||
pinMode(_LCDML_CONTROL_encoder_pin_button , INPUT_PULLUP);
|
||||
}
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
// loop
|
||||
void LCDML_CONTROL_loop()
|
||||
{
|
||||
// read encoder status
|
||||
unsigned char a = digitalRead(_LCDML_CONTROL_encoder_pin_a);
|
||||
unsigned char b = digitalRead(_LCDML_CONTROL_encoder_pin_b);
|
||||
unsigned char t = digitalRead(_LCDML_CONTROL_encoder_pin_button);
|
||||
|
||||
// change button status if high and low active are switched
|
||||
if (_LCDML_CONTROL_encoder_high_active == 1) {
|
||||
t = !t;
|
||||
}
|
||||
|
||||
// check if the button was pressed and save this state
|
||||
if((millis() - g_LCDML_DISP_press_time) >= _LCDML_CONTROL_encoder_switch_time) {
|
||||
g_LCDML_DISP_press_time = millis(); // reset button press time
|
||||
|
||||
// press button once
|
||||
if (t == false && g_LCDML_CONTROL_encoder_t_prev == 0)
|
||||
{
|
||||
g_LCDML_CONTROL_t_pressed = 1;
|
||||
}
|
||||
else {
|
||||
g_LCDML_CONTROL_encoder_t_prev = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// check if button is currently pressed
|
||||
if(t == false)
|
||||
{
|
||||
// check if the advanced rotary function is enabled
|
||||
if(_LCDML_CONTROL_encoder_advanced_rotary == 1)
|
||||
{
|
||||
// check if the rotary encoder was moved
|
||||
if (a == false && g_LCDML_CONTROL_encoder_a_prev ) {
|
||||
g_LCDML_CONTROL_encoder_t_prev = 1;
|
||||
|
||||
if (b == false)
|
||||
{
|
||||
// switch active and rotary b moved
|
||||
_LCDML_CONTROL_encoder_rotary_b_and_press();
|
||||
}
|
||||
else
|
||||
{
|
||||
// switch active and rotary a moved
|
||||
_LCDML_CONTROL_encoder_rotary_a_and_press();
|
||||
}
|
||||
|
||||
g_LCDML_CONTROL_t_pressed = 0;
|
||||
g_LCDML_CONTROL_t_press_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// check advanced mode "long press switch"
|
||||
if(_LCDML_CONTROL_encoder_advanced_switch == 1)
|
||||
{
|
||||
// button was pressed
|
||||
if(g_LCDML_CONTROL_t_pressed == 1)
|
||||
{
|
||||
// check overrun and stop
|
||||
if(g_LCDML_CONTROL_t_press_time < 255)
|
||||
{
|
||||
g_LCDML_CONTROL_t_press_time++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// switch is not active
|
||||
|
||||
// check encoder
|
||||
if (a == false && g_LCDML_CONTROL_encoder_a_prev) {
|
||||
g_LCDML_CONTROL_encoder_t_prev = 1;
|
||||
|
||||
if (b == false)
|
||||
{
|
||||
_LCDML_CONTROL_encoder_rotary_a();
|
||||
}
|
||||
else
|
||||
{
|
||||
_LCDML_CONTROL_encoder_rotary_b();
|
||||
}
|
||||
|
||||
g_LCDML_CONTROL_t_pressed = 0;
|
||||
g_LCDML_CONTROL_t_press_time = 0;
|
||||
g_LCDML_DISP_press_time = millis();
|
||||
}
|
||||
|
||||
// check if an button was pressed
|
||||
if(g_LCDML_CONTROL_t_pressed == 1)
|
||||
{
|
||||
if(g_LCDML_CONTROL_t_press_time * _LCDML_CONTROL_encoder_refresh_time >= _LCDML_CONTROL_encoder_t_long_press && _LCDML_CONTROL_encoder_advanced_switch == 1)
|
||||
{
|
||||
_LCDML_CONTROL_encoder_switch_press_long();
|
||||
}
|
||||
else
|
||||
{
|
||||
_LCDML_CONTROL_encoder_switch_press_short();
|
||||
}
|
||||
|
||||
g_LCDML_CONTROL_t_pressed = 0;
|
||||
g_LCDML_CONTROL_t_press_time = 0;
|
||||
g_LCDML_DISP_press_time = millis();
|
||||
}
|
||||
}
|
||||
|
||||
g_LCDML_CONTROL_encoder_a_prev = a; // set new encoder status
|
||||
|
||||
}
|
||||
// *********************************************************************
|
||||
// ******************************* END *********************************
|
||||
// *********************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// *************** (4) CONTROL WITH A KEYPAD ***************************
|
||||
// *********************************************************************
|
||||
#elif(_LCDML_CONTROL_cfg == 4)
|
||||
// include
|
||||
// more information under http://playground.arduino.cc/Main/KeypadTutorial
|
||||
#include <Keypad.h>
|
||||
// settings
|
||||
#define _LCDML_CONTROL_keypad_rows 4 // Four rows
|
||||
#define _LCDML_CONTROL_keypad_cols 3 // Three columns
|
||||
// global vars
|
||||
char keys[_LCDML_CONTROL_keypad_rows][_LCDML_CONTROL_keypad_cols] = {
|
||||
{'1','2','3'},
|
||||
{'4','5','6'},
|
||||
{'7','8','9'},
|
||||
{'#','0','*'}
|
||||
};
|
||||
byte rowPins[_LCDML_CONTROL_keypad_rows] = { 9, 8, 7, 6 }; // Connect keypad COL0, COL1 and COL2 to these Arduino pins.
|
||||
byte colPins[_LCDML_CONTROL_keypad_cols] = { 12, 11, 10 }; // Create the Keypad
|
||||
// objects
|
||||
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, _LCDML_CONTROL_keypad_rows, _LCDML_CONTROL_keypad_cols );
|
||||
// *********************************************************************
|
||||
// setup
|
||||
void LCDML_CONTROL_setup()
|
||||
{
|
||||
}
|
||||
// *********************************************************************
|
||||
// loop
|
||||
void LCDML_CONTROL_loop()
|
||||
{
|
||||
char key = kpd.getKey();
|
||||
if(key) // Check for a valid key.
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case '#': LCDML_BUTTON_enter(); break;
|
||||
case '2': LCDML_BUTTON_up(); break;
|
||||
case '8': LCDML_BUTTON_down(); break;
|
||||
case '4': LCDML_BUTTON_left(); break;
|
||||
case '6': LCDML_BUTTON_right(); break;
|
||||
case '*': LCDML_BUTTON_quit(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// *********************************************************************
|
||||
// ******************************* END *********************************
|
||||
// *********************************************************************
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// *************** (5) CONTROL WITH IR REMOTE ***************************
|
||||
// *********************************************************************
|
||||
#elif(_LCDML_CONTROL_cfg == 5)
|
||||
// ir include (this lib have to be installed)
|
||||
#include <IRremote.h>
|
||||
// ir global vars
|
||||
int RECV_PIN = 11;
|
||||
// ir objects
|
||||
IRrecv irrecv(RECV_PIN);
|
||||
decode_results results;
|
||||
|
||||
// *********************************************************************
|
||||
// setup (nothing change here)
|
||||
void LCDML_CONTROL_setup()
|
||||
{
|
||||
irrecv.enableIRIn(); // Start the receiver
|
||||
}
|
||||
// *********************************************************************
|
||||
// loop
|
||||
// change in this function the ir values to your values
|
||||
void LCDML_CONTROL_loop()
|
||||
{
|
||||
if (irrecv.decode(&results))
|
||||
{
|
||||
// comment this line out, to check the correct code
|
||||
//Serial.println(results.value, HEX);
|
||||
|
||||
// in this switch case you have to change the value 0x...1 to the correct ir code
|
||||
switch (results.value)
|
||||
{
|
||||
case 0x00000001: LCDML_BUTTON_enter(); break;
|
||||
case 0x00000002: LCDML_BUTTON_up(); break;
|
||||
case 0x00000003: LCDML_BUTTON_down(); break;
|
||||
case 0x00000004: LCDML_BUTTON_left(); break;
|
||||
case 0x00000005: LCDML_BUTTON_right(); break;
|
||||
case 0x00000006: LCDML_BUTTON_quit(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// *********************************************************************
|
||||
// ******************************* END *********************************
|
||||
// *********************************************************************
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// *************** (6) CONTROL OVER JOYSTICK *********************
|
||||
// *********************************************************************
|
||||
#elif(_LCDML_CONTROL_cfg == 6)
|
||||
// settings
|
||||
#define _LCDML_CONTROL_analog_pinx A0
|
||||
#define _LCDML_CONTROL_analog_piny A1
|
||||
#define _LCDML_CONTROL_digitalread 33 //don't work with u8glib
|
||||
|
||||
// when you did not use a button set the value to zero
|
||||
#define _LCDML_CONTROL_analog_up_min 612 // Button Up
|
||||
#define _LCDML_CONTROL_analog_up_max 1023
|
||||
#define _LCDML_CONTROL_analog_down_min 0 // Button Down
|
||||
#define _LCDML_CONTROL_analog_down_max 412
|
||||
#define _LCDML_CONTROL_analog_left_min 612 // Button Left
|
||||
#define _LCDML_CONTROL_analog_left_max 1023
|
||||
#define _LCDML_CONTROL_analog_right_min 0 // Button Right
|
||||
#define _LCDML_CONTROL_analog_right_max 412
|
||||
// *********************************************************************
|
||||
// setup
|
||||
void LCDML_CONTROL_setup()
|
||||
{
|
||||
pinMode (_LCDML_CONTROL_digitalread, INPUT);
|
||||
}
|
||||
// *********************************************************************
|
||||
// loop
|
||||
void LCDML_CONTROL_loop()
|
||||
{
|
||||
// check debounce timer
|
||||
if((millis() - g_LCDML_DISP_press_time) >= _LCDML_DISP_cfg_button_press_time) {
|
||||
g_LCDML_DISP_press_time = millis(); // reset debounce timer
|
||||
|
||||
uint16_t valuex = analogRead(_LCDML_CONTROL_analog_pinx); // analogpinx
|
||||
uint16_t valuey = analogRead(_LCDML_CONTROL_analog_piny); // analogpinx
|
||||
uint16_t valuee = digitalRead(_LCDML_CONTROL_digitalread); //digitalpinenter
|
||||
|
||||
|
||||
if (valuey >= _LCDML_CONTROL_analog_up_min && valuey <= _LCDML_CONTROL_analog_up_max) { LCDML_BUTTON_up(); } // up
|
||||
if (valuey >= _LCDML_CONTROL_analog_down_min && valuey <= _LCDML_CONTROL_analog_down_max) { LCDML_BUTTON_down(); } // down
|
||||
if (valuex >= _LCDML_CONTROL_analog_left_min && valuex <= _LCDML_CONTROL_analog_left_max) { LCDML_BUTTON_left(); } // left
|
||||
if (valuex >= _LCDML_CONTROL_analog_right_min && valuex <= _LCDML_CONTROL_analog_right_max) { LCDML_BUTTON_right(); } // right
|
||||
|
||||
if(valuee == true) {LCDML_BUTTON_enter();} // enter
|
||||
|
||||
// back buttons have to be included as menuitem
|
||||
// lock at the examle LCDML_back_button
|
||||
|
||||
}
|
||||
}
|
||||
// *********************************************************************
|
||||
// ******************************* END *********************************
|
||||
// *********************************************************************
|
||||
|
||||
|
||||
#else
|
||||
#error _LCDML_CONTROL_cfg is not defined or not in range
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
// =====================================================================
|
||||
//
|
||||
// Output function
|
||||
//
|
||||
// =====================================================================
|
||||
|
||||
/* ******************************************************************** */
|
||||
void LCDML_lcd_menu_display()
|
||||
/* ******************************************************************** */
|
||||
{
|
||||
// check if menu needs an update
|
||||
if (LCDML_DISP_update()) {
|
||||
|
||||
// init vars
|
||||
uint8_t n_max = (LCDML.getChilds() >= _LCDML_DISP_rows) ? _LCDML_DISP_rows : (LCDML.getChilds());
|
||||
uint8_t scrollbar_min = 0;
|
||||
uint8_t scrollbar_max = LCDML.getChilds();
|
||||
uint8_t scrollbar_cur_pos = LCDML.getCursorPosAbs();
|
||||
uint8_t scroll_pos = ((1.*n_max * _LCDML_DISP_rows) / (scrollbar_max - 1) * scrollbar_cur_pos);
|
||||
|
||||
|
||||
// update content
|
||||
if (LCDML_DISP_update_content()) {
|
||||
// clear menu
|
||||
LCDML_lcd_menu_clear();
|
||||
|
||||
// display rows
|
||||
for (uint8_t n = 0; n < n_max; n++)
|
||||
{
|
||||
// set cursor
|
||||
lcd.setCursor(1, n);
|
||||
// set content
|
||||
// with content id you can add special content to your static menu or replace the content
|
||||
// the content_id contains the id wich is set on main tab for a menuitem
|
||||
switch(LCDML.content_id[n])
|
||||
{
|
||||
//case 0:
|
||||
// lcd.print("special"); // or datetime or other things
|
||||
// break;
|
||||
|
||||
default: // static content
|
||||
lcd.print(LCDML.content[n]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update cursor and scrollbar
|
||||
if (LCDML_DISP_update_cursor()) {
|
||||
|
||||
// display rows
|
||||
for (uint8_t n = 0; n < n_max; n++)
|
||||
{
|
||||
//set cursor
|
||||
lcd.setCursor(0, n);
|
||||
|
||||
//set cursor char
|
||||
if (n == LCDML.getCursorPos()) {
|
||||
lcd.write(_LCDML_DISP_cfg_cursor);
|
||||
} else {
|
||||
lcd.write(' ');
|
||||
}
|
||||
|
||||
// delete or reset scrollbar
|
||||
if (_LCDML_DISP_cfg_scrollbar == 1) {
|
||||
if (scrollbar_max > n_max) {
|
||||
lcd.setCursor((_LCDML_DISP_cols - 1), n);
|
||||
lcd.write((uint8_t)0);
|
||||
}
|
||||
else {
|
||||
lcd.setCursor((_LCDML_DISP_cols - 1), n);
|
||||
lcd.print(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// display scrollbar
|
||||
if (_LCDML_DISP_cfg_scrollbar == 1) {
|
||||
if (scrollbar_max > n_max) {
|
||||
//set scroll position
|
||||
if (scrollbar_cur_pos == scrollbar_min) {
|
||||
// min pos
|
||||
lcd.setCursor((_LCDML_DISP_cols - 1), 0);
|
||||
lcd.write((uint8_t)1);
|
||||
} else if (scrollbar_cur_pos == (scrollbar_max - 1)) {
|
||||
// max pos
|
||||
lcd.setCursor((_LCDML_DISP_cols - 1), (n_max - 1));
|
||||
lcd.write((uint8_t)4);
|
||||
} else {
|
||||
// between
|
||||
lcd.setCursor((_LCDML_DISP_cols - 1), scroll_pos / n_max);
|
||||
lcd.write((uint8_t)(scroll_pos % n_max) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// reinit some vars
|
||||
LCDML_DISP_update_end();
|
||||
}
|
||||
|
||||
|
||||
// lcd clear
|
||||
void LCDML_lcd_menu_clear()
|
||||
{
|
||||
lcd.clear();
|
||||
lcd.setCursor(0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,529 @@
|
||||
/* ===================================================================== *
|
||||
* *
|
||||
* BACKEND SYSTEM *
|
||||
* *
|
||||
* ===================================================================== *
|
||||
* every "backend function" needs three functions
|
||||
* - void LCDML_BACK_setup(..func_name..)
|
||||
* - void LCDML_BACK_loop(..func_name..)
|
||||
* - void LCDML_BACK_stable(..func_name..)
|
||||
*
|
||||
* - every BACKEND function can be stopped and started
|
||||
* EXAMPLE CODE:
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_control)
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
}
|
||||
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_control)
|
||||
{
|
||||
// runs in loop
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_control)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
}
|
||||
* ===================================================================== *
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_static)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_static"));
|
||||
Serial.println(F("==========================="));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_static)
|
||||
{
|
||||
Serial.println(F("Loop: LCDML_BACKEND_static"));
|
||||
|
||||
// return false = go to first backend function and check time
|
||||
return false;
|
||||
// return true = go to next backend function and check time
|
||||
// return true;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_static)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_static"));
|
||||
Serial.println(F("================================="));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
unsigned long g_dynamic_counter = 1;
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_dynamic)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_dynamic"));
|
||||
Serial.println(F("============================"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_dynamic)
|
||||
{
|
||||
// runs in loop with different times
|
||||
Serial.print(F("Loop: LCDML_BACKEND_dynamic - last loop time: "));
|
||||
Serial.println(LCDML_BACK_dynamic_getLoopTime(LCDML_BACKEND_dynamic));
|
||||
|
||||
// set next loop time
|
||||
g_dynamic_counter++;
|
||||
|
||||
// read old loop time and div it through g_dynamic_counter
|
||||
LCDML_BACK_dynamic_setLoopTime(LCDML_BACKEND_dynamic, (LCDML_BACK_dynamic_setDefaultTime(LCDML_BACKEND_dynamic) / g_dynamic_counter));
|
||||
|
||||
if(g_dynamic_counter > 30) {
|
||||
// reset counter after 8 steps
|
||||
g_dynamic_counter = 1;
|
||||
// set loop time to default
|
||||
LCDML_BACK_dynamic_setDefaultTime(LCDML_BACKEND_dynamic);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_dynamic)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_dynamic"));
|
||||
Serial.println(F("=================================="));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_ge1)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_ge1"));
|
||||
Serial.println(F("============================"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_ge1)
|
||||
{
|
||||
// runs in loop
|
||||
Serial.println(F("Loop: LCDML_BACKEND_ge1"));
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_ge1)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_ge1"));
|
||||
Serial.println(F("=================================="));
|
||||
}
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_ge2)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_ge2"));
|
||||
Serial.println(F("============================"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_ge2)
|
||||
{
|
||||
// runs in loop
|
||||
Serial.println(F("Loop: LCDML_BACKEND_ge2"));
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_ge2)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_ge2"));
|
||||
Serial.println(F("=================================="));
|
||||
}
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_ge3)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_ge3"));
|
||||
Serial.println(F("============================"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_ge3)
|
||||
{
|
||||
// runs in loop
|
||||
Serial.println(F("Loop: LCDML_BACKEND_ge3"));
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_ge3)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_ge3"));
|
||||
Serial.println(F("=================================="));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
uint8_t g_state_counter = 0;
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_state_1)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_state_1"));
|
||||
Serial.println(F("============================"));
|
||||
Serial.println(F("count until 5"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_state_1)
|
||||
{
|
||||
// runs in loop
|
||||
if(g_state_counter == 5) {
|
||||
// stopStable this function
|
||||
LCDML_BACK_stopStable(LCDML_BACKEND_state_1);
|
||||
// go to next state with restart (runs setup again)
|
||||
LCDML_BACK_restart(LCDML_BACKEND_state_2);
|
||||
} else {
|
||||
// increment
|
||||
g_state_counter++;
|
||||
Serial.print(F("Loop: LCDML_BACKEND_state_1 - counter: "));
|
||||
Serial.println(g_state_counter);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_state_1)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_state_1"));
|
||||
Serial.println(F("=================================="));
|
||||
|
||||
// reset counter
|
||||
g_state_counter = 0;
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_state_2)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_state_2"));
|
||||
Serial.println(F("============================"));
|
||||
Serial.println(F("count until 10"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_state_2)
|
||||
{
|
||||
// runs in loop
|
||||
if(g_state_counter == 10) {
|
||||
// stopStable this function
|
||||
LCDML_BACK_stopStable(LCDML_BACKEND_state_2);
|
||||
// go to next state with restart (runs setup again)
|
||||
LCDML_BACK_restart(LCDML_BACKEND_state_3);
|
||||
} else {
|
||||
// increment
|
||||
g_state_counter++;
|
||||
Serial.print(F("Loop: LCDML_BACKEND_state_2 - counter: "));
|
||||
Serial.println(g_state_counter);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_state_2)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_state_2"));
|
||||
Serial.println(F("=================================="));
|
||||
|
||||
// reset counter
|
||||
g_state_counter = 0;
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_state_3)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_state_3"));
|
||||
Serial.println(F("============================"));
|
||||
Serial.println(F("count until 2"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_state_3)
|
||||
{
|
||||
// runs in loop
|
||||
if(g_state_counter == 2) {
|
||||
// stopStable this function
|
||||
LCDML_BACK_stopStable(LCDML_BACKEND_state_3);
|
||||
// go to next state with restart (runs setup again)
|
||||
LCDML_BACK_restart(LCDML_BACKEND_state_4);
|
||||
} else {
|
||||
// increment
|
||||
g_state_counter++;
|
||||
Serial.print(F("Loop: LCDML_BACKEND_state_3 - counter: "));
|
||||
Serial.println(g_state_counter);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_state_3)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_state_3"));
|
||||
Serial.println(F("=================================="));
|
||||
|
||||
// reset counter
|
||||
g_state_counter = 0;
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_state_4)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_state_4"));
|
||||
Serial.println(F("============================"));
|
||||
Serial.println(F("count until 5 and destroy itself"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_state_4)
|
||||
{
|
||||
// runs in loop
|
||||
if(g_state_counter == 5) {
|
||||
// stopStable this function
|
||||
LCDML_BACK_stopStable(LCDML_BACKEND_state_4);
|
||||
} else {
|
||||
// increment
|
||||
g_state_counter++;
|
||||
Serial.print(F("Loop: LCDML_BACKEND_state_4 - counter: "));
|
||||
Serial.println(g_state_counter);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_state_4)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_state_4"));
|
||||
Serial.println(F("=================================="));
|
||||
|
||||
// reset counter
|
||||
g_state_counter = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_event)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_event"));
|
||||
Serial.println(F("============================"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_event)
|
||||
{
|
||||
// runs in loop
|
||||
Serial.println(F("Loop: LCDML_BACKEND_event - only loop is called and stopped once again"));
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_event)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_event"));
|
||||
Serial.println(F("=================================="));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
uint8_t g_ping_pong_counter = 0;
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_signals_ping)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_signals_ping"));
|
||||
Serial.println(F("============================"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_signals_ping)
|
||||
{
|
||||
// runs in loop
|
||||
/*
|
||||
if(LCDML_BACK_signal_get(signal_from_ping_to_ping)) {
|
||||
if(g_ping_pong_counter >= 10) {
|
||||
LCDML_BACK_stopStable(LCDML_BACKEND_signals_ping);
|
||||
LCDML_BACK_stopStable(LCDML_BACKEND_signals_pong);
|
||||
g_ping_pong_counter = 0;
|
||||
LCDML_BACK_signal_clear(signal_from_ping_to_ping);
|
||||
LCDML_BACK_signal_clear(signal_from_ping_to_pong);
|
||||
}
|
||||
LCDML_BACK_signal_clear(signal_from_ping_to_ping);
|
||||
LCDML_BACK_signal_set(signal_from_ping_to_pong);
|
||||
Serial.println(F("Loop: LCDML_BACKEND_signals_ping - get signal"));
|
||||
g_ping_pong_counter++;
|
||||
} else {
|
||||
Serial.println(F("Loop: LCDML_BACKEND_signals_ping - no signal"));
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_signals_ping)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_signals_ping"));
|
||||
Serial.println(F("=================================="));
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_signals_pong)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_signals_pong"));
|
||||
Serial.println(F("============================"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_signals_pong)
|
||||
{
|
||||
// runs in loop
|
||||
/*
|
||||
if(LCDML_BACK_signal_get(signal_from_ping_to_pong)) {
|
||||
LCDML_BACK_signal_clear(signal_from_ping_to_pong);
|
||||
LCDML_BACK_signal_set(signal_from_ping_to_ping);
|
||||
Serial.println(F("Loop: LCDML_BACKEND_signals_pong - get signal"));
|
||||
g_ping_pong_counter++;
|
||||
} else {
|
||||
Serial.println(F("Loop: LCDML_BACKEND_signals_pong - no signal"));
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_signals_pong)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_signals_pong"));
|
||||
Serial.println(F("=================================="));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_kill_system_3)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_kill_system_3"));
|
||||
Serial.println(F("============================"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_kill_system_3)
|
||||
{
|
||||
// runs in loop
|
||||
Serial.println(F("Loop: LCDML_BACKEND_kill_system_3"));
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_kill_system_3)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_kill_system_3"));
|
||||
Serial.println(F("=================================="));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_kill_system_4)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_kill_system_4"));
|
||||
Serial.println(F("============================"));
|
||||
// set loop time to zero
|
||||
LCDML_BACK_dynamic_setLoopTime(LCDML_BACKEND_kill_system_4, 0);
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_kill_system_4)
|
||||
{
|
||||
// runs in loop
|
||||
Serial.println(F("Loop: LCDML_BACKEND_kill_system_4"));
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_kill_system_4)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Setup: LCDML_BACKEND_kill_system_4"));
|
||||
Serial.println(F("============================"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
unsigned long g_real_loop_time_old = millis();
|
||||
void LCDML_BACK_setup(LCDML_BACKEND_idle)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// is called only if it is started or restartet (reset+start)
|
||||
Serial.println(F("Setup: LCDML_BACKEND_idle"));
|
||||
Serial.println(F("============================"));
|
||||
Serial.println(F("This function is called every 30 secounds"));
|
||||
Serial.println(F("If this function is not called, the loop time of other threads was set wrong"));
|
||||
}
|
||||
boolean LCDML_BACK_loop(LCDML_BACKEND_idle)
|
||||
{
|
||||
// runs in loop
|
||||
Serial.print(F("Loop: LCDML_BACKEND_idle - real loop time: "));
|
||||
Serial.print((float)((millis() - g_real_loop_time_old)/1000.));
|
||||
Serial.println(" [s]");
|
||||
g_real_loop_time_old = millis();
|
||||
return false;
|
||||
}
|
||||
void LCDML_BACK_stable(LCDML_BACKEND_idle)
|
||||
{
|
||||
// stable stop
|
||||
// is called when a backend function is stopped with stopStable
|
||||
Serial.println(F("Stop Stable: LCDML_BACKEND_event"));
|
||||
Serial.println(F("=================================="));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
/* ===================================================================== *
|
||||
* *
|
||||
* 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_static)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// use parameter on menu init
|
||||
uint8_t param = LCDML_DISP_getParameter();
|
||||
switch(param)
|
||||
{
|
||||
case 1: // start backend
|
||||
LCDML_BACK_start(LCDML_BACKEND_static);
|
||||
break;
|
||||
|
||||
case 2: // reset backend
|
||||
LCDML_BACK_reset(LCDML_BACKEND_static);
|
||||
break;
|
||||
|
||||
case 3: // stop backend
|
||||
LCDML_BACK_stop(LCDML_BACKEND_static);
|
||||
break;
|
||||
|
||||
case 4: // restart backend
|
||||
LCDML_BACK_reset(LCDML_BACKEND_static);
|
||||
break;
|
||||
|
||||
case 5: // stop stable
|
||||
LCDML_BACK_stopStable(LCDML_BACKEND_static);
|
||||
break;
|
||||
|
||||
default:
|
||||
Serial.println(F("Wrong Parameter: LCDML_FUNC_static"));
|
||||
break;
|
||||
}
|
||||
// quit
|
||||
LCDML_DISP_funcend();
|
||||
}
|
||||
void LCDML_DISP_loop(LCDML_FUNC_static)
|
||||
{ // loop
|
||||
}
|
||||
void LCDML_DISP_loop_end(LCDML_FUNC_static)
|
||||
{ // loop end
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_DISP_setup(LCDML_FUNC_dynamic)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// use parameter on menu init
|
||||
uint8_t param = LCDML_DISP_getParameter();
|
||||
switch(param)
|
||||
{
|
||||
case 1: // Start
|
||||
LCDML_BACK_start(LCDML_BACKEND_dynamic);
|
||||
break;
|
||||
|
||||
case 2: // Stop Stable
|
||||
LCDML_BACK_stopStable(LCDML_BACKEND_dynamic);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
Serial.println(F("not implemented -> next beta 4"));
|
||||
break;
|
||||
|
||||
default:
|
||||
Serial.println(F("Wrong Parameter: LCDML_FUNC_dynamic"));
|
||||
break;
|
||||
}
|
||||
// quit
|
||||
LCDML_DISP_funcend();
|
||||
}
|
||||
void LCDML_DISP_loop(LCDML_FUNC_dynamic)
|
||||
{ // loop
|
||||
}
|
||||
void LCDML_DISP_loop_end(LCDML_FUNC_dynamic)
|
||||
{ // loop end
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_DISP_setup(LCDML_FUNC_group)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// use parameter on menu init
|
||||
uint8_t param = LCDML_DISP_getParameter();
|
||||
switch(param)
|
||||
{
|
||||
case 1: // start group
|
||||
LCDML_BACK_group_start(GROUP_group_example);
|
||||
break;
|
||||
|
||||
case 2: // group stop
|
||||
LCDML_BACK_group_stop(GROUP_group_example);
|
||||
break;
|
||||
|
||||
default:
|
||||
Serial.println(F("Wrong Parameter: LCDML_FUNC_group"));
|
||||
break;
|
||||
}
|
||||
// quit
|
||||
LCDML_DISP_funcend();
|
||||
}
|
||||
void LCDML_DISP_loop(LCDML_FUNC_group)
|
||||
{ // loop
|
||||
}
|
||||
void LCDML_DISP_loop_end(LCDML_FUNC_group)
|
||||
{ // loop end
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_DISP_setup(LCDML_FUNC_state_start)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// start backend function with restart (setup runs again)
|
||||
LCDML_BACK_restart(LCDML_BACKEND_state_1);
|
||||
LCDML_DISP_funcend();
|
||||
}
|
||||
void LCDML_DISP_loop(LCDML_FUNC_state_start)
|
||||
{ // loop
|
||||
}
|
||||
|
||||
void LCDML_DISP_loop_end(LCDML_FUNC_state_start)
|
||||
{ // loop end
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_DISP_setup(LCDML_FUNC_trigger_event)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
LCDML_BACK_start(LCDML_BACKEND_event);
|
||||
LCDML_DISP_funcend();
|
||||
}
|
||||
|
||||
void LCDML_DISP_loop(LCDML_FUNC_trigger_event)
|
||||
{ // loop
|
||||
}
|
||||
|
||||
void LCDML_DISP_loop_end(LCDML_FUNC_trigger_event)
|
||||
{ // loop end
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_DISP_setup(LCDML_FUNC_ping_pong)
|
||||
// *********************************************************************
|
||||
{
|
||||
// starts backend functions
|
||||
/*
|
||||
LCDML_BACK_signal_set(signal_from_ping_to_ping);
|
||||
LCDML_BACK_restart(LCDML_BACKEND_signals_ping);
|
||||
LCDML_BACK_restart(LCDML_BACKEND_signals_pong);
|
||||
*/
|
||||
Serial.println(F("LCDML_FUNC_ping_pong: beta 4"));
|
||||
LCDML_DISP_funcend();
|
||||
}
|
||||
|
||||
void LCDML_DISP_loop(LCDML_FUNC_ping_pong)
|
||||
{ // loop
|
||||
}
|
||||
|
||||
void LCDML_DISP_loop_end(LCDML_FUNC_ping_pong)
|
||||
{ // loop end
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
void LCDML_DISP_setup(LCDML_FUNC_kill)
|
||||
// *********************************************************************
|
||||
{
|
||||
// setup
|
||||
// use parameter on menu init
|
||||
uint8_t param = LCDML_DISP_getParameter();
|
||||
switch(param)
|
||||
{
|
||||
case 1: // stop all backend function
|
||||
LCDML_BACK_all_stop();
|
||||
break;
|
||||
|
||||
case 2: // restart all backend function
|
||||
LCDML_BACK_all_restart();
|
||||
break;
|
||||
|
||||
case 3: // start a function with static time 0
|
||||
LCDML_BACK_start(LCDML_BACKEND_kill_system_3);
|
||||
break;
|
||||
|
||||
case 4: // start a dynamic function and set loop time to 0
|
||||
LCDML_BACK_start(LCDML_BACKEND_kill_system_4);
|
||||
break;
|
||||
|
||||
default:
|
||||
Serial.println(F("Wrong Parameter: LCDML_FUNC_group"));
|
||||
break;
|
||||
}
|
||||
// quit
|
||||
LCDML_DISP_funcend();
|
||||
}
|
||||
void LCDML_DISP_loop(LCDML_FUNC_kill)
|
||||
{ // loop
|
||||
}
|
||||
void LCDML_DISP_loop_end(LCDML_FUNC_kill)
|
||||
{ // loop end
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
// ============================================================
|
||||
// Example: LCDML: serialmonitor
|
||||
// ============================================================
|
||||
// Autor: Nils Feldkämper
|
||||
// Last update: 08.01.2017
|
||||
// License: MIT
|
||||
// ============================================================
|
||||
// Descripton:
|
||||
//
|
||||
// ============================================================
|
||||
|
||||
// include libs
|
||||
#include <LiquidCrystal.h>
|
||||
#include <LCDMenuLib.h>
|
||||
|
||||
// lib config
|
||||
#define _LCDML_DISP_cfg_button_press_time 200 // button press time in ms
|
||||
#define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar
|
||||
#define _LCDML_DISP_cfg_cursor 0x7E // cursor Symbol
|
||||
|
||||
// *********************************************************************
|
||||
// LCDML TYPE SELECT
|
||||
// *********************************************************************
|
||||
// settings for lcd
|
||||
#define _LCDML_DISP_cols 20
|
||||
#define _LCDML_DISP_rows 4
|
||||
|
||||
// lcd object
|
||||
// liquid crystal needs (rs, e, dat4, dat5, dat6, dat7)
|
||||
LiquidCrystal lcd(4,5,6,7,8,9);
|
||||
|
||||
const uint8_t scroll_bar[5][8] = {
|
||||
{B10001, B10001, B10001, B10001, B10001, B10001, B10001, B10001}, // scrollbar top
|
||||
{B11111, B11111, B10001, B10001, B10001, B10001, B10001, B10001}, // scroll state 1
|
||||
{B10001, B10001, B11111, B11111, B10001, B10001, B10001, B10001}, // scroll state 2
|
||||
{B10001, B10001, B10001, B10001, B11111, B11111, B10001, B10001}, // scroll state 3
|
||||
{B10001, B10001, B10001, B10001, B10001, B10001, B11111, B11111} // scrollbar bottom
|
||||
};
|
||||
|
||||
// *********************************************************************
|
||||
// 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 26
|
||||
|
||||
// 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)
|
||||
// LCDMenuLib_addMenu (id, group, prev_layer_element, new_element_num, lang_char_array)
|
||||
// LCDMenuLib_addParam(id, group, prev_layer_element, new_element_num, lang_char_array, callback_function, parameter [0-255]) // needs LCDML_DISP_initParam
|
||||
|
||||
//LCDML_DISP_init(_LCDML_DISP_cnt);
|
||||
LCDML_DISP_initParam(_LCDML_DISP_cnt); // enbable parameters (needs one byte per menu element)
|
||||
// Menu
|
||||
LCDML_DISP_addMenu (0 , _LCDML_G1 , LCDML_root , 1 , "Backend Basic");
|
||||
LCDML_DISP_addMenu (1 , _LCDML_G1 , LCDML_root_1 , 1 , "Func (static)");
|
||||
LCDML_DISP_addParam (2 , _LCDML_G1 , LCDML_root_1_1 , 1 , "Start" , LCDML_FUNC_static, 1);
|
||||
LCDML_DISP_addParam (3 , _LCDML_G1 , LCDML_root_1_1 , 2 , "Reset" , LCDML_FUNC_static, 2);
|
||||
LCDML_DISP_addParam (4 , _LCDML_G1 , LCDML_root_1_1 , 3 , "Stop" , LCDML_FUNC_static, 3);
|
||||
LCDML_DISP_addParam (5 , _LCDML_G1 , LCDML_root_1_1 , 4 , "Restart" , LCDML_FUNC_static, 4);
|
||||
LCDML_DISP_addParam (6 , _LCDML_G1 , LCDML_root_1_1 , 5 , "Stop stable" , LCDML_FUNC_static, 5);
|
||||
LCDML_DISP_addMenu (7 , _LCDML_G1 , LCDML_root_1 , 2 , "Func (dynamic)");
|
||||
LCDML_DISP_addParam (8 , _LCDML_G1 , LCDML_root_1_2 , 1 , "Start" , LCDML_FUNC_dynamic, 1);
|
||||
LCDML_DISP_addParam (9 , _LCDML_G1 , LCDML_root_1_2 , 2 , "Stop Stable" , LCDML_FUNC_dynamic, 2);
|
||||
LCDML_DISP_addParam (10 , _LCDML_G1 , LCDML_root_1_2 , 3 , "Set Time" , LCDML_FUNC_dynamic, 3);
|
||||
LCDML_DISP_addMenu (11 , _LCDML_G1 , LCDML_root , 2 , "Backend Groups");
|
||||
LCDML_DISP_addParam (12 , _LCDML_G1 , LCDML_root_2 , 1 , "Group start" , LCDML_FUNC_group, 1);
|
||||
LCDML_DISP_addParam (13 , _LCDML_G1 , LCDML_root_2 , 2 , "Group stop" , LCDML_FUNC_group, 2);
|
||||
LCDML_DISP_addMenu (14 , _LCDML_G1 , LCDML_root , 3 , "Backend State-M.");
|
||||
LCDML_DISP_add (15 , _LCDML_G1 , LCDML_root_3 , 1 , "Start" , LCDML_FUNC_state_start);
|
||||
LCDML_DISP_addMenu (16 , _LCDML_G1 , LCDML_root , 4 , "Backend Event");
|
||||
LCDML_DISP_add (17 , _LCDML_G1 , LCDML_root_4 , 1 , "Trigger" , LCDML_FUNC_trigger_event);
|
||||
LCDML_DISP_addMenu (18 , _LCDML_G1 , LCDML_root , 5 , "Backend Signals");
|
||||
LCDML_DISP_add (19 , _LCDML_G1 , LCDML_root_5 , 1 , "Ping Pong" , LCDML_FUNC_ping_pong);
|
||||
LCDML_DISP_addMenu (20 , _LCDML_G1 , LCDML_root , 6 , "Destroy System");
|
||||
LCDML_DISP_addMenu (21 , _LCDML_G1 , LCDML_root_6 , 1 , "restart helps");
|
||||
LCDML_DISP_addMenu (22 , _LCDML_G1 , LCDML_root_6 , 2 , "Kill");
|
||||
LCDML_DISP_addParam (23 , _LCDML_G1 , LCDML_root_6_2 , 1 , "stopp all" , LCDML_FUNC_kill, 1);
|
||||
LCDML_DISP_addParam (24 , _LCDML_G1 , LCDML_root_6_2 , 2 , "restart all" , LCDML_FUNC_kill, 2);
|
||||
LCDML_DISP_addParam (25 , _LCDML_G1 , LCDML_root_6_2 , 3 , "static init 0", LCDML_FUNC_kill, 3);
|
||||
LCDML_DISP_addParam (26 , _LCDML_G1 , LCDML_root_6_2 , 4 , "dyn set to 0" , LCDML_FUNC_kill, 4);
|
||||
// create Menu
|
||||
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 16 // last backend function id
|
||||
|
||||
LCDML_BACK_init(_LCDML_BACK_cnt);
|
||||
// only for example - do not make this in your real program
|
||||
LCDML_BACK_new_timebased_static (0 , ( 0UL ) , _LCDML_stop , LCDML_BACKEND_kill_system_3);
|
||||
LCDML_BACK_new_timebased_dynamic (1 , ( 1000UL ) , _LCDML_stop , LCDML_BACKEND_kill_system_4);
|
||||
// menu function and control function
|
||||
LCDML_BACK_new_timebased_dynamic (2 , ( 20UL ) , _LCDML_start , LCDML_BACKEND_control);
|
||||
LCDML_BACK_new_timebased_dynamic (3 , ( 1000UL ) , _LCDML_stop , LCDML_BACKEND_menu);
|
||||
// custom backend function
|
||||
// static time example
|
||||
LCDML_BACK_new_timebased_static (4 , ( 500UL ) , _LCDML_stop , LCDML_BACKEND_static);
|
||||
// dynamic time example
|
||||
LCDML_BACK_new_timebased_dynamic (5 , ( 4000UL ) , _LCDML_stop , LCDML_BACKEND_dynamic);
|
||||
// groups example
|
||||
LCDML_BACK_new_timebased_static (6 , ( 1533UL ) , _LCDML_stop , LCDML_BACKEND_ge1);
|
||||
LCDML_BACK_new_timebased_static (7 , ( 2727UL ) , _LCDML_stop , LCDML_BACKEND_ge2);
|
||||
LCDML_BACK_new_timebased_static (8 , ( 3918UL ) , _LCDML_stop , LCDML_BACKEND_ge3);
|
||||
// state maschine
|
||||
LCDML_BACK_new_timebased_static (9 , ( 500UL ) , _LCDML_stop , LCDML_BACKEND_state_1);
|
||||
LCDML_BACK_new_timebased_static (10 , ( 500UL ) , _LCDML_stop , LCDML_BACKEND_state_2);
|
||||
LCDML_BACK_new_timebased_static (11 , ( 500UL ) , _LCDML_stop , LCDML_BACKEND_state_3);
|
||||
LCDML_BACK_new_timebased_static (12 , ( 500UL ) , _LCDML_stop , LCDML_BACKEND_state_4);
|
||||
// event
|
||||
LCDML_BACK_new_eventbased (13 , LCDML_BACKEND_event);
|
||||
// signals - ping pong
|
||||
LCDML_BACK_new_timebased_static (14 , ( 2000UL ) , _LCDML_stop , LCDML_BACKEND_signals_ping);
|
||||
LCDML_BACK_new_timebased_static (15 , ( 500UL ) , _LCDML_stop , LCDML_BACKEND_signals_pong);
|
||||
|
||||
// this backend function is only for debug
|
||||
LCDML_BACK_new_timebased_static (16 , ( 30000UL ) , _LCDML_start , LCDML_BACKEND_idle);
|
||||
LCDML_BACK_create();
|
||||
|
||||
|
||||
// Groups
|
||||
// =========
|
||||
// for group example
|
||||
LCDML_BACK_group_init(GROUP_group_example, 3)
|
||||
{
|
||||
LCDML_BACK_group(LCDML_BACKEND_ge1),
|
||||
LCDML_BACK_group(LCDML_BACKEND_ge2),
|
||||
LCDML_BACK_group(LCDML_BACKEND_ge3),
|
||||
};
|
||||
|
||||
// for state mashine
|
||||
LCDML_BACK_group_init(GROUP_state_mashine, 4)
|
||||
{
|
||||
LCDML_BACK_group(LCDML_BACKEND_state_1),
|
||||
LCDML_BACK_group(LCDML_BACKEND_state_2),
|
||||
LCDML_BACK_group(LCDML_BACKEND_state_3),
|
||||
LCDML_BACK_group(LCDML_BACKEND_state_4),
|
||||
};
|
||||
|
||||
// for ping pong example
|
||||
LCDML_BACK_group_init(GROUP_ping_pong, 2)
|
||||
{
|
||||
LCDML_BACK_group(LCDML_BACKEND_signals_ping),
|
||||
LCDML_BACK_group(LCDML_BACKEND_signals_pong),
|
||||
};
|
||||
|
||||
// Signals
|
||||
// ========
|
||||
// here are some signals defined
|
||||
/* beta 4
|
||||
LCDML_BACK_signal_init(2);
|
||||
LCDML_BACK_signal(0, signal_from_ping_to_pong);
|
||||
LCDML_BACK_signal(1, signal_from_pong_to_ping);
|
||||
*/
|
||||
|
||||
// *********************************************************************
|
||||
// SETUP
|
||||
// *********************************************************************
|
||||
void setup()
|
||||
{
|
||||
// serial init; only be needed if serial control is used
|
||||
Serial.begin(9600); // start serial
|
||||
Serial.println(F(_LCDML_VERSION)); // only for examples
|
||||
|
||||
// LCD Begin
|
||||
lcd.begin(_LCDML_DISP_cols,_LCDML_DISP_rows);
|
||||
// set special chars for scrollbar
|
||||
lcd.createChar(0, (uint8_t*)scroll_bar[0]);
|
||||
lcd.createChar(1, (uint8_t*)scroll_bar[1]);
|
||||
lcd.createChar(2, (uint8_t*)scroll_bar[2]);
|
||||
lcd.createChar(3, (uint8_t*)scroll_bar[3]);
|
||||
lcd.createChar(4, (uint8_t*)scroll_bar[4]);
|
||||
|
||||
// Enable all items with _LCDML_G1 and _LCDML_G2
|
||||
LCDML_DISP_groupEnable(_LCDML_G1); // enable group 1
|
||||
|
||||
// Enable menu rollover if needed
|
||||
//LCDML.enRollover();
|
||||
|
||||
// LCDMenu Setup
|
||||
LCDML_setup(_LCDML_BACK_cnt);
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
// LOOP
|
||||
// *********************************************************************
|
||||
void loop()
|
||||
{
|
||||
// this function must called here, do not delete it
|
||||
LCDML_run(_LCDML_priority);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// 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
|
||||
Reference in New Issue
Block a user