]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
lamp: allow going back in drawing selection, too
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 21 Nov 2016 21:43:59 +0000 (16:43 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 21 Nov 2016 21:44:49 +0000 (16:44 -0500)
lamp-touch.lua

index db8ece3b0d9fd41799e83b2d2b7d4fe3dcad7150..6a131cd55298871f7701d4e3ad59ec358c08ee29 100644 (file)
@@ -108,8 +108,8 @@ local function ontouch()
       if bit.isset(down,2) then touchcolor = touchcolor + 1 else touchcolor = touchcolor + 2 end
       claimfb()
     else
-      -- go backward, slowly
-      if bit.isset(down,2) then touchcolor = touchcolor - 1; claimfb() end
+      -- go backward, slowly (unless mode select; see below)
+      if bit.isset(down,2) and bit.isclear(down,3) then touchcolor = touchcolor - 1; claimfb() end
     end
     if     touchcolor >= 48 then touchcolor = touchcolor - 48
     elseif touchcolor < 0  then touchcolor = touchcolor + 48
@@ -119,8 +119,12 @@ local function ontouch()
     if bit.isset(down,3) then
       print("front middle touched", touch_db_fn)
       if touch_db_fn == nil then
-       touchfnix = touchfnix + 1
+       if bit.isset(down,2)
+        then touchfnix = touchfnix - 1
+        else touchfnix = touchfnix + 1
+       end
        if touchfnix > #touchfns then touchfnix = 1 end
+       if touchfnix <= 0 then touchfnix = #touchfns end
        touch_db_fn = tq:queue(200,onfndebounce)
       end
       claimfb()
@@ -132,7 +136,6 @@ local function ontouch()
   -- if bit.isset(down,4) then end
 
   -- draw if we've claimed it!
-  print("ahhhh", ledfb, touchfb)
   if ledfb == touchfb then
     touchtmr:unregister()
     loaddrawfn(touchfns[touchfnix])(touchtmr,touchfb,touchcolorvec(touchcolor)); dodraw()