Browse Source

Add min_color and max_color options

Tyler Hallada 8 years ago
parent
commit
3097e0851f
1 changed files with 9 additions and 1 deletions
  1. 9 1
      glow.py

+ 9 - 1
glow.py

@@ -24,6 +24,12 @@ parser.add_argument('-m', '--minimum', type=int, default=0,
24 24
 parser.add_argument('-n', '--no_dim', action='store_true', default=False,
25 25
 		help='Instead of fading out to a dim minimum, only pause at max glow'
26 26
 		'and then fade to the next random color.')
27
+parser.add_argument('-L', '--min_color', type=int, default=0,
28
+		help='Minimum of the range to select color values from. A higher value will'
29
+		'make brighter colors. (valid range: 0-255)')
30
+parser.add_argument('-H', '--max_color', type=int, default=255,
31
+		help='Maximum of the range to select color values from. A lower value will'
32
+		'make dimmer colors. (valid range: 0-255)')
27 33
 parser.add_argument('-v', '--verbose', action='store_true', default=False,
28 34
 		help='Display debug printouts of the current and target colors at every '
29 35
 		'sub-interval')
@@ -50,6 +56,8 @@ interval = parser.parse_args().interval
50 56
 glow_pause = parser.parse_args().glow_pause
51 57
 dim_pause = parser.parse_args().dim_pause
52 58
 minimum = parser.parse_args().minimum
59
+min_color = parser.parse_args().min_color
60
+max_color = parser.parse_args().max_color
53 61
 no_dim = parser.parse_args().no_dim
54 62
 verbose = parser.parse_args().verbose
55 63
 if verbose: print "Allocating..."
@@ -177,7 +185,7 @@ spidev.flush()
177 185
 
178 186
 # Now, glow
179 187
 while True:
180
-	color = tuple([random.randint(0, len(gamma)-1) for x in range(3)])
188
+	color = tuple([random.randint(min_color, max_color) for x in range(3)])
181 189
 	# Wrap in try/except block for graceful exiting via KeyboardInterrupt
182 190
 	try:
183 191
 		fade_to_color(color, array, gamma, step=step,