Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: markfickett/LED-Controller
base: b4ce845e43
...
head fork: markfickett/LED-Controller
compare: e50dd645df
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
15 python/ledcontroller/Buffer.py
View
@@ -24,6 +24,21 @@ def getColors(self):
"""
return self.__colors
+ def clear(self):
+ """
+ Reset all the colors to blank (black).
+ """
+ for c in self.__colors:
+ c.clear()
+
+ def setFromBuffer(self, buffer):
+ """
+ Set the contents of this buffer to match another buffer.
+ """
+ for localColor, otherColor in zip(
+ self.__colors, buffer.getColors()):
+ localColor.set(otherColor)
+
def insertAndPop(self, color):
"""
Insert the given Color into the beginning (index 0) of the color
14 python/ledcontroller/Color.py
View
@@ -11,7 +11,13 @@ def __init__(self, rgb=None):
if rgb:
self.setRgb(*rgb)
else:
- self.setRgb(0, 0, 0)
+ self.clear()
+
+ def clear(self):
+ """
+ Reset to the default black color.
+ """
+ self.setRgb(0, 0, 0)
def setRgb(self, r, g, b):
"""
@@ -21,6 +27,12 @@ def setRgb(self, r, g, b):
self.__g = float(g)
self.__b = float(b)
+ def set(self, color):
+ """
+ Set this Color to match another.
+ """
+ self.setRgb(*color.getRgb())
+
def clamp(self):
"""
Modify this color so that its component values all are within
9 python/ledcontroller/SendingBuffer.py
View
@@ -20,18 +20,21 @@ def __init__(self, outputSerial=None, **kwargs):
def setSerial(self, outputSerial):
self.__serial = outputSerial
- def sendAndWait(self):
+ def sendAndWait(self, reverse=False):
"""
Send the current contents of the color buffer to the currently
set Serial, and wait for the send to complete to avoid read
errors on the receiving end with immediately repeated sends.
+ @param reversed if True, send Colors in reverse order
"""
if not self.__serial:
raise RuntimeError('Call setSerial (or provide in'
' constructor) before sending.')
+ colors = self.getColors()
+ if reverse:
+ colors = reversed(colors)
senderKwargs = {
- DATA_RECEIVER_COLOR_KEY:
- Serialization.ToBytes(self.getColors()),
+ DATA_RECEIVER_COLOR_KEY: Serialization.ToBytes(colors),
}
self.__serial.write(DataSender.Format(**senderKwargs))
self.__serial.flush()

No commit comments for this range

Something went wrong with that request. Please try again.