Map switch binary to String

Moderators: Voyager, BertB, rtenklooster, Stuntteam, grovkillen, TD-er

Post Reply
Normal user
Posts: 19
Joined: 01 Sep 2017, 02:22

Map switch binary to String

#1 Post by trumee » 06 Feb 2019, 04:43


I have a switch which produces a value 0 and 1. How can I convert these to 'OFF' and 'ON' strings to display them in OLED?

Does ESPEasy support strings?


User avatar
Normal user
Posts: 2721
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: Map switch binary to String

#2 Post by grovkillen » 06 Feb 2019, 05:34

Values can not be strings but using rules you can interpret any value and output ita string to your OLED.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop:
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Normal user
Posts: 2
Joined: 10 Jan 2019, 11:28

Re: Map switch binary to String

#3 Post by Plumifrons » 06 Feb 2019, 12:16

Any hint or example, as I'm having this problem as well (see viewtopic.php?f=2&t=6292... ?

Normal user
Posts: 248
Joined: 06 Nov 2016, 13:45

Re: Map switch binary to String

#4 Post by Domosapiens » 06 Feb 2019, 20:40

Found in my notes:
From here ... -383228300
for the Wiki:
Format Transformation:
Feature to transform Values from numeric to strings or to format numeric values.


Where #transformation is:
Format of PIN states of GPIO (0 or 1)
#V: value unformatted
#O: 1/0 -> ON/OFF
#C: 1/0 -> OPEN/CLOSE
#U: 1/0 -> UP/DOWN
#u: 1/0 -> U/D
#Y: 1/0 -> YES/NO
#y: 1/0 -> Y/N
#I: 1/0 -> IN/OUT
#X: 1/0 -> X/O
#Z: 1/0 -> 1/0
Adding ! to any of the above formatting inverts the logic.
So for example:
#O! 1/0 -> OFF/ON
#Z! 1/0 -> 0/1
#Y! 1/0 -> NO/YES
Format of any number value (floats):
#Dx.y: x digits + y decimals
#E: convert to ceiling
#F: convert to floor
Examples (value = 3.1415):
#D -> 3
#D3 -> 003
#D.2 -> 3.14
#D3.2 -> 003.14
#E -> 4
#F -> 3
#R: justifies the latest value to the right according to the number of characters exported by the LCD (tested on LCD). Not tested on other displays.
Justification formats applis to the transformed value:
#Pn: prefix with padding spaces
#Sn suffix with padding spaces
Example (value = 1)
#U#S5 -> UP (+3 spaces)
#U#P5 -> (3 spaces) UP
New Transformations:
#H: Hot/Cold
#M: Man/Auto
#m: M/A
New Justifications:
#Lx: Left (x=number of chars)
#Rx: Right (x=number of chars)
#Ux.y: Substring (x=first char; y=number of chars)
Never tried it, please report back with working examples ;) ;)
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

Normal user
Posts: 19
Joined: 01 Sep 2017, 02:22

Re: Map switch binary to String

#5 Post by trumee » 07 Feb 2019, 01:01

Thanks the transformation worked for me and OLED does show the string. Would be great if you could add a transformation for Empty/Full.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests