/
EXAMPLE
60 lines (41 loc) · 3.66 KB
/
EXAMPLE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
%% do not forget to load LCD-PI32 kernel modules
%% cd LCD-PI32; sudo ./PI32
%% start erlang with smp enabled !
%% erl -smp enable -epx framebuffer_device '"/dev/fb1"' input_mouse_device '"/dev/input/event0"' lcd_pi32 1
application:start(hex_epx).
%% RECTANGLES
hex_epx:init_event(out, [{id,green},{type,rectangle},{x,10},{y,10},{width,64},{height,64},{fill,solid},{color,16#ff00ff00}]).
hex_epx:init_event(out, [{id,red},{type,rectangle},{x,100},{y,100},{width,64},{height,64},{fill,solid},{color,16#ffff0000}]).
hex_epx:init_event(out, [{id,blue},{type,rectangle},{x,50},{y,50},{width,64},{height,64},{fill,solid},{color,16#ff0000ff}]).
%% BUTTONS
hex_epx:init_event(in, [{id,b1},{type,button},{x,100},{y,100},{width,64},{height,64},{fill,solid},{color,16#ffff0000},{font,[{name,"Arial"},{size,12}]},{text,"OK"}]).
hex_epx:init_event(in, [{id,b2},{type,button},{x,165},{y,100},{width,64},{height,64},{fill,solid},{color,16#ff00ff00},{font,[{name,"Arial"},{size,12}]},{text,"Push"}]).
%% VALUES
hex_epx:init_event(out, [{id,v2},{type,value},{x,200},{y,43},{width,64},{height,32},{fill,solid},{color,16#ff00ffff},{font,[{name,"Arial"},{size,12}]},{value,0},{format,"~4.16.0B"}]).
%% IMAGE
hex_epx:init_event(out, [{id,i1},{type,image},{x,1},{y,1},{image,"/Users/tony/Pictures/Test/solros.bmp"}]).
hex_epx:init_event(out, [{id,i2},{type,image},{x,60},{y,1},{image,"/Users/tony/Pictures/Test/solros.bmp"}]).
hex_epx:init_event(out, [{id,i3},{type,image},{x,120},{y,1},{image,"/Users/tony/Pictures/Test/solros.jpg"}]).
%% SMALL DEMO
hex_epx:init_event(out, [{id,v1},{type,value},{x,200},{y,10},{width,64},{height,32},{fill,solid},{color,16#ff00ff00},{font,[{name,"Arial"},{size,12}]},{value,0},{format,"~4..0w"}]).
%% SLIDER
hex_epx:init_event(in, [{id,s1},{type,slider},{x,5},{y,200},{width,300},{height,32},{color,16#ff006600},{min,0},{max,1024}]).
%% CONNECT SLIDER and VALUE1
hex_epx:add_event([{id,s1}], slider, fun(_,Env) -> hex_epx:output([{id,v1}], Env) end).
%% BUTTON DEMO
%% Spacing = (320 - (4*64 + 3*4))/2 = 26
%% X1 = 26
%% X2 = X1 + 64 + 4 = 94
%% X3 = X2 + 64 + 4 = 162
%% X4 = X3 + 64 + 4 = 230
%%
hex_epx:init_event(in, [{id,b1},{type,button},{x,26},{y,10},{width,64},{height,64},{fill,solid},{color,16#ffff0000},{font,[{name,"Arial"},{size,12}]},{text,"F1"}]).
hex_epx:init_event(in, [{id,b2},{type,button},{x,94},{y,10},{width,64},{height,64},{fill,solid},{color,16#ffff0000},{font,[{name,"Arial"},{size,12}]},{text,"F2"}]).
hex_epx:init_event(in, [{id,b3},{type,button},{x,162},{y,10},{width,64},{height,64},{fill,solid},{color,16#ffff0000},{font,[{name,"Arial"},{size,12}]},{text,"F3"}]).
hex_epx:init_event(in, [{id,b4},{type,button},{x,230},{y,10},{width,64},{height,64},{fill,solid},{color,16#ffff0000},{font,[{name,"Arial"},{size,12}]},{text,"F4"}]).
hex_epx:init_event(in, [{id,b5},{type,button},{x,26},{y,78},{width,64},{height,64},{fill,solid},{color,16#ff00ff00},{font,[{name,"Arial"},{size,12}]},{text,"F5"}]).
hex_epx:init_event(in, [{id,b6},{type,button},{x,94},{y,78},{width,64},{height,64},{fill,solid},{color,16#ff00ff00},{font,[{name,"Arial"},{size,12}]},{text,"F6"}]).
hex_epx:init_event(in, [{id,b7},{type,button},{x,162},{y,78},{width,64},{height,64},{fill,solid},{color,16#ff0000ff},{font,[{name,"Arial"},{size,12}]},{text,"F7"}]).
hex_epx:init_event(in, [{id,b8},{type,button},{x,230},{y,78},{width,64},{height,64},{fill,solid},{color,16#ff0000ff},{font,[{name,"Arial"},{size,12}]},{text,"F8"}]).
hex_epx:init_event(out, [{id,amp},{type,value},{x,26},{y,150},{width,132},{height,48},{font,[{name,"Arial"},{size,40}]},{format,"~w A"}]).
hex_epx:init_event(out, [{id,volt},{type,value},{x,162},{y,150},{width,132},{height,48},{font,[{name,"Arial"},{size,40}]},{format,"~w V"}]).