Skip to content

Commit e85ad47

Browse files
committed
parse input allow negative values
numeric fields now alow parse of negative numbers, needed because async is wired to it
1 parent dc37a08 commit e85ad47

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoMenu library
2-
version=4.17.17
2+
version=4.17.18
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=Generic menu/interactivity system

src/itemsTemplates.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,22 @@ namespace Menu {
4646

4747
template<typename T>
4848
void menuField<T>::parseInput(navNode& nav,menuIn& in) {
49-
if (strchr(numericChars,in.peek())) {//a numeric value was entered
49+
//TODO: on a cmd based nav (not streams) this mess will be pushed to stream input only
50+
//can not enter negative number literals by serial, using steps or web is ok
51+
bool neg=false;
52+
char nc=in.peek();
53+
if (nc=='-') {
54+
in.read();
55+
if (!strchr(numericChars,in.peek())) {
56+
doNav(nav,downCmd);
57+
return;
58+
}
59+
// Serial.println("NEGATIVE NUMBER PARSE THEN!");
60+
neg=true;
61+
}
62+
if (neg||strchr(numericChars,nc)) {//a numeric value was entered
5063
if (in.numValueInput) {
51-
target()=(T)in.parseFloat();//TODO: use template specialization and proper convertion
64+
target()=(T)((neg?-1:1)*in.parseFloat());//TODO: use template specialization and proper convertion
5265
tunning=true;
5366
doNav(nav,enterCmd);
5467
} else doNav(nav,idxCmd);

0 commit comments

Comments
 (0)