]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
linux-draw-xpm: ws2812:shift negative
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Wed, 14 Mar 2018 18:04:01 +0000 (14:04 -0400)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Wed, 14 Mar 2018 18:04:01 +0000 (14:04 -0400)
linux-draw-xpm.lua

index 2f881cfe813bd8688a78ea1ed922763c9fde6d1b..04bc26981319432ea96b7e3c4eaa32c94c9c236e 100644 (file)
@@ -42,13 +42,21 @@ function remotefb.shift(self,n,m,i,j)
 
   if m == nil then m = remotefb.SHIFT_LOGICAL end
 
-  local ix
-
-  for ix = 1, n do
-    local v = table.remove(self,j)
-    if m == ws2812.SHIFT_LOGICAL then v = string.char(0,0,0) end
-
-    table.insert(self,i,v)
+  if n == 0 then return
+  elseif n > 0 then
+    local ix
+    for ix = 1, n do
+      local v = table.remove(self,j)
+      if m == ws2812.SHIFT_LOGICAL then v = string.char(0,0,0) end
+      table.insert(self,i,v)
+    end
+  elseif n < 0 then
+    local ix
+    for ix = 1, -n do
+      local v = table.remove(self,i)
+      if m == ws2812.SHIFT_LOGICAL then v = string.char(0,0,0) end
+      table.insert(self,j,v)
+    end
   end
 end
 remotefb:fill(0,0,0)