Code: Select all
my_canvas=canvas_add(-50,-50,575,575)
---lets draw the inital black box
canvas_draw(my_canvas, function()
_rect(40,40,575,575)
_fill("black",0) --Note the 0 after the "black". It is the opacity
end)
---now lets dim the black box
--create a var for dimming/opacity
dim_var=1
--Add a function
function dim_my_canvas()
canvas_draw(my_canvas, function()
_rect(40,40,575,575)
_fill("black",dim_var) ---Note we have used the var we created vary the opacity
end)
end
---add your dial
function dial_change(dir)
dim_var=dim_var+(dir*0.1) ---Change the opacity value
var_cap(dim_var,0,1) ---Limit the scope of the opacity value.
dim_my_canvas () --force a callback to the dim function
end
-- Create a new rotary encoder
hw_dial_add("ARDUINO_MEGA2560_A_D3", "ARDUINO_MEGA2560_A_D4","TYPE_1_DETENT_PER_PULSE", dial_change)