Skip to content

Commit 04059fb

Browse files
committed
Update readme, remove commented code
1 parent f570b24 commit 04059fb

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,12 @@ push = push2_python.Push2()
338338
# This function is defined in a rather silly way, could probably be optimized a lot ;)
339339
def generate_3_color_frame():
340340
colors = ['{b:05b}{g:06b}{r:05b}'.format(
341-
r=int(32*random.random()), g=int(64*random.random()), b=int(32*random.random())),
342-
'{b:05b}{g:06b}{r:05b}'.format(
343-
r=int(32*random.random()), g=int(64*random.random()), b=int(32*random.random())),
344-
'{b:05b}{g:06b}{r:05b}'.format(
345-
r=int(32*random.random()), g=int(64*random.random()), b=int(32*random.random()))]
341+
r=int(31*random.random()), g=int(63*random.random()), b=int(31*random.random())),
342+
'{b:05b}{g:06b}{r:05b}'.format(
343+
r=int(31*random.random()), g=int(63*random.random()), b=int(31*random.random())),
344+
'{b:05b}{g:06b}{r:05b}'.format(
345+
r=int(31*random.random()), g=int(63*random.random()), b=int(31*random.random()))]
346+
colors = [int(c, 2) for c in colors]
346347
line_bytes = []
347348
for i in range(0, 960): # 960 pixels per line
348349
if i <= 960 // 3:
@@ -364,7 +365,7 @@ for i in range(0, 20):
364365
# Now crate an extra frame which loads an image from a file. Image must be 960x160 pixels.
365366
img = Image.open('test_img_960x160.png')
366367
frame = numpy.array(img)
367-
#frame = img_array/255 # Convert rgb values to [0.0, 1.0] floats
368+
frame = img_array/255 # Convert rgb values to [0.0, 1.0] floats
368369

369370
# Now lets configure some action handlers which will display frames in Push2's display in
370371
# reaction to pad and button presses

push2_python/simulator/simulator.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,7 @@ def prepare_next_frame_for_display(self, frame, input_format=push2_python.consta
104104
frame_b_shifted = numpy.left_shift(frame_b_filtered, 8) # Shift 8 to the left so G sits at the 16-23 bits
105105
rgb_frame = frame_r_shifted + frame_g_shifted + frame_b_shifted # Combine all channels
106106
rgb_frame = numpy.bitwise_or(rgb_frame, int('11111111000000000000000000000000', 2)) # Set alpha channel to "full!" (bits 24-32)
107-
108-
'''
109-
elif input_format == push2_python.constants.FRAME_FORMAT_RGB:
110-
111-
r_filter = int('111111110000000000000000', 2)
112-
g_filter = int('000000001111111100000000', 2)
113-
b_filter = int('000000000000000011111111', 2)
114-
frame_r_filtered = numpy.bitwise_and(rgb_frame, r_filter)
115-
frame_r_shifted = numpy.left_shift(frame_r_filtered, 16) # Shift 16 to left so R starts at bit 32
116-
frame_g_filtered = numpy.bitwise_and(rgb_frame, g_filter)
117-
frame_g_shifted = numpy.left_shift(frame_g_filtered, 8) # Shift 8 to the left so G start at bit 24
118-
frame_b_filtered = numpy.bitwise_and(rgb_frame, b_filter)
119-
frame_b_shifted = frame_b_filtered # No shift, B already starts at 16
120-
rgb_frame = frame_r_shifted + frame_g_shifted + frame_b_shifted # Combine all channels
121-
rgb_frame = numpy.bitwise_or(rgb_frame, int('00000000000000000000000011111111', 2)) # Set alpha channel to "full!"
122-
'''
123-
107+
124108
img = Image.frombytes('RGBA', (960, 160), rgb_frame.tobytes())
125109
buffered = BytesIO()
126110
img.save(buffered, format="png")

0 commit comments

Comments
 (0)