Changing the color of a bargraph depending on his value #2806
-
Hello from France !
Nothing groundbreaking here, it shows an horizontal bar wich changes in size, is red when V<37 V, yellow when V is between 37 V and 38.5 V and green when V>38.5 V. Now my idea is to having a continuous changing color going from red when V is 35 V to green when V is 43V I'm thankfull for any hint ! Roland |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
So, after a little more brainstorming I found a solution, with a little help from this page : Here is the modified code :
A little explanation for those interested : I'm still interested in other solutions ! Roland |
Beta Was this translation helpful? Give feedback.
-
There is a function for this:
So:
Will return the correct 16 bit value for a yellow colour. |
Beta Was this translation helpful? Give feedback.
-
You may find this sketch useful. It uses the library alphaBlend function and has a function to generate the colours of a rainbow: https://github.com/Bodmer/TFT_eSPI/blob/master/examples/Generic/alphaBlend_Test/alphaBlend_Test.ino The alphaBlend produces a gradual change from one colour to another by changing the alpha value from 0 to 255. |
Beta Was this translation helpful? Give feedback.
There is a function for this:
So:
Will return the correct 16 bit value for a yellow colour.