-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Warwick Stone
committed
Oct 22, 2018
1 parent
ba74d89
commit 6e8f2c2
Showing
5 changed files
with
53 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import argparse | ||
|
||
class ArgParser: | ||
def __init__(self, description): | ||
self.description = description | ||
|
||
def parse_args(self): | ||
arg_parser = argparse.ArgumentParser(description=self.description) | ||
arg_parser.add_argument('--host', help='set the host address of the server, ' + | ||
'eg. 0.0.0.0 to accept external requests') | ||
arg_parser.add_argument('--device', help='set the display device (default: %(default)s)', | ||
choices=['pygame', 'arduino'], | ||
default='pygame') | ||
return arg_parser.parse_args() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from threading import Thread | ||
|
||
from pixel_generator_slave import PixelGeneratorSlave | ||
|
||
|
||
class PixelService: | ||
""" Deals with all pixel stuff required by the flask app """ | ||
def __init__(self, num_pixels): | ||
self.pixelgen = PixelGeneratorSlave(num_pixels) | ||
|
||
def start_displayer(self, device): | ||
if device == 'pygame': | ||
from pygame_pixels.pygame_pixels import PygamePixelDisplayer | ||
pixeldisp = PygamePixelDisplayer(self.pixelgen.generate) | ||
elif device == 'arduino': | ||
from arduino_pixels.py_serial_pixels.serial_pixel_displayer import SerialPixelDisplayer | ||
pixeldisp = SerialPixelDisplayer(self.pixelgen.generate) | ||
else: | ||
raise Exception('unknown displayer device: ' + device) | ||
|
||
# run the displayer in a background thread, since it runs a blocking loop | ||
dispthread = Thread(target=pixeldisp.run) | ||
dispthread.start() | ||
|
||
def set_all(self, r, g, b): | ||
self.pixelgen.set_all(r, g, b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters