-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsamplebase.py
More file actions
66 lines (53 loc) · 2.1 KB
/
Copy pathsamplebase.py
File metadata and controls
66 lines (53 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import argparse
import importlib
import os
import time
import sys
if os.name == 'nt':
RGBMatrix = getattr(importlib.import_module('RGBMatrixEmulator'), 'RGBMatrix')
RGBMatrixOptions = getattr(importlib.import_module('RGBMatrixEmulator'), 'RGBMatrixOptions')
else:
from rgbmatrix import RGBMatrix, RGBMatrixOptions
class SampleBase(object):
def __init__(self, args):
self.args = args
def usleep(self, value):
time.sleep(value / 1000000.0)
def run(self):
print("Running")
def process(self):
options = RGBMatrixOptions()
if self.args.led_gpio_mapping is not None:
options.hardware_mapping = self.args.led_gpio_mapping
options.rows = self.args.led_rows
options.cols = self.args.led_cols
options.chain_length = self.args.led_chain
options.parallel = self.args.led_parallel
options.row_address_type = self.args.led_row_addr_type
options.multiplexing = self.args.led_multiplexing
options.pwm_bits = self.args.led_pwm_bits
options.brightness = self.args.led_brightness
options.pwm_lsb_nanoseconds = self.args.led_pwm_lsb_nanoseconds
options.led_rgb_sequence = self.args.led_rgb_sequence
options.pixel_mapper_config = self.args.led_pixel_mapper
options.panel_type = self.args.led_panel_type
if os.name != 'nt':
options.limit_refresh_rate_hz = self.args.led_limit_refresh
if self.args.led_show_refresh:
options.show_refresh_rate = 1
if self.args.led_slowdown_gpio != None:
options.gpio_slowdown = self.args.led_slowdown_gpio
if self.args.led_no_hardware_pulse:
options.disable_hardware_pulsing = True
if not self.args.drop_privileges:
options.drop_privileges = False
self.matrix = RGBMatrix(options=options)
self.run()
# try:
# # Start loop
# print("Press CTRL-C to stop sample")
# self.run()
# except KeyboardInterrupt:
# print("Exiting\n")
# sys.exit(0)
return True