-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
462 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[env] | ||
framework = arduino | ||
lib_extra_dirs = ../../libraries/ | ||
monitor_speed = 115200 | ||
|
||
[env:1284p16m] | ||
platform = atmelavr | ||
; use rmap Git version | ||
;platform = https://github.com/r-map/platform-atmelavr.git | ||
platform_packages = | ||
toolchain-atmelavr @ https://github.com/r-map/platformio-toolchain-atmelavr-uselocal.git | ||
;toolchain-atmelavr@9.3.1 | ||
; use upstream Git version | ||
;framework-arduino-avr @ https://github.com/arduino/ArduinoCore-avr.git | ||
framework-arduino-avr @ https://github.com/r-map/ArduinoCore-avr.git | ||
board = 1284p16m | ||
lib_ignore = | ||
STM32duino FreeRTOS | ||
EspSoftwareSerial | ||
GSM_GPRSLibrary | ||
IRremoteESP8266 | ||
IRremoteSTM32 | ||
|
232 changes: 232 additions & 0 deletions
232
platformio/test/arduinomenu_lcd/src/arduinomenu_lcd.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
#include <Arduino.h> | ||
|
||
/******************** | ||
Sept. 2014 Rui Azevedo - ruihfazevedo(@rrob@)gmail.com | ||
menu output to standard arduino LCD (LiquidCrystal) | ||
output: LCD | ||
input: encoder and Serial | ||
www.r-site.net | ||
***/ | ||
|
||
#include <Wire.h> | ||
#include <menu.h> | ||
#include <menuIO/hd44780_I2CexpOut.h> | ||
#include <menuIO/serialOut.h> | ||
#include <menuIO/serialIn.h> | ||
//#include <menuIO/encoderIn.h> | ||
#include <menuIO/RotaryIn.h> | ||
#include <menuIO/keyIn.h> | ||
#include <menuIO/chainStream.h> | ||
|
||
using namespace Menu; | ||
|
||
// LCD ///////////////////////////////////////// | ||
#include <hd44780.h> | ||
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c LCD i/o class header | ||
|
||
// Note, i2c address can be specified or automatically located | ||
// If you wish to use a specific address comment out this constructor | ||
// and use the constructor below that specifies the address | ||
|
||
// declare the lcd object for auto i2c address location | ||
hd44780_I2Cexp lcd; | ||
|
||
// Encoder ///////////////////////////////////// | ||
#define encA 2 | ||
#define encB 3 | ||
//this encoder has a button here | ||
#define encBtn 6 | ||
|
||
encoderIn<encA,encB> encoder;//simple encoder driver | ||
encoderInStream<encA,encB> encStream(encoder);// simple quad encoder fake Stream | ||
|
||
//a keyboard with only one key as the encoder button | ||
keyMap encBtn_map[]={{-encBtn,defaultNavCodes[enterCmd].ch}};//negative pin numbers use internal pull-up, this is on when low | ||
keyIn<1> encButton(encBtn_map);//1 is the number of keys | ||
|
||
//input from the encoder + encoder button + serial | ||
serialIn serial(Serial); | ||
menuIn* inputsList[]={&encStream,&encButton,&serial}; | ||
chainStream<3> in(inputsList);//3 is the number of inputs | ||
|
||
#define LEDPIN 13 | ||
|
||
//// ISR for encoder management | ||
void encoderprocess (){ | ||
encoder.process(); | ||
} | ||
|
||
|
||
result doAlert(eventMask e, prompt &item); | ||
|
||
result showEvent(eventMask e,navNode& nav,prompt& item) { | ||
Serial.print("event: "); | ||
Serial.println(e); | ||
return proceed; | ||
} | ||
|
||
int test=55; | ||
|
||
result action1(eventMask e,navNode& nav, prompt &item) { | ||
Serial.print("action1 event: "); | ||
Serial.print(e); | ||
Serial.println(", proceed menu"); | ||
Serial.flush(); | ||
return proceed; | ||
} | ||
|
||
result action2(eventMask e,navNode& nav, prompt &item) { | ||
Serial.print("action2 event: "); | ||
Serial.print(e); | ||
Serial.print(", quiting menu."); | ||
Serial.flush(); | ||
return quit; | ||
} | ||
|
||
int ledCtrl=LOW; | ||
|
||
result myLedOn() { | ||
ledCtrl=HIGH; | ||
return proceed; | ||
} | ||
result myLedOff() { | ||
ledCtrl=LOW; | ||
return proceed; | ||
} | ||
|
||
TOGGLE(ledCtrl,setLed,"Led: ",doNothing,noEvent,noStyle//,doExit,enterEvent,noStyle | ||
,VALUE("On",HIGH,doNothing,noEvent) | ||
,VALUE("Off",LOW,doNothing,noEvent) | ||
); | ||
|
||
int selTest=0; | ||
SELECT(selTest,selMenu,"Select",doNothing,noEvent,noStyle | ||
,VALUE("Zero",0,doNothing,noEvent) | ||
,VALUE("One",1,doNothing,noEvent) | ||
,VALUE("Two",2,doNothing,noEvent) | ||
); | ||
|
||
int chooseTest=-1; | ||
CHOOSE(chooseTest,chooseMenu,"Choose",doNothing,noEvent,noStyle | ||
,VALUE("First",1,doNothing,noEvent) | ||
,VALUE("Second",2,doNothing,noEvent) | ||
,VALUE("Third",3,doNothing,noEvent) | ||
,VALUE("Last",-1,doNothing,noEvent) | ||
); | ||
|
||
//customizing a prompt look! | ||
//by extending the prompt class | ||
class altPrompt:public prompt { | ||
public: | ||
altPrompt(constMEM promptShadow& p):prompt(p) {} | ||
Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t) override { | ||
return out.printRaw(F("special prompt!"),len);; | ||
} | ||
}; | ||
|
||
MENU(subMenu,"Sub-Menu",showEvent,anyEvent,noStyle | ||
,OP("Sub1",showEvent,anyEvent) | ||
,OP("Sub2",showEvent,anyEvent) | ||
,OP("Sub3",showEvent,anyEvent) | ||
,altOP(altPrompt,"",showEvent,anyEvent) | ||
,EXIT("<Back") | ||
); | ||
|
||
/*extern menu mainMenu; | ||
TOGGLE((mainMenu[1].enabled),togOp,"Op 2:",doNothing,noEvent,noStyle | ||
,VALUE("Enabled",enabledStatus,doNothing,noEvent) | ||
,VALUE("disabled",disabledStatus,doNothing,noEvent) | ||
);*/ | ||
|
||
// char* constMEM hexDigit MEMMODE="0123456789ABCDEF"; | ||
// char* constMEM hexNr[] MEMMODE={"0","x",hexDigit,hexDigit}; | ||
// char buf1[]="0x11"; | ||
|
||
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle | ||
,OP("Op1",action1,anyEvent) | ||
,OP("Op2",action2,enterEvent) | ||
//,SUBMENU(togOp) | ||
,FIELD(test,"Test","%",0,100,10,1,doNothing,noEvent,wrapStyle) | ||
,SUBMENU(subMenu) | ||
,SUBMENU(setLed) | ||
,OP("LED On",myLedOn,enterEvent) | ||
,OP("LED Off",myLedOff,enterEvent) | ||
,SUBMENU(selMenu) | ||
,SUBMENU(chooseMenu) | ||
,OP("Alert test",doAlert,enterEvent) | ||
// ,EDIT("Hex",buf1,hexNr,doNothing,noEvent,noStyle) | ||
,EXIT("<Back") | ||
); | ||
|
||
//const panel panels[] MEMMODE={{0,0,16,2}}; | ||
//navNode* nodes[sizeof(panels)/sizeof(panel)]; | ||
//panelsList pList(panels,nodes,1); | ||
|
||
#define MAX_DEPTH 2 | ||
/*idx_t tops[MAX_DEPTH]; | ||
liquidCrystalOut outLCD(lcd,tops,pList);//output device for LCD | ||
menuOut* constMEM outputs[] MEMMODE={&outLCD};//list of output devices | ||
outputsList out(outputs,1);//outputs list with 2 outputs*/ | ||
|
||
MENU_OUTPUTS(out, MAX_DEPTH | ||
,LIQUIDCRYSTAL_OUT(lcd,{0,0,16,2}) | ||
,NONE | ||
); | ||
NAVROOT(nav,mainMenu,MAX_DEPTH,in,out);//the navigation root object | ||
|
||
result alert(menuOut& o,idleEvent e) { | ||
if (e==idling) { | ||
o.setCursor(0,0); | ||
o.print("alert test"); | ||
o.setCursor(0,1); | ||
o.print("[select] to continue..."); | ||
} | ||
return proceed; | ||
} | ||
|
||
result doAlert(eventMask e, prompt &item) { | ||
nav.idleOn(alert); | ||
return proceed; | ||
} | ||
|
||
result idle(menuOut& o,idleEvent e) { | ||
switch(e) { | ||
case idleStart:o.print("suspending menu!");break; | ||
case idling:o.print("suspended...");break; | ||
case idleEnd:o.print("resuming menu.");break; | ||
} | ||
return proceed; | ||
} | ||
|
||
void setup() { | ||
pinMode(encBtn,INPUT_PULLUP); | ||
pinMode(LEDPIN,OUTPUT); | ||
Wire.begin(); | ||
Serial.begin(115200); | ||
while(!Serial); | ||
Serial.println("Arduino Menu Library");Serial.flush(); | ||
encoder.begin(); | ||
encButton.begin(); | ||
lcd.begin(16,2); | ||
|
||
// encoder with interrupt on the A & B pins | ||
attachInterrupt(digitalPinToInterrupt(encA), encoderprocess, CHANGE); | ||
attachInterrupt(digitalPinToInterrupt(encB), encoderprocess, CHANGE); | ||
|
||
|
||
nav.idleTask=idle;//point a function to be used when menu is suspended | ||
mainMenu[1].enabled=disabledStatus; | ||
nav.showTitle=false; | ||
lcd.setCursor(0, 0); | ||
lcd.print("Menu 4.x LCD"); | ||
lcd.setCursor(0, 1); | ||
lcd.print("rmap.cc"); | ||
delay(2000); | ||
} | ||
|
||
void loop() { | ||
nav.poll(); | ||
digitalWrite(LEDPIN, ledCtrl); | ||
delay(100);//simulate a delay as if other tasks are running | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[env] | ||
framework = arduino | ||
lib_extra_dirs = ../../libraries/ | ||
monitor_speed = 115200 | ||
build_flags = -DMENU_USERAM | ||
|
||
|
||
[env:1284p16m] | ||
platform = atmelavr | ||
; use rmap Git version | ||
;platform = https://github.com/r-map/platform-atmelavr.git | ||
platform_packages = | ||
toolchain-atmelavr @ https://github.com/r-map/platformio-toolchain-atmelavr-uselocal.git | ||
;toolchain-atmelavr@9.3.1 | ||
; use upstream Git version | ||
;framework-arduino-avr @ https://github.com/arduino/ArduinoCore-avr.git | ||
framework-arduino-avr @ https://github.com/r-map/ArduinoCore-avr.git | ||
board = 1284p16m | ||
lib_ignore = | ||
STM32duino FreeRTOS | ||
EspSoftwareSerial | ||
GSM_GPRSLibrary | ||
IRremoteESP8266 | ||
IRremoteSTM32 | ||
|
Oops, something went wrong.