Hardware


Shell Lab L1 is a programmable LED signal lamp with USB/serial interface

Characteristic:

● PWM to adjust RGB brightness (each channel is independently adjusted from 0~255)
● blinking effect (freq adjustable from 0.1~20Hz, 0 for static)
● L1B model(brighter), switch to WS2812 chip, double brightness
● L1B model(brighter), support rotation mode, current is stable
● beeper embedded, frequency/duration are adjustable, less volume
● alarm embedded (optional), louder volume, with adjustable down counter
● interactive serial console with ASCII command, online manual embedded
● programming language is not limited (Python recommended)
● quick test with Testbench App (with various demo codes)
● pip install mcush library (support windows/linux/mac) and write scripts easily

Use cases:

● fault/exception indication in product/software cycle test
● indication in assembly line, green for PASS and red for FAIL
● experiment progress indication
● kanban/placard indication
● logistic/storage management, goods location indicator
● ROS robot indication
● interactive game design
● educational experiment design
● outdoor case, auto indicator
● system integration for industrial equipment
● art creativity

Work modes:


Install:

fix the accessory buckle buddy first, then pile the lamp and rotate a little

Customize:

● change USB interface to TTL
● Bluetooth/serial convert embedded, for wireless control
● default 2-meter length cable, customizable

Attention:

● long time working in static mode is not recommended because:
worse indication effect and decrease in LED lifetime
● for multi-lamps condition, add extra power for USB-HUB

Software

Serial Communication FAQ
C Programming FAQ

Serial command:

1. LED Control Command:
=>lamp --help
usage: lamp [-m mode] [-c RGB_color] [-r red_color] [-g green_color] [-b blue_color] [-f freq] [-C counter]
options:
 -m/--mode       0-blink, 1/2-rotate
 -c/--color      RRGGBB format
 -r/--red        red value
 -g/--green      green value
 -b/--blue       blue value
 -f/--freq       0~20 Hz(default 1)
 -C/--counter    blink down-counter
=> 
2. Beeper Control:
=>beep --help
usage: beep [-f frequency] ms
options:
 -f/--frequency  20~10000(default 4000)hz
 ms              1~10000(default 50)ms
=> 
3. Alarm Control (louder):
=>alarm --help
usage: alarm [-c count] [-f freq]
options:
-c/--count 1~1000
-f/--freq 1~10 Hz(default 1)
=> 

Example:

blink in RED color, 1Hz(default):
=>lamp -c 0xFF0000
=>
blink in GREEN color, 2Hz:
=>lamp -c 0xFF00 -f 2
=>
blink in BLUE color, 0.5Hz:
=>lamp -c 0xFF -f 0.5
=>
blink YELLOW color, 0.1Hz:
=>lamp -c 0xFFFF00 -f 0.1
=>
blink PURPLE color, 10Hz:
=>lamp -c 0xFF00FF -f 10
=>
static CYAN color:
=>lamp -c 0x00FFFF -f 0
=>
single RED channel as 64:
=>lamp -r 64
=>
single GREEN channel as 0x80:
==>lamp -g 0x80
=>
single BLUE channel as 0x200:
=>lamp -b 200
=>
query current color/freq setting:
=>lamp
color: 0x000000
freq: 1.0
=>
short beep @4kHz/50ms(default):
=>beep
=>
short beep @2kHz/1sec:
=>beep -f 2000 1000
=>
Alarm once @1Hz:
=>alarm -c 1
=>
Alarm ten times @10Hz:
=>alarm -c 10 -f 10
=>
Alarm down counter and freq:
=>alarm
count: 0
freq: 1
=>
Rotation mode (L1B model only):
=>lamp -m 0  (0-blink mode, default)
=>lamp -m 1  (clockwise rotation mode)
=>lamp -m 2  (anticlockwise rotation mode)
=>

Python API:

Install: sudo pip3 install mcush
Upgrade: sudo pip3 install -U mcush
class ShellLabLamp(mcush.ShellLab.ShellLab):
    def lamp(self, color=None, red=None, green=None, blue=None, freq=None, mode=None, count=None):
        # lower level serial command

    def color(self, c, freq=None, count=None):
        # color, freq and blink downcounter
    
    def mode(self, mode):
        # rotation mode  0-blinking  1-clockwise  2-anticlockwise

    def alarm(self, count=None, freq=None):
        # alarm down counter and frequency
    
    def reset(self, lamp_freq=1, alarm_freq=1, mode=None):
        # mode reset

