Need advices for "linear leds"
-
- Posts: 57
- Joined: Sat Nov 26, 2016 9:58 pm
Need advices for "linear leds"
Hi there,
How would you manage display ?
I mean, Red, Green and Yellow Leds
This a gauge for a PA28 Cadet Diesel
Thanks for your advices !
How would you manage display ?
I mean, Red, Green and Yellow Leds
This a gauge for a PA28 Cadet Diesel
Thanks for your advices !
- Keith Baxter
- Posts: 4674
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Need advices for "linear leds"
Hi,
I would use canvas_draw and then a for loop for all the led's.
Keith
I would use canvas_draw and then a for loop for all the led's.
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
-
- Posts: 57
- Joined: Sat Nov 26, 2016 9:58 pm
Re: Need advices for "linear leds"
Thanks Keith !
Edit : I've found canvas_draw in wiki.
Edit : I've found canvas_draw in wiki.
Re: Need advices for "linear leds"
If canvas is too difficult then images can work as well.
You can put them in an array to make it a bit easier. But if that's also new for you then I suggest to start simple.
You can put them in an array to make it a bit easier. But if that's also new for you then I suggest to start simple.
-
- Posts: 57
- Joined: Sat Nov 26, 2016 9:58 pm
Re: Need advices for "linear leds"
Thanks Ralph !
I' trying canvas_draw()
These lines are working fine :
However , an error "ERROR - logic.lua:71: Argument 'id(1)' in function 'opacity' is not a valid reference, which is not allowed is returned with these lines :
The print line works as it is a string, but the opacity line returns the error. The node_id is not a string. How can i handle it in a loop ?
I'm searching ...
I' trying canvas_draw()
These lines are working fine :
Code: Select all
Volt_1 = canvas_add(105, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("red")
end)
Volt_2 = canvas_add(115, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("red")
end)
Volt_3 = canvas_add(125, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("yellow")
end)
Volt_4 = canvas_add(135, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("green")
end)
Volt_5 = canvas_add(145, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("green")
end)
Volt_6 = canvas_add(155, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("green")
end)
Volt_7 = canvas_add(165, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("green")
end)
Volt_8 = canvas_add(175, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("yellow")
end)
Volt_9 = canvas_add(185, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("red")
end)
Volt_10 = canvas_add(195, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("red")
end)
Volt_Group = group_add(Volt_1,Volt_2,Volt_3,Volt_4,Volt_5,Volt_6,Volt_7,Volt_8,Volt_9,Volt_10)
opacity(Volt_Group, 0.3)
Code: Select all
for ID = 1, 10 do
Volt_Id = "Volt_".. ID
print(Volt_Id)
opacity(Volt_Id, 0.0)
end
I'm searching ...
Re: Need advices for "linear leds"
Did you try tostring() ?
-
- Posts: 57
- Joined: Sat Nov 26, 2016 9:58 pm
Re: Need advices for "linear leds"
Yes, i did.
it does not work :
Return :
it does not work :
Code: Select all
for ID = 1, 10 do
Volt_Id = "Volt_".. ID
print(Volt_Id)
opacity(tostring(Volt_Id), 1.0)
end
Code: Select all
INFO - Volt_1
ERROR - logic.lua:88: Argument 'id(1)' in function 'opacity' is not a valid reference, which is not allowed
Re: Need advices for "linear leds"
I looked at your script on my phone, so I didn't have a close look at first. You're doing a opacity on a non existing node. First you have to create the node (image or whatever).
-
- Posts: 57
- Joined: Sat Nov 26, 2016 9:58 pm
Re: Need advices for "linear leds"
Ralph, thans for your help.
The nodes are created before the loop :
The fisrt one :
This is working fine. So, with the line should work when .
Am I missing something ?
To complete my anwser, with this line, all is fine :
It looks like the variable Volt_Id should be converted to node_id type ...
The nodes are created before the loop :
The fisrt one :
Code: Select all
Volt_1 = canvas_add(105, 50, 200, 200, function()
_rect(50,50,7,25)
_fill("red")
end)
Code: Select all
opacity(tostring(Volt_Id), 1.0)
Code: Select all
Volt_Id equals Volt_1
Am I missing something ?
To complete my anwser, with this line, all is fine :
Code: Select all
opacity(Volt_1, 1.0)
Re: Need advices for "linear leds"
Why would you create separate canvasses for each item? Why not one canvas for all?