Menürendszer LCD-n
Menürendszer LCD-n
Ismertek valami olyan könyvtárat, amit arra lehetne használni, hogy menürendszert kezeljünk LCD-n, ahol a menüpontok között mozogni gombokkal lehet?
Re: Menürendszer LCD-n
Ilyeneket én is találtam, csak azt hittem van valami konkrét javaslat, hogy ki mit használ, mert akkor azzal kezdeném, nem kísérleteznék Na mindegy, azért köszi
Re: Menürendszer LCD-n
Próbálkozok egy saját megvalósítással, eseményvezérelt módon. A gondom az, hogy vlami szintaktikai hiba miatt le sem fordul a program (zárójelet hiányol).
Kód: Egész kijelölése
void gombnyomas(){
if (digitalRead(ENTERgomb)==HIGH) {
menuszint++;
menubelep(menuszint);
}
else if (digitalRead(LEgomb)==HIGH) lefele();
else if (digitalRead(FELgomb)==HIGH) felfele();
else if (digitalRead(KILEPgomb)==HIGH) {
if (menuszint>0) {
menuszint--;
menubelep(menuszint);
}
}
}
Re: Menürendszer LCD-n
Elseif-ek környékén nincsen....
helyett
Kód: Egész kijelölése
else if (digitalRead(LEgomb)==HIGH) lefele();
Kód: Egész kijelölése
else if (digitalRead(LEgomb)==HIGH) {
lefele();
}
Re: Menürendszer LCD-n
Érdekes, én korábban C-ben tanultam programozni, ott ha csak 1 utasítás volt, akkor nem kellett kapcsos zárójelek közé tenni. Na mindegy, kipróbálom, köszi
Re: Menürendszer LCD-n
Na közben rájöttem: a #define-os sorok végére is tettem pontosvesszőt és így a pontosvesszőt is behelyettesítette a fordító... Mostmár csak pár hiba van:
LCD.ino: In function 'void fomenu()':
LCD:84: error: statement cannot resolve address of overloaded function
LCD.ino: In function 'void orabeallitas()':
LCD error: statement cannot resolve address of overloaded function
Itt a kód:
LCD.ino: In function 'void fomenu()':
LCD:84: error: statement cannot resolve address of overloaded function
LCD.ino: In function 'void orabeallitas()':
LCD error: statement cannot resolve address of overloaded function
Itt a kód:
Kód: Egész kijelölése
#include <LiquidCrystal.h>
#include <Time.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(22,23,24,25,26,27);
byte a1[8] = {
B10,B100,B1110,B1,B1111,B10001,B1111};
byte e1[8] = {
B10,B100,B1110,B10001,B11111,B10000,B1110};
byte i1[8] = {
B10,B100,B0,B1110,B100,B100,B1110};
byte o1[8] = {
B100,B100,B0,B1110,B10001,B10001,B1110};
byte o2[8] = {
B1010,B0,B1110,B10001,B10001,B10001,B1110};
byte o3[8] = {
B1010,B1010,B0,B1110,B10001,B10001,B1110};
byte u1[8] = {
B10,B100,B10001,B10001,B10001,B10011,B1101};
byte u2[8] = {
B1010,B0,B0,B10001,B10001,B10011,B1101};
byte u3[8] = {
B1010,B1010,B0,B10001,B10001,B10011,B1101};
time_t t = now();
#define ENTERgomb 9
#define LEgomb 7
#define FELgomb 8
#define KILEPgomb 6
byte menuszint=0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(20,4);
lcd.createChar(0, a1);
lcd.createChar(1, e1);
lcd.createChar(2, i1);
lcd.createChar(3, o1);
lcd.createChar(4, o3);
lcd.createChar(5, u1);
lcd.createChar(6, u2);
lcd.createChar(7, u3);
setTime(19,19,0,21,10,2013);
attachInterrupt(0, gombnyomas, RISING);
fomenu();
}
void loop() {
if (menuszint==0){
lcd.setCursor(14,1);
t = now();
lcd.print(hour(t));
lcd.write(":");
if (minute(t)<10) {
lcd.print("0");
lcd.print(minute(t));
}
else lcd.print(minute(t));
}
}
void gombnyomas(){
if (digitalRead(ENTERgomb)==HIGH) {
menuszint++;
menubelep(menuszint);
}
// else if (digitalRead(LEgomb)==HIGH) lefele();
// else if (digitalRead(FELgomb)==HIGH) felfele();
else if (digitalRead(KILEPgomb)==HIGH) {
if (menuszint>0) {
menuszint--;
menubelep(menuszint);
}
}
}
void menubelep(byte szint){
if (szint==0) fomenu();
if (szint==1) orabeallitas();
}
void fomenu(){
lcd.clear;
lcd.setCursor(0,0);
lcd.print("H");
lcd.write(4);
lcd.write("m");
lcd.write(1);
lcd.print("rs");
lcd.write(1);
lcd.print("klet: 20.5");
lcd.setCursor(0,1);
lcd.print("Id");
lcd.write(4);
lcd.write(": ");
}
void orabeallitas(){
lcd.clear;
lcd.setCursor(0,0);
lcd.print("Ora:");
lcd.setCursor(0,17);
lcd.print(hour(t));
lcd.setCursor(1,0);
lcd.print("Perc:");
lcd.setCursor(1,17);
lcd.print(minute(t));
}
Re: Menürendszer LCD-n
Valakinek ötlet esetleg?
Re: Menürendszer LCD-n
Szevasz!
A clear is függvény vagy mi:D
Kéne neki nyitó/zárójel.
A clear is függvény vagy mi:D
Kéne neki nyitó/zárójel.
Re: Menürendszer LCD-n
És tényleg, köszönöm
-
- Újonc
- Hozzászólások: 10
- Csatlakozott: 2016. május 22. vasárnap, 20:26
Re: Menürendszer LCD-n
Sziasztok!
Szerettem volna a kijelzőmre egy menüt.
Ezt a kódot találtam,de nem működik.
Mi lehet a hiba?
Ezt a hibaüzenetet kapom!
Arduino: 1.5.7 (Windows , Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
sketch_jul02a.ino: In function 'void setup()':
sketch_jul02a.ino:81:8: error: 'class MenuBackend' has no member named 'toRoot'
sketch_jul02a.ino: In function 'void menuUsed(MenuUseEvent)':
sketch_jul02a.ino:132:8: error: 'class MenuBackend' has no member named 'toRoot'
sketch_jul02a.ino: In function 'void navigateMenus()':
sketch_jul02a.ino:276:12: error: 'class MenuBackend' has no member named 'toRoot'
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Szerettem volna a kijelzőmre egy menüt.
Ezt a kódot találtam,de nem működik.
Mi lehet a hiba?
Ezt a hibaüzenetet kapom!
Arduino: 1.5.7 (Windows , Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
sketch_jul02a.ino: In function 'void setup()':
sketch_jul02a.ino:81:8: error: 'class MenuBackend' has no member named 'toRoot'
sketch_jul02a.ino: In function 'void menuUsed(MenuUseEvent)':
sketch_jul02a.ino:132:8: error: 'class MenuBackend' has no member named 'toRoot'
sketch_jul02a.ino: In function 'void navigateMenus()':
sketch_jul02a.ino:276:12: error: 'class MenuBackend' has no member named 'toRoot'
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Kód: Egész kijelölése
/*
Copyright Giuseppe Di Cillo (www.coagula.org)
Contact: dicillo@coagula.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
IMPORTANT: to use the menubackend library by Alexander Brevig download it at http://www.arduino.cc/playground/uploads/Profiles/MenuBackend_1-4.zip and add the next code at line 195
void toRoot() {
setCurrent( &getRoot() );
}
*/
#include <MenuBackend.h> //MenuBackend library - copyright by Alexander Brevig
#include <LiquidCrystal.h> //this library is included in the Arduino IDE
const int buttonPinLeft = 8; // pin for the Up button
const int buttonPinRight = 9; // pin for the Down button
const int buttonPinEsc = 10; // pin for the Esc button
const int buttonPinEnter = 11; // pin for the Enter button
int lastButtonPushed = 0;
int lastButtonEnterState = LOW; // the previous reading from the Enter input pin
int lastButtonEscState = LOW; // the previous reading from the Esc input pin
int lastButtonLeftState = LOW; // the previous reading from the Left input pin
int lastButtonRightState = LOW; // the previous reading from the Right input pin
long lastEnterDebounceTime = 0; // the last time the output pin was toggled
long lastEscDebounceTime = 0; // the last time the output pin was toggled
long lastLeftDebounceTime = 0; // the last time the output pin was toggled
long lastRightDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 500; // the debounce time
// LiquidCrystal display with:
// rs on pin 7
// rw on ground
// enable on pin 6
// d4, d5, d6, d7 on pins 5, 4, 3, 2
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
//Menu variables
MenuBackend menu = MenuBackend(menuUsed,menuChanged);
//initialize menuitems
MenuItem menu1Item1 = MenuItem("Item1");
MenuItem menuItem1SubItem1 = MenuItem("Item1SubItem1");
MenuItem menuItem1SubItem2 = MenuItem("Item1SubItem2");
MenuItem menu1Item2 = MenuItem("Item2");
MenuItem menuItem2SubItem1 = MenuItem("Item2SubItem1");
MenuItem menuItem2SubItem2 = MenuItem("Item2SubItem2");
MenuItem menuItem3SubItem3 = MenuItem("Item2SubItem3");
MenuItem menu1Item3 = MenuItem("Item3");
void setup()
{
pinMode(buttonPinLeft, INPUT);
pinMode(buttonPinRight, INPUT);
pinMode(buttonPinEnter, INPUT);
pinMode(buttonPinEsc, INPUT);
lcd.begin(16, 2);
//configure menu
menu.getRoot().add(menu1Item1);
menu1Item1.addRight(menu1Item2).addRight(menu1Item3);
menu1Item1.add(menuItem1SubItem1).addRight(menuItem1SubItem2);
menu1Item2.add(menuItem2SubItem1).addRight(menuItem2SubItem2).addRight(menuItem3SubItem3);
menu.toRoot();
lcd.setCursor(0,0);
lcd.print("www.coagula.org");
} // setup()...
void loop()
{
readButtons(); //I splitted button reading and navigation in two procedures because
navigateMenus(); //in some situations I want to use the button for other purpose (eg. to change some settings)
} //loop()...
void menuChanged(MenuChangeEvent changed){
MenuItem newMenuItem=changed.to; //get the destination menu
lcd.setCursor(0,1); //set the start position for lcd printing to the second row
if(newMenuItem.getName()==menu.getRoot()){
lcd.print("Main Menu ");
}else if(newMenuItem.getName()=="Item1"){
lcd.print("Item1 ");
}else if(newMenuItem.getName()=="Item1SubItem1"){
lcd.print("Item1SubItem1");
}else if(newMenuItem.getName()=="Item1SubItem2"){
lcd.print("Item1SubItem2 ");
}else if(newMenuItem.getName()=="Item2"){
lcd.print("Item2 ");
}else if(newMenuItem.getName()=="Item2SubItem1"){
lcd.print("Item2SubItem1 ");
}else if(newMenuItem.getName()=="Item2SubItem2"){
lcd.print("Item2SubItem2 ");
}else if(newMenuItem.getName()=="Item2SubItem3"){
lcd.print("Item2SubItem3 ");
}else if(newMenuItem.getName()=="Item3"){
lcd.print("Item3 ");
}
}
void menuUsed(MenuUseEvent used){
lcd.setCursor(0,0);
lcd.print("You used ");
lcd.setCursor(0,1);
lcd.print(used.item.getName());
delay(3000); //delay to allow message reading
lcd.setCursor(0,0);
lcd.print("www.coagula.org");
menu.toRoot(); //back to Main
}
void readButtons(){ //read buttons status
int reading;
int buttonEnterState=LOW; // the current reading from the Enter input pin
int buttonEscState=LOW; // the current reading from the input pin
int buttonLeftState=LOW; // the current reading from the input pin
int buttonRightState=LOW; // the current reading from the input pin
//Enter button
// read the state of the switch into a local variable:
reading = digitalRead(buttonPinEnter);
// check to see if you just pressed the enter button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonEnterState) {
// reset the debouncing timer
lastEnterDebounceTime = millis();
}
if ((millis() - lastEnterDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonEnterState=reading;
lastEnterDebounceTime=millis();
}
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonEnterState = reading;
//Esc button
// read the state of the switch into a local variable:
reading = digitalRead(buttonPinEsc);
// check to see if you just pressed the Down button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonEscState) {
// reset the debouncing timer
lastEscDebounceTime = millis();
}
if ((millis() - lastEscDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonEscState = reading;
lastEscDebounceTime=millis();
}
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonEscState = reading;
//Down button
// read the state of the switch into a local variable:
reading = digitalRead(buttonPinRight);
// check to see if you just pressed the Down button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonRightState) {
// reset the debouncing timer
lastRightDebounceTime = millis();
}
if ((millis() - lastRightDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonRightState = reading;
lastRightDebounceTime =millis();
}
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonRightState = reading;
//Up button
// read the state of the switch into a local variable:
reading = digitalRead(buttonPinLeft);
// check to see if you just pressed the Down button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonLeftState) {
// reset the debouncing timer
lastLeftDebounceTime = millis();
}
if ((millis() - lastLeftDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonLeftState = reading;
lastLeftDebounceTime=millis();;
}
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonLeftState = reading;
//records which button has been pressed
if (buttonEnterState==HIGH){
lastButtonPushed=buttonPinEnter;
}else if(buttonEscState==HIGH){
lastButtonPushed=buttonPinEsc;
}else if(buttonRightState==HIGH){
lastButtonPushed=buttonPinRight;
}else if(buttonLeftState==HIGH){
lastButtonPushed=buttonPinLeft;
}else{
lastButtonPushed=0;
}
}
void navigateMenus() {
MenuItem currentMenu=menu.getCurrent();
switch (lastButtonPushed){
case buttonPinEnter:
if(!(currentMenu.moveDown())){ //if the current menu has a child and has been pressed enter then menu navigate to item below
menu.use();
}else{ //otherwise, if menu has no child and has been pressed enter the current menu is used
menu.moveDown();
}
break;
case buttonPinEsc:
menu.toRoot(); //back to main
break;
case buttonPinRight:
menu.moveRight();
break;
case buttonPinLeft:
menu.moveLeft();
break;
}
lastButtonPushed=0; //reset the lastButtonPushed variable
}
Re: Menürendszer LCD-n
Hiányzik a telepített függvénykönyvtárad.
Az Arduino 1.5.7 - BETA kiadás! 1.6.4...1.6.7 a stabil (utána BETA jellegűek jönnek megint)
Az Arduino 1.5.7 - BETA kiadás! 1.6.4...1.6.7 a stabil (utána BETA jellegűek jönnek megint)
-
- Újonc
- Hozzászólások: 10
- Csatlakozott: 2016. május 22. vasárnap, 20:26
Re: Menürendszer LCD-n
Pedig hozzáadtam a könyvtárat. Na mindegy Köszönöm,akkor megy az 1.6.4 fel
-
- Újonc
- Hozzászólások: 1
- Csatlakozott: 2017. augusztus 21. hétfő, 19:53
Re: Menürendszer LCD-n
Sziasztok! Nem tudtok véletlenül egy egyszerűen működő menü libet? Keresgéltem githubon, sajnos kevés sikerrel. Illetve van egy eléggé figyelemre méltő, de elvesztem az információk tengerében a kezelésével kapcsolatban. https://github.com/neu-rah/ArduinoMenu Nekem igazából elég lenne egy főmenüből álló görgethető menü ahol a submenükön belül egy numerikus értéket tudok variálni. Régebben készítettem egyet ami múködik is de nagyon nem szép. https://github.com/szepnorbee/kazan_controller_beta A kimeneti eszköz egy ST7735 TFT-lenne és egy 4 gombból álló resistive billentyűzet. Hasonló: https://cdn.instructables.com/F8X/QWC3/ ... MEDIUM.jpg Minden ötletet, hozzászólást szívesen fogadok. Köszi
Re: Menürendszer LCD-n
Sziasztok! Menü, submenü-t szeretnék használni, de a kiválasztáshoz Encoder-t használnék, amit megnyomva csak az Enter gomb-om van.
Van valakinek ötlete? Rengeteget átnéztem, de általában a 4 gombos menüvezérlést részesítik előnyben. Aki Encodert használ annak a menürendszerén pedig nem tudok végigmenni elemezni, megtanulni, felhasználni. Köszönettel
Van valakinek ötlete? Rengeteget átnéztem, de általában a 4 gombos menüvezérlést részesítik előnyben. Aki Encodert használ annak a menürendszerén pedig nem tudok végigmenni elemezni, megtanulni, felhasználni. Köszönettel