From 0637802af8f658e9cad2b0ad619b95cf9df47c5e Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Wed, 14 Mar 2018 14:04:01 -0400 Subject: [PATCH] linux-draw-xpm: ws2812:shift negative --- linux-draw-xpm.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) 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) -- 2.50.1