From: Nathaniel Wesley Filardo Date: Wed, 14 Mar 2018 18:04:01 +0000 (-0400) Subject: linux-draw-xpm: ws2812:shift negative X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=0637802af8f658e9cad2b0ad619b95cf9df47c5e;p=acmetensortoys-esp-lua_lamp linux-draw-xpm: ws2812:shift negative --- diff --git a/linux-draw-xpm.lua b/linux-draw-xpm.lua index 2f881cf..04bc269 100644 --- a/linux-draw-xpm.lua +++ b/linux-draw-xpm.lua @@ -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)