Manage keypad display

This commit is contained in:
2022-09-11 14:21:35 +02:00
parent 696263f562
commit c0982d080a

View File

@ -14,13 +14,16 @@ function _update()
end
function _draw()
cls()
rect(0,0,127,127,1)
draw_keypad()
result=get_input()
if result!="" then
print(get_input())
end
end
-->8
-- buttons --
-- button management --
function init_btn_status()
-- no repeating delay for keyboard
@ -108,10 +111,92 @@ function get_input()
end
return result
end
-->8
-- keypad input --
function draw_keypad()
-- size of keys
local delta=8
-- keypad location
local kx=(127-delta*3)/2
local ky=127-delta*3
local keys = {
{ --1
dx=0,dy=0,
up=true,down=false,
left=true,right=false
},
{ --2
dx=1,dy=0,
up=true,down=false,
left=false,right=false
},
{ --3
dx=2,dy=0,
up=true,down=false,
left=false,right=true
},
{ --4
dx=0,dy=1,
up=false,down=false,
left=true,right=false
},
{ --5
dx=1,dy=1,
up=false,down=false,
left=false,right=false
},
{ --6
dx=2,dy=1,
up=false,down=false,
left=false,right=true
},
{ --7
dx=0,dy=2,
up=false,down=true,
left=true,right=false
},
{ --8
dx=1,dy=2,
up=false,down=true,
left=false,right=false
},
{ --9
dx=2,dy=2,
up=false,down=true,
left=false,right=true
}
}
for k,v in pairs(keys) do
if btn(⬆️)==v.up and
btn(⬇️)==v.down and
btn(⬅️)==v.left and
btn(➡️)==v.right then
offset=16
else
offset=0
end
spr(k+offset,
kx+v.dx*delta,
ky+v.dy*delta
)
end
end
__gfx__
00000000666666606666666066666660666666606666666066666660666666606666666066666660000000000000000000000000000000000000000000000000
00000000671177656711176567111765671717656711176567111765671117656711176567111765000000000000000000000000000000000000000000000000
00000000677177656777176567771765671717656717776567177765677717656717176567171765000000000000000000000000000000000000000000000000
00000000677177656711176567711765671117656711176567111765677117656711176567111765000000000000000000000000000000000000000000000000
00000000677177656717776567771765677717656777176567171765677717656717176567771765000000000000000000000000000000000000000000000000
00000000671117656711176567111765677717656711176567111765677717656711176567771765000000000000000000000000000000000000000000000000
00000000666666656666666566666665666666656666666566666665666666656666666566666665000000000000000000000000000000000000000000000000
00000000055555550555555505555555055555550555555505555555055555550555555505555555000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000066666660666666606666666066666660666666606666666066666660666666606666666000000000000000000000000000000000000000000000000
00000000067117760671117606711176067171760671117606711176067111760671117606711176000000000000000000000000000000000000000000000000
00000000067717760677717606777176067171760671777606717776067771760671717606717176000000000000000000000000000000000000000000000000
00000000067717760671117606771176067111760671117606711176067711760671117606711176000000000000000000000000000000000000000000000000
00000000067717760671777606777176067771760677717606717176067771760671717606777176000000000000000000000000000000000000000000000000
00000000067111760671117606711176067771760671117606711176067771760671117606777176000000000000000000000000000000000000000000000000
00000000066666660666666606666666066666660666666606666666066666660666666606666666000000000000000000000000000000000000000000000000