diff --git a/.github/workflows/platformio.yml b/.github/workflows/platformio.yml index c380f9e26..bd9d83ba7 100644 --- a/.github/workflows/platformio.yml +++ b/.github/workflows/platformio.yml @@ -51,9 +51,9 @@ jobs: run: | cd platformio/stima_v3/i2c-wind platformio run - - name: Build Stima V3 sensor_config + - name: Build Stima V3 sensor_config_menu_sdcard run: | - cd platformio/stima_v3/sensor_config + cd platformio/stima_v3/sensor_config_menu_sdcard platformio run - name: Build Stima V3 stima run: | @@ -95,6 +95,10 @@ jobs: run: | cd platformio/stima_v3/test_logging platformio run + - name: Build Stima fakeanalog + run: | + cd platformio/test/fakeanalog + platformio run - name: Build Stima fakeraingauge run: | cd platformio/test/fakeraingauge diff --git a/platformio/test/arduinomenu_lcd/platformio.ini b/platformio/test/arduinomenu_lcd/platformio.ini new file mode 100644 index 000000000..e9dab5f68 --- /dev/null +++ b/platformio/test/arduinomenu_lcd/platformio.ini @@ -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 + diff --git a/platformio/test/arduinomenu_lcd/src/arduinomenu_lcd.ino b/platformio/test/arduinomenu_lcd/src/arduinomenu_lcd.ino new file mode 100644 index 000000000..214f2ef4f --- /dev/null +++ b/platformio/test/arduinomenu_lcd/src/arduinomenu_lcd.ino @@ -0,0 +1,232 @@ +#include + +/******************** +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 +#include +#include +#include +#include +//#include +#include +#include +#include + +using namespace Menu; + +// LCD ///////////////////////////////////////// +#include +#include // 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 encoder;//simple encoder driver +encoderInStream 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(" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Menu; + +#define SDCARD_SS 7 +SdFat sd; + +//function to handle file select +// declared here and implemented bellow because we need +// to give it as event handler for `filePickMenu` +// and we also need to refer to `filePickMenu` inside the function +result filePick(eventMask event, navNode& nav, prompt &item); + +// LCD ///////////////////////////////////////// +#include +#include // 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 encoder;//simple encoder driver +encoderInStream 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 + + +SDMenuT> filePickMenu(sd,"SD Card","/",filePick,enterEvent); + +//implementing the handler here after filePick is defined... +result filePick(eventMask event, navNode& nav, prompt &item) { + // switch(event) {//for now events are filtered only for enter, so we dont need this checking + // case enterCmd: + if (nav.root->navFocus==(navTarget*)&filePickMenu) { + Serial.println(); + Serial.print("selected file:"); + Serial.println(filePickMenu.selectedFile); + Serial.print("from folder:"); + Serial.println(filePickMenu.selectedFolder); + } + // break; + // } + return proceed; +} + +//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 + +//// ISR for encoder management +void encoderprocess (){ + encoder.process(); +} + +const panel panels[] MEMMODE={{0,0,20,4}}; +navNode* nodes[sizeof(panels)/sizeof(panel)]; +panelsList pList(panels,nodes,1); + +#define MAX_DEPTH 2 + +MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle + ,SUBMENU(filePickMenu) + ,OP("Something else...",doNothing,noEvent) + ,EXIT("=nextPool) { + nav.poll(); + nextPool=now+1000/menuFPS; + } +}