]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
touch: sort drawings by name for selection
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Tue, 7 Nov 2017 23:29:32 +0000 (18:29 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 8 Nov 2017 00:04:32 +0000 (19:04 -0500)
lamp-touch.lua

index 5aac3f319c805bde98013191326cfe83b6d840b7..313faace6d7a575636bc285e100172548ce480e9 100644 (file)
@@ -18,11 +18,10 @@ if touchlastfn == nil then touchlastfn = "fill" end
 local k,v
 for k,v in pairs(file.list()) do
   local ix, _, meth = k:find("^draw%-(%w+)%.lc$")
-  if ix then
-    touchfns[#touchfns+1] = meth
-    if meth == touchlastfn then touchfnix = #touchfns end
-  end
+  if ix then touchfns[#touchfns+1] = meth end
 end
+table.sort(touchfns)
+for k,v in ipairs(touchfns) do if v == touchlastfn then touchfnix = k end end
 
 local function claimfb()
   if ledfb_claimed == 0 then