Hello,
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?
Thanks
Map switch binary to String
Moderators: grovkillen, Stuntteam, TD-er
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Map switch binary to String
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: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
-
- New user
- Posts: 3
- Joined: 10 Jan 2019, 11:28
Re: Map switch binary to String
Any hint or example, as I'm having this problem as well (see viewtopic.php?f=2&t=6292... ?
-
- Normal user
- Posts: 307
- Joined: 06 Nov 2016, 13:45
Re: Map switch binary to String
Found in my notes:
From here https://github.com/letscontrolit/ESPEas ... -383228300
From here https://github.com/letscontrolit/ESPEas ... -383228300
Never tried it, please report back with working examplesfor the Wiki:
Format Transformation:
Feature to transform Values from numeric to strings or to format numeric values.
Syntax:
[task#value#transformation#justification]
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)
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.
Re: Map switch binary to String
Thanks the transformation worked for me and OLED does show the string. Would be great if you could add a transformation for Empty/Full.
-
- New user
- Posts: 3
- Joined: 10 Jan 2019, 11:28
Re: Map switch binary to String
Yes, this did the trick.
I've send from my Pi a 0 (for not charging) or a 1 to a dummy task called "charging". In the settings of the oled I've used
And with the "#Y" the 0 or 1 of the value of the task is converted to "NO" or "YES".
I've send from my Pi a 0 (for not charging) or a 1 to a dummy task called "charging". In the settings of the oled I've used
Code: Select all
Charging:[charging#charging#Y]
Who is online
Users browsing this forum: Google [Bot] and 39 guests