Implementation of the Jaycar RGB USB LED fan (GH1031) protocol
Project description
Micro Wave USB Fan
This library is a pure Python reimplementation of the Jaycar RGB USB LED fan (GH1031) protocol. Communication occurs using USB HID reports as a transport. This library uses hidapi to do this across Linux, macOS, FreeBSD and Windows.
Installation
pip install microwave-usbfan
Example Implementation
Two Text Messages
from usbfan import Device, Program, TextMessage
# A program is made up of a list of Messages
# A "TextMessage" is a subclass of the generic Message class
p = Program((TextMessage("Hello, World!"),
TextMessage("How is everyone going?"),))
# Open the device and program
d = Device()
d.program(p)
Single Red Dot
from usbfan import Colour, Column, Device, Message, Program
# A generic "Message" is made up of 1 to 144 "Column" object
# A "Column" has 11 boolean pixels and a "Colour"
columns = [Column([True] + [False] * 10, Colour.red)]
for _ in range(7):
columns.append(Column([False] * 11, Colour.red))
p = Program((Message(columns),))
# Open the device and program
d = Device()
d.program(p)
Rainbow Message
from usbfan import Colour, Column, Device, Message, Program, TextMessage
# We can cycle the rainbow here and fill all 144 columns
rainbow_colours = [Colour.red, Colour.yellow, Colour.green,
Colour.cyan, Colour.blue, Colour.magenta]
rainbow = [Column([True] * 11,
rainbow_colours[i % len(rainbow_colours)])
for i in range(Message.MAX_COLUMNS)]
p = Program((
TextMessage("Here comes the rainbow!"),
Message(rainbow),
))
# Open the device and program
d = Device()
d.program(p)
Mode Controls
For each message, you can define how it opens, what it does once displayed, and what it does when closing.
from usbfan import Colour, Column, Device, Message, Program, TextMessage, \
MessageStyle, OpenTransition, CloseTransition
# We can cycle the rainbow here and fill all 144 columns
rainbow_colours = [Colour.red, Colour.yellow, Colour.green,
Colour.cyan, Colour.blue, Colour.magenta]
rainbow = [Column([True] * 11,
rainbow_colours[i % len(rainbow_colours)])
for i in range(Message.MAX_COLUMNS)]
p = Program((
TextMessage("Here comes the rainbow!",
message_style=MessageStyle.Flash,
open_transition=OpenTransition.DownUp,
close_transition=CloseTransition.DownUp),
Message(rainbow,
message_style=MessageStyle.Clockwise,
open_transition=OpenTransition.FromMiddle,
close_transition=CloseTransition.ToMiddle),
))
# Open the device and program
d = Device()
d.program(p)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
microwave-usbfan-1.1.tar.gz
(155.9 kB
view hashes)