From 0985dd8aacb6264ef7cdd2f2f336b13e95019366 Mon Sep 17 00:00:00 2001 From: Rui Azevedo Date: Thu, 20 Feb 2020 14:06:08 -0100 Subject: [PATCH] floatField added field decimal places format. --- examples/handlers/handlers/handlers.ino | 2 +- library.properties | 2 +- src/items.h | 9 +++++++++ src/itemsTemplates.hpp | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/handlers/handlers/handlers.ino b/examples/handlers/handlers/handlers.ino index fa951c31..96500b9c 100644 --- a/examples/handlers/handlers/handlers.ino +++ b/examples/handlers/handlers/handlers.ino @@ -137,7 +137,7 @@ char name[]=" "; MENU(mainMenu,"Main menu",showEvent,anyEvent,wrapStyle ,OP("Op1",showEvent,anyEvent) ,OP("Op2",showEvent,anyEvent) - ,FIELD(test,"Test","%",0,100,10,1,showEvent,anyEvent,wrapStyle) + ,altFIELD(decPlaces<3>::menuField,test,"Test","%",0,100,1,0.001,showEvent,anyEvent,wrapStyle) ,SUBMENU(subMenu) ,SUBMENU(setLed) ,OP("LED On",myLedOn,enterEvent) diff --git a/library.properties b/library.properties index a83a4f27..d0b07f0c 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ArduinoMenu library -version=4.18.3 +version=4.19.0 author=Rui Azevedo, ruihfazevedo@gmail.com maintainer=neu-rah, ruihfazevedo@gmail.com sentence=Generic menu/interactivity system diff --git a/src/items.h b/src/items.h index 71fe4167..8f9e1968 100644 --- a/src/items.h +++ b/src/items.h @@ -215,6 +215,15 @@ #endif }; + template + struct decPlaces { + template + struct menuField:Menu::menuField { + using Menu::menuField::menuField; + idx_t printReflex(menuOut& o) const override; + }; + }; + //-------------------------------------------------------------------------- template class menuValue:public prompt { diff --git a/src/itemsTemplates.hpp b/src/itemsTemplates.hpp index 6fc14c72..c7448bc8 100644 --- a/src/itemsTemplates.hpp +++ b/src/itemsTemplates.hpp @@ -102,6 +102,10 @@ namespace Menu { } } + template + template + idx_t decPlaces::menuField::printReflex(menuOut& o) const {return o.print(Menu::menuField::reflex,dps);} + template Used choose::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr) { bool ed=this==root.navFocus;