How to use a variable in an argument ? #1448
Replies: 6 comments
-
Posted at 2021-01-10 by Robin Sun 2021.01.10 Hi @Guillaume_G chew on this for a while The issue appears to be L26 with an incorrect parameter list. Espruino reference for setColor() function:
> http://www.espruino.com/Reference#l_Graphics_setColor
This is a great web site to test Javascript concepts: Tutorial and Examples along with a 'TryIt' editor This may also be solved using either Arrays or JSON object notation.
If you wish to stay in base10 then these snippets might be one way
or maybe in hex
and if you get stuck on the gristle, I'll check back in a few hours to get you over the goal post. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-10 by @MaBecker @Guillaume_G take a look at this file https://github.com/espruino/BangleApps/blob/master/apps/scolor/show-color.js |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-11 by @allObjects ...this is really a weird piece of code... with every button 1 press, a new watch on button 1 is created... furthermore, the index runs away... (of course, only after quite many presses). Fixing of the code is removing the first repeating watch and changing the second one to repeat. For the index, remove the modulo in every array access, and replace the simple increment with
PS: I assume that creator of this code confused that the original design did not work with repeated watching button 1 outside of the drawColor() function - that no matter what value the repeat(e) option property was given - it just did not work so the watch, the second one inside the loop was established... this time with proper spelling of the (...this in the official Espruino repo... @gfwilliams, I guess introducing an ESR### - like the JSR### - process would give a bit more stability to the code base. To not stifle the contribution process, it could be a two stage app repository, where a new or changed app first goes into a staging mode / area / ... and move into the final place only after community feedback.) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-11 by @gfwilliams Hi! It depends a bit what platform you're aiming for...
One way of doing it that is efficient and portable between different displays is to use the hex string format that newer Espruino firmwares support:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-11 by @allObjects for that reason I created implemented an overridable custom color setter in my UI work. I took advantage of your normation of 3 values from 0..1 for each of the RGB color. From that I map with the custom setter to what the connected display needs. Everyone goes for a logical / abstract / common graphic layer to keep the api and most of the code the same across displays. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-17 by Guillaume_G Yes in this format it works thanks! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-10 by Guillaume_G
Hey!
I'm trying to stock the RGB color code in variables but I don't know how to use it in an argument like the argument of the g.setColor() function.
Here is my code
(this code doesn't work )
I don't know how to transfer the values of one variable in the arguments
I hope you see what I'm trying to do if not ask me ;)
Thanks for your help
Beta Was this translation helpful? Give feedback.
All reactions