Example:

import mcush
from mcush.linkong.ShellLab import ShellLabLamp
lamp = ShellLabLamp('COM10')  # fill the actual serial port
lamp.color('red', freq=2)  # blink fast in red color
lamp.alarm(count=3)  # alarm for three times

Download:

Shell Lab Testbench Application


CH341 VCP Driver(Windows)


Application

Single lamp blinking effect

Multi lamps blinking effect

Rotation mode for L1B model only


Enhanced version, 20 groups of LEDs for smooth brightness


Case and PCB customized


Deployed in headless NAS, use serial lamp to indicator remote connectiondownload
#!/usr/bin/env python3
import mcush
import subprocess
import sys
import time

lamp_color = None
lamp_freq = None

def set_color( color, freq=1 ):
    global lamp_color, lamp_freq
    if color is None:
        color = 'black'
    if (color == lamp_color) and (freq == lamp_freq):
        return color
    try:
        print('switch to %s'% color)
        lamp = mcush.ShellLab.ShellLabLamp()
        if lamp_freq == freq:
            lamp.color( color )
        else:
            lamp.color( color, freq=freq )
            lamp_freq = freq
        lamp_color = color
        lamp.disconnect()
        del lamp
        return color
    except Exception as e:
        print( e )
        lamp_color = None
        lamp_freq = None
        return None

def main(argv=None):
    set_color('red',freq=2)
    time.sleep(0.5)
    set_color('green',freq=2)
    time.sleep(0.5)
    set_color('blue',freq=2)
    time.sleep(0.5)
    while True:
        ps_output = subprocess.check_output(['ps', 'x'])
        #print(ps_output)
        if 'proftpd' in ps_output:
            set_color('blue')
        elif 'unison' in ps_output:
            set_color('green')
        else:
            set_color('black')
        time.sleep(1)
 
if __name__ == '__main__':
    main(sys.argv) 

Config the lamp to looly display RGBCMY color after powerup download
# this script runs in ShellLab Testbench Application
freq = 0.2  # hz
delay_ms = int(1000/freq)  # ms

fcfs = Utils.FCFS()
fcfs.appendFile("rgbcmy", '''\
a -c 0xFF0000
delay {delay_ms}
a -c 0x00FF00
delay {delay_ms}
a -c 0x0000FF
delay {delay_ms}
a -c 0x00FFFF
delay {delay_ms}
a -c 0xFF00FF
delay {delay_ms}
a -c 0xFFFF00
delay {delay_ms}
load /c/rgbcmy
'''.format(delay_ms=delay_ms))

fcfs.appendFile("init", '''\
delay
a -c 0 -f {freq}
load /c/rgbcmy
'''.format(freq=freq))

s = ShellLabLamp(PORT)
s.fcfsFormat()
s.fcfsProgram(fcfs.generate())
s.port.write('reboot\n')
#s.reboot()

Control with Raspberry board

Single step debug with Raspberry board



test with mcush_util
#!/bin/sh
# Shell Lab L1 lamp controller demo with mcush_util
# download/compile/install mcush_util firstly
# Shanghai Linkong Software Tech. Co., Ltd.
# www.xrsoft.com
set -e
PORT=/dev/ttyUSB0

# model match
mcush_util -p$PORT -mShellLab-L1 -r

# basic colors
mcush_util -nq -p$PORT run "b" "a -f0.9" \
    "a -c0xff -C1" "delay" \
    "a -c0xff00 -C1" "delay" "a -c0xff0000 -C1" "delay" \
    "a -c0xffff -C1" "delay" "a -c0xffff00 -C1" "delay" \
    "a -c0xff00ff -C1" "delay" "a -c0xffffff -C1" "delay"

# police alarm light
mcush_util -nq -p$PORT run "a -f10 -c0xff" "delay" \
    "a -c0xff0000" "delay" "a -c0xff" "delay" \
    "a -c0xff0000" "delay" "a -c0xff" "delay" \
    "a -c0xff0000" "delay" "a -c0xff" "delay"

# end, turn off 
mcush_util -nq -p$PORT run "a -c0"