This is not a double post as this is descriptive to the LiquidMenu library involving a issue with the examples which use the button library, and includes a button header file in the examples that use said file.
I am assuming you must already have the button library installed before using this menu library, and are suppose to replace the button header file with the one provided in the example. It does not state this in the readme what if anything should be down with the button header file in the examples which include it.
After fixing previous flaws with the installation, and properly configuring the lcd to I2C. I wanted to test the focus example to get a better understanding of what focus does exactly. I moved the button.h to the button library, properly configured the code for the i2c display, hit compile, error... with button.cpp. Shit, there wasn't one included with the menu library so I don't know what to do about the errors, or what would be the best replacement for the check() function in the focus example of liquidmenu. Does anyone know what button library is expected to be installed which has the proper .cpp file? I am including the errors, and sketch that supplied such errors.
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\Bob\\Documents\\Arduino\\libraries\\LiquidCrystal_I2C" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Users\\Bob\\Documents\\Arduino\\libraries\\LiquidMenu-1.4.1\\src" "-IC:\\Users\\Bob\\Documents\\Arduino\\libraries\\Button" "C:\\Users\\Bob\\Documents\\Arduino\\libraries\\Button\\Button.cpp" -o "C:\\Users\\Bob\\AppData\\Local\\Temp\\arduino_build_360648\\libraries\\Button\\Button.cpp.o"
In file included from C:\Users\Bob\Documents\Arduino\libraries\Button\Button.cpp:21:0:
C:\Users\Bob\Documents\Arduino\libraries\Button\Button.h:5:18: error: expected ')' before 'pin'
Button (uint8_t pin, bool pullup = false, uint16_t debounceDelay = 50)
^
C:\Users\Bob\Documents\Arduino\libraries\Button\Button.cpp:93:1: error: expected '}' at end of input
}
^
C:\Users\Bob\Documents\Arduino\libraries\Button\Button.cpp:93:1: error: expected unqualified-id at end of input
Using library LiquidCrystal_I2C at version 1.1.2 in folder: C:\Users\Bob\Documents\Arduino\libraries\LiquidCrystal_I2C
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Using library LiquidMenu-1.4.1 at version 1.4.0 in folder: C:\Users\Bob\Documents\Arduino\libraries\LiquidMenu-1.4.1
Using library Button in folder: C:\Users\Bob\Documents\Arduino\libraries\Button (legacy)
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
/*
||
|| @file Button.cpp
|| @version 1.6
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Provide an easy way of making buttons
|| #
||
|| @license
|| | Copyright (c) 2009 Alexander Brevig. All rights reserved.
|| | This code is subject to AlphaLicence.txt
|| | alphabeta.alexanderbrevig.com/AlphaLicense.txt
|| #
||
*/
//include the class definition
#include "Button.h"
/*
|| <<constructor>>
|| @parameter buttonPin sets the pin that this switch is connected to
|| @parameter buttonMode indicates PULLUP or PULLDOWN resistor
*/
Button::Button(uint8_t buttonPin, uint8_t buttonMode){
this->pin=buttonPin;
pinMode(pin,INPUT);
buttonMode==PULLDOWN ? pulldown() : pullup();
state = 0;
bitWrite(state,CURRENT,!mode);
}
/*
|| Set pin HIGH as default
*/
void Button::pullup(void){
mode=PULLUP;
digitalWrite(pin,HIGH);
}
/*
|| Set pin LOW as default
*/
void Button::pulldown(void){
mode=PULLDOWN;
//digitalWrite(pin,LOW);
}
/*
|| Return the bitWrite(state,CURRENT, of the switch
*/
bool Button::isPressed(void){
bitWrite(state,PREVIOUS,bitRead(state,CURRENT));
if (digitalRead(pin) == mode){
bitWrite(state,CURRENT,false);
} else {
bitWrite(state,CURRENT,true);
}
if (bitRead(state,CURRENT) != bitRead(state,PREVIOUS)){
bitWrite(state,CHANGED,true);
}else{
bitWrite(state,CHANGED,false);
}
return bitRead(state,CURRENT);
}
/*
|| Return true if the button has been pressed
*/
bool Button::wasPressed(void){
if (bitRead(state,CURRENT)){
return true;
} else {
return false;
}
}
/*
|| Return true if state has been changed
*/
bool Button::stateChanged(void){
return bitRead(state,CHANGED);
}
/*
|| Return true if the button is pressed, and was not pressed before
*/
bool Button::uniquePress(void){
return (isPressed() && stateChanged());
}
https://playground.arduino.cc/Code/Button/
I downloaded from here.