##
'''
-This protocol decoder can decode generic RGB LED string values that are
-clocked over SPI in RGB values.
+This decoder stacks on top of the 'spi' PD and decodes generic RGB LED string
+values that are clocked over SPI in RGB values.
'''
from .pd import *
+
import sigrokdecode as srd
class Decoder(srd.Decoder):
- api_version =1
+ api_version = 1
id = 'rgb_led'
name = 'RGB LED (SPI mode)'
longname = 'RGB LED string decoder (SPI mode)'
- desc = ''
+ desc = 'Generic RGB LED string protocol (RGB values clocked over SPI).'
license = 'gplv2'
inputs = ['spi']
outputs = ['rgb_led']
optional_probes = []
options = {}
annotations = [
- ['text', 'Human-readable text'],
- ['warnings', 'Human-readable warnings'],
+ ['rgb', 'RGB values'],
]
def __init__(self, **kwargs):
def decode(self, ss, es, data):
ptype, mosi, miso = data
- # Only care about data packets
+ # Only care about data packets.
if ptype != 'DATA':
return
self.ss, self.es = ss, es
if len(self.mosi_bytes) != 3:
return
- red, green, blue = self.mosi_bytes
+ red, green, blue = self.mosi_bytes
rgb_value = int(red) << 16
rgb_value |= int(green) << 8
rgb_value |= int(blue)