Page 1 of 1

Display GPIO state with text

Posted: 13 Mar 2019, 19:43
by asuz
How can I display GPIO state with text instead of number at LCD Screen. For example, if GPIO 12 state is 1 LCD Screen display ON, if GPIO 12 state is 0 LCD Screen display OFF.

Re: Display GPIO state with text

Posted: 13 Mar 2019, 19:55
by grovkillen
Later versions let you do this by adding a converter for translating 1/0 to ON/OFF etc. Don't have the exact syntax in my head now but look for "pinstate" or similar. I will try to look more tomorrow.

Re: Display GPIO state with text

Posted: 13 Mar 2019, 22:18
by Domosapiens
From my notes:

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)

Re: Display GPIO state with text

Posted: 13 Mar 2019, 22:38
by asuz
Domosapiens wrote: 13 Mar 2019, 22:18 From my notes:

Format Transformation:
Feature to transform Values from numeric to strings or to format numeric values.
Syntax:
[task#value#transformation#justification]
................
Wonderful property, thank you very much for your guidance. Just wonder one more think about that transformation, what if I need to transform 1 to ABCD and 0 to EFGH instead of ON or OFF?

Re: Display GPIO state with text

Posted: 14 Mar 2019, 05:49
by grovkillen
You mean custom names? The list of transformations aren't covering your need?

Re: Display GPIO state with text

Posted: 14 Mar 2019, 16:41
by asuz
grovkillen wrote: 14 Mar 2019, 05:49 You mean custom names? The list of transformations aren't covering your need?
Isn't it possible with rules?

Re: Display GPIO state with text

Posted: 14 Mar 2019, 16:55
by grovkillen
No it's not. Unless you use if states etc. But what do you want to do exactly?

Re: Display GPIO state with text

Posted: 14 Mar 2019, 19:21
by asuz
grovkillen wrote: 14 Mar 2019, 16:55 No it's not. Unless you use if states etc. But what do you want to do exactly?
I need to display translation of ON and OFF in my language for one of my project. Sometimes people who doesnot know English are confuse ON and OFF meaning.

Re: Display GPIO state with text

Posted: 14 Mar 2019, 21:07
by grovkillen
Ok, then you need to do some if statements and LCD commands.

Re: Display GPIO state with text

Posted: 15 Mar 2019, 19:43
by asuz
grovkillen wrote: 14 Mar 2019, 21:07 Ok, then you need to do some if statements and LCD commands.
OK, thank you, i will try