def set_checker(offset): n = offset for y in range(5): for x in range(11): scrollphat.set_pixel(x,y,n % 2 == 0) n += 1 scrollphat.update()
def display(self, amt): val = 0 if(amt != None): val = int(amt) if(val > self.MAX): val = self.MAX self.flash(val) return if(val == self.last): return if(self.last > val): scrollphat.clear() self.last = val y = 0 x = 0 while(val > 0): scrollphat.set_pixel(x, y, True) scrollphat.update() x = x + 1 if(x == 10): y = y + 1 x = 0 val = val -1
def getstravabargraph(): global totaldistance totaldistance = 0 activitiesthisyear = client.get_activities( after=mondaypst, limit=500) # Download all activities this year for activity in activitiesthisyear: totaldistance += float(stravalib.unithelper.miles( activity.distance)) #add up the total distance limit = 0 bargraph = [] #Get the most recent 5 activities to draw the bar chart for activity in sorted(activitiesthisyear, key=sortby, reverse=True): bargraph.append( int( math.ceil( float(stravalib.unithelper.miles(activity.distance)) / km_per_pixel))) limit += 1 if limit == 5: #only get most recent 5 activities (1 per row of pixels) break bargraph.reverse() return bargraph # def drawgraph(values): scrollphat.clear_buffer() for row, value in enumerate(values): for col in range(0, 11): if value <= col: scrollphat.set_pixel(col, row, False) else: scrollphat.set_pixel(col, row, True) scrollphat.update()
def on_message(self, message): cmd = json.loads(message) #{u'raw': 1, u'turned_on': True, u'led': 1} if cmd['turned_on']: scrollphat.set_pixel(cmd['led'],cmd['raw'],1) else: scrollphat.set_pixel(cmd['led'],cmd['raw'],0) scrollphat.update()
def print_scroll(self): scrollphat.clear() for x, col in enumerate(self.field.buffer): for y, pixel in enumerate(col): scrollphat.set_pixel(x, y, pixel) scrollphat.set_pixel(self.ai.player.x, self.ai.player.y, 1) if SCREEN_TYPE == "SCROLL": scrollphat.update() if SCREEN_TYPE == "SCROLLHD": scrollphat.show()
def displaySprite(sprite): """Display a simple sprite on the matrix. The sprite should be an array of 5 binary strings""" print("Displaying Sprite: %s" % sprite) scrollphat.clear() for rowNum, row in enumerate(sprite): for colNum, cell in enumerate(row): scrollphat.set_pixel(colNum, rowNum, int(cell)) scrollphat.update()
def set_checker(self, offset): scrollphat.clear() n = offset for y in range(SCREEN_HEIGHT): for x in range(SCREEN_WIDTH): scrollphat.set_pixel(x, y, n % 2 == 0) n += 1 if SCREEN_TYPE == "SCROLL": scrollphat.update() if SCREEN_TYPE == "SCROLLHD": scrollphat.show()
def ledstage(stage): pause_time = 0.03 scrollphat.set_brightness(2) for y in range(5): for x in range(stage): scrollphat.set_pixel(x, y, 1) scrollphat.update() time.sleep(pause_time)
def ledstage( stage ): pause_time = 0.03 scrollphat.set_brightness(2) for y in range(5): for x in range(stage): scrollphat.set_pixel(x,y,1) scrollphat.update() time.sleep(pause_time)
def slow_fill(self, val, pause): y = 0 x = 0 while(val > 0): scrollphat.set_pixel(x, y, True) time.sleep(pause) scrollphat.update() x = x + 1 if(x == 10): y = y + 1 x = 0 val = val -1
def clear(pause): # arrow body for x in range(11): scrollphat.set_pixel(x, 2, 0) # arrow tip part scrollphat.set_pixel(8, 0, 0) scrollphat.set_pixel(9, 1, 0) scrollphat.set_pixel(9, 3, 0) scrollphat.set_pixel(8, 4, 0) scrollphat.update() time.sleep(pause)
def paint(pause): # arrow body for x in range(11): scrollphat.set_pixel(x, 2, 1) # arrow tip part scrollphat.set_pixel(8, 0, 1) scrollphat.set_pixel(9, 1, 1) scrollphat.set_pixel(9, 3, 1) scrollphat.set_pixel(8, 4, 1) scrollphat.update() time.sleep(pause)
def clear(fast=False): log_str('clear scroll') if not fast: for x in range(11): for y in range(5): scrollphat.set_pixel(x, y, 0) sleep(0.015) scrollphat.update() scrollphat.clear_buffer() scrollphat.clear() scrollphat.update()
def on_message(self, message): # print 'message received %s' % message action = True rawled=int(message) if rawled < 0: rawled=rawled*-1 action= False led= rawled-1 a= led % 11 b= led // 11 import scrollphat # scrollphat.clear() scrollphat.set_pixel(a,b,action) scrollphat.update()
def scrollphat_output(days, hours, minutes, seconds, total): global start_seconds start_seconds = start_seconds or total bar = int(5 * (float(total) / start_seconds)) scrollphat.clear_buffer() s = str(seconds) indent = 2 if len(s) == 1: indent = 4 scrollphat.write_string(s, indent) for y in range(bar): scrollphat.set_pixel(0, y, 1) scrollphat.update()
def mainprog(): "Display current time with pixels on the Scroll pHAT." global disp t = time.strftime(f, time.localtime()) h1, h2, m1, m2 = [int(x) for x in t] disp = [[2, 4, 4, 4, 1, 6, 6, 1, 8, 8, 8] for y in range(3)] tog( 0, 1, h1, 3) tog( 1, 4, h2, 5) tog( 5, 7, m1, 7) tog( 8, 11, m2, 9) for x in range(11): for y in range(3): r, g, b = colors[ disp[y][x] ] if (r+g+b>0): scrollphat.set_pixel(x, y+1, 1) else: scrollphat.set_pixel(x, y+1, 0) scrollphat.update()
def mainprog(): "Display current time with pixels on the Scroll pHAT." global disp t = time.strftime(f, time.localtime()) h1, h2, m1, m2 = [int(x) for x in t] disp = [[2, 4, 4, 4, 1, 6, 6, 1, 8, 8, 8] for y in range(3)] tog(0, 1, h1, 3) tog(1, 4, h2, 5) tog(5, 7, m1, 7) tog(8, 11, m2, 9) for x in range(11): for y in range(3): r, g, b = colors[disp[y][x]] if (r + g + b > 0): scrollphat.set_pixel(x, y + 1, 1) else: scrollphat.set_pixel(x, y + 1, 0) scrollphat.update()
def draw(self, game): text = game.get_scroller_text() if text != '': scrollphat.write_string(text) scrollphat.scroll() time.sleep(0.06) else: scrollphat.clear() for x, y in game.get_pixels(): pixel = int(x), int(y) scrollphat.set_pixel(pixel[0], pixel[1], 1) scrollphat.update()
def update(count): global last scrollphat.set_pixel(10,4,0) if count == None: scrollphat.clear() scrollphat.write_string("----") else: if count != last: scrollphat.clear() scrollphat.write_string(str(count)) last = count
def update(count): global last scrollphat.set_pixel(10, 4, 0) if count == None: scrollphat.clear() scrollphat.write_string("----") else: if count != last: scrollphat.clear() scrollphat.write_string(str(count)) last = count
def showmotor(controller, row, motorval): if controller == "ab": row = row + 6 #print motorval if motorval == 0: for n in range(5): scrollphat.set_pixel(row,n,0) scrollphat.update() else: steps = int(round((abs(motorval) - BASE_MOTOR_POWER) / 21)) for n in range(5): if n <= steps: scrollphat.set_pixel(row,n,1) scrollphat.update() else: scrollphat.set_pixel(row,n,0) scrollphat.update() return
def showmotor(controller, row, motorval): if controller == "ab": row = row + 6 #print motorval if motorval == 0: for n in range(5): scrollphat.set_pixel(row, n, 0) scrollphat.update() else: steps = int(round((abs(motorval) - BASE_MOTOR_POWER) / 21)) for n in range(5): if n <= steps: scrollphat.set_pixel(row, n, 1) scrollphat.update() else: scrollphat.set_pixel(row, n, 0) scrollphat.update() return
def plot_digit(digit, position): bcd_digit = string_to_bcd(digit) for y in range(0, 5, 1): scrollphat.set_pixel(position, y, int(bcd_digit[y]) == 1) while True: try: current = time.strftime('%H0%M0%S') for x in range(0, 8): plot_digit(current[x], x) for i in range(0, 5): scrollphat.set_pixel(10, i, (5 - i) <= ((int(current[3:5])) / 10)) scrollphat.update() time.sleep(0.5) except KeyboardInterrupt: scrollphat.clear() sys.exit(-1) # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
def sec_gap_off(): scrollphat.set_pixel(5,1,0) scrollphat.set_pixel(5,3,0)
brightness = 20 # Setting brightness on scroll phat w, h = (11, 5) # Setting width and height x, y = (0, 0) # Setting x and y grav = 0.5 # Setting Gravity jump_vel = 0 # Setting jump velocity jump_decay = 0.8 # Setting jump decay move_speed = 1 # Setting movement speed while True: # Loop forever scrollphat.clear() # Clearing the display scrollphat.set_brightness(brightness) # Getting the brightness for LEDS scrollphat.set_pixel(int(x), int(y), 1) # Setting pixel to show in bottom left corner scrollphat.update() # Updating scroll phat time.sleep(0.03) # Set scroll phat to sleep for .3 seconds pygame.event.pump() # Processes pygame event handlers internally axis_value = joystick.get_axis(0) # Setting axis value for x if axis_value > 0.8: # If axis value is greater than 0.8 x += move_speed # increase move speed of x elif axis_value < -0.8: # If axis value is less than 0.8 x -= move_speed # Decrease move speed if x >= w: # if x is greater than width x = w - 1 # x = width - 1 elif x < 0: # If x is less than 0
def num_3_(): scrollphat.set_pixel(6,0,0) scrollphat.set_pixel(7,0,0) scrollphat.set_pixel(6,1,0) scrollphat.set_pixel(7,1,0) scrollphat.set_pixel(6,2,0) scrollphat.set_pixel(7,2,0) scrollphat.set_pixel(6,3,0) scrollphat.set_pixel(7,3,0) scrollphat.set_pixel(6,4,0) scrollphat.set_pixel(7,4,0)
def plot_digit(digit, position): bcd_digit = string_to_bcd(digit) for y in range(0, 5, 1): scrollphat.set_pixel(position, y, int(bcd_digit[y]) == 1)
def setCell(row, col, cell): if cell eq '0': scrollphat.set_pixel(row, col, 0)
def num_1_5(): scrollphat.set_pixel(0, 0, 1) scrollphat.set_pixel(1, 0, 1) scrollphat.set_pixel(0, 1, 1) scrollphat.set_pixel(1, 1, 0) scrollphat.set_pixel(0, 2, 1) scrollphat.set_pixel(1, 2, 1) scrollphat.set_pixel(0, 3, 0) scrollphat.set_pixel(1, 3, 1) scrollphat.set_pixel(0, 4, 1) scrollphat.set_pixel(1, 4, 1)
def num_4_0(): scrollphat.set_pixel(9, 0, 1) scrollphat.set_pixel(10, 0, 1) scrollphat.set_pixel(9, 1, 1) scrollphat.set_pixel(10, 1, 1) scrollphat.set_pixel(9, 2, 1) scrollphat.set_pixel(10, 2, 1) scrollphat.set_pixel(9, 3, 1) scrollphat.set_pixel(10, 3, 1) scrollphat.set_pixel(9, 4, 1) scrollphat.set_pixel(10, 4, 1)
i = 0 buf = [0] * 11 scrollphat.set_brightness(1) while True: try: for x in range(0, 11): y = (math.sin((i + (x * 10)) / 10.0) + 1) # Produces range from 0 to 2 y *= 2.5 # Scale to 0 to 5 buf[x] = 1 << int(y) # scrollphat.set_brightness(randint(1,100)) for q in range(randint(0,3)): y = randint(0,4) x = randint(0,10) scrollphat.set_pixel(x,y,1) # sp.update() # time.sleep(0.1) # sp.clear() scrollphat.set_buffer(buf) scrollphat.update() time.sleep(0.5) i += 1 except KeyboardInterrupt: scrollphat.clear() sys.exit(-1)
# Date: 10/23/16 # Author: John Harrison # IST 440W - Joe Oakes # Penn State Abington import sys import time import scrollphat #low brightness scrollphat.set_brightness(10) #iterate through columns and rows, turning all pixels on for y in range(5): for x in range(11): scrollphat.set_pixel(x, y, True) scrollphat.update() time.sleep(.500) scrollphat.clear() time.sleep(.250) #iterate through columns and rows, turning all pixels on for y in range(5): for x in range(11): scrollphat.set_pixel(x, y, True) scrollphat.update() time.sleep(.500) scrollphat.clear()
def paint(pause): for y in range(5): for x in range(11): scrollphat.set_pixel(x, y, 1) scrollphat.update() time.sleep(pause)
def clear(pause): for y in range(5): for x in range(11): scrollphat.set_pixel(x, y, 0) scrollphat.update() time.sleep(pause)
#!/usr/bin/env python """lights a single led. The function set_pixel() takes 3 arguments - x position (in a range 0-10), y position (range 0-4) and off/on (0/1). The position of an led is given top-to-bottom, left-to-right with the scrollphat positioned so that 'scroll pHAT' is along the bottom edge and 'PIMORONI.COM' runs along the right-hand short edge.""" import scrollphat #sets a single pixel to 'on' - in this case it is the pixel in the second from left column in the middle row scrollphat.set_pixel(1,2,0) scrollphat.update();
def armDownColumn(self, columnNumber, position): '''Sets the columns for when it has the arms up''' if self.args.verbose: print( 'Running SpaceInvader.armUpDown, columnNumber: %s, position: %s' % (columnNumber, position)) if columnNumber == 0: scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) elif columnNumber == 1: scrollphat.set_pixel(position, 2, 1) elif columnNumber == 2: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 3: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 4: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) elif columnNumber == 5: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) elif columnNumber == 6: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 7: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 8: scrollphat.set_pixel(position, 2, 1) elif columnNumber == 9: scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) else: print('armDownColumn input error: %s' % columnNumber)
def sec_gap_off(): scrollphat.set_pixel(5, 1, 0) scrollphat.set_pixel(5, 3, 0)
print('Rotate: ' + str(args.rotate)) print('Interval: ' + str(args.interval)) print('Number of docker containers running: ' + str(nb_containers)) scrollphat.set_rotate(args.rotate) scrollphat.set_brightness(args.brightness) prev_temp = 0 prev_load = 0 prev_nb_containers = 0 while True: try: # Display the temperature temp = get_cpu_temperature() if (temp > prev_temp): for x in range(int(temp / 80 * 11)): scrollphat.set_pixel(x, args.temperature, 1) elif (temp < prev_temp): for x in range(int(temp / 80 * 11), int(prev_temp / 80 * 11)): scrollphat.set_pixel(x, args.temperature, 0) prev_temp = temp # Display the cpu load load = psutil.cpu_percent() if (load > prev_load): for x in range(int(load / 100 * 11)): scrollphat.set_pixel(x, args.cpu, 1) elif (load < prev_load): for x in range(int(load / 100 * 11), int(prev_load / 100 * 11)): scrollphat.set_pixel(x, args.cpu, 0) prev_load = load # Display the number of containers running
import time import scrollphat as s s.clear() s.set_brightness(2) #time.sleep(2) # draw arrow s.set_pixel(5, 4, 1) s.set_pixel(5, 0, 1) s.set_pixel(4, 1, 1) s.set_pixel(4, 3, 1) s.set_pixel(3, 2, 1) s.set_pixel(4, 2, 1) s.set_pixel(5, 2, 1) s.set_pixel(6, 2, 1) s.set_pixel(7, 2, 1) s.set_pixel(8, 2, 1) s.set_pixel(9, 2, 1) s.set_pixel(10, 2, 1) while True: s.scroll() s.update() time.sleep(0.05)
def switchoff(): for x in range(11): for y in range(5): scrollphat.set_pixel(x,y,0) scrollphat.update();
face_chibbi_meh = ['00000000000', '01000000100', '00100001000', '01000000100', '00011110000'] face_chibbi_dead = ['10100001010', '01000000100', '10100001010', '00000000000', '00011110000'] face_chibbi_ugh = ['01010010100', '01010010100', '00100001000', '00000000000', '00011110000'] def setCell(row, col, cell): if cell eq '0': scrollphat.set_pixel(row, col, 0) else: scrollphat.set_pixel(row, col, 1) # Displays a sprite defined in an array of 5 def displaySprite(sprite): for rowNum, row in sprite: for colNum, cell in row: setCell(rowNum, colNum, cell) scrollphat.update()
def clear(pause): for y in range(5): for x in range(11): scrollphat.set_pixel(x,y,0) scrollphat.update() time.sleep(pause)
return ('00000' + bcd_digit)[-5:] def plot_digit(digit, position): bcd_digit = string_to_bcd(digit) for y in range(0, 5, 1): scrollphat.set_pixel(position, y, int(bcd_digit[y]) == 1) while True: current = time.strftime('%H0%M0%S') for x in range(0, 8): plot_digit(current[x], x) for i in range(0, 5): scrollphat.set_pixel(10, i, (5 - i) <= ((int(current[3:5])) / 10)) scrollphat.update() time.sleep(0.5) # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY # OF SUCH DAMAGE.
#!/usr/bin/env python import sys import json import time import scrollphat if len(sys.argv) != 3: print("\nProblem") sys.exit(0) data = json.loads(sys.argv[1]) brightness = int(sys.argv[2]) scrollphat.set_brightness(brightness) for d in data: print data[d] scrollphat.set_pixel(data[d][0], data[d][1], True) scrollphat.update() sys.exit(0)
while total_time > elapsed: try: elapsed = time.time() - start # print elapsed blinkstate = not blinkstate blinker_line = (int)(elapsed / popov) # print blinker_line scrollphat.clear_buffer() for x in range(0, 11, 1): for y in range(0, 11, 1): loc_line = ((y * 11) + x) / 11 if loc_line == blinker_line: scrollphat.set_pixel(x, y, blinkstate) if loc_line > blinker_line: scrollphat.set_pixel(x, y, True) scrollphat.update() time.sleep(0.5) except KeyboardInterrupt: scrollphat.clear() sys.exit(-1) scrollphat.set_brightness(50) for t in range(0, 3, 1): for s in range(0, 5, 1): flash()
def columnPosition(self, columnNumber, position): '''Sets the twitter logo columns position''' if self.args.verbose: print( 'Running Twitter.columnPosition, columnNumber: %s, position: %s' % (columnNumber, position)) print('Logo orientation: %s' % self.orientation) # Orientation: REGULAR if (self.orientation == None) or (self.orientation == 'regular'): if columnNumber == 0: scrollphat.set_pixel(position, 2, 1) elif columnNumber == 1: scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) elif columnNumber == 2: scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 3: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 4: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 5: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 6: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 7: scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 8: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) elif columnNumber == 9: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) elif columnNumber == 10: scrollphat.set_pixel(position, 2, 1) else: print('columnPosition input error: %s' % columnNumber) # Orientation: INVERTED elif self.orientation == 'inverted': if columnNumber == 0: scrollphat.set_pixel(position, 2, 1) elif columnNumber == 1: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) elif columnNumber == 2: scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 3: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 4: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 5: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 6: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 7: scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 8: scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 9: scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) elif columnNumber == 10: scrollphat.set_pixel(position, 2, 1) else: print('columnPosition input error: %s' % columnNumber) else: print('Orientation unknown: %s' % self.orientation)
def num_1_6(): scrollphat.set_pixel(0,0,1) scrollphat.set_pixel(1,0,0) scrollphat.set_pixel(0,1,1) scrollphat.set_pixel(1,1,0) scrollphat.set_pixel(0,2,1) scrollphat.set_pixel(1,2,1) scrollphat.set_pixel(0,3,1) scrollphat.set_pixel(1,3,1) scrollphat.set_pixel(0,4,1) scrollphat.set_pixel(1,4,1)
#!/usr/bin/env python import scrollphat as sp import math import time import sys from random import randint i = 0 buf = [0] * 11 sp.set_brightness(20) while True: # light random pixels with random brightness sp.set_brightness(randint(1,100)) for q in range(randint(0,3)): y = randint(0,4) x = randint(0,10) sp.set_pixel(x,y,1) sp.update() time.sleep(0.1) sp.clear()
def paint(pause): for y in range(5): for x in range(11): scrollphat.set_pixel(x,y,1) scrollphat.update() time.sleep(pause)
def num_4_0(): scrollphat.set_pixel(9,0,1) scrollphat.set_pixel(10,0,1) scrollphat.set_pixel(9,1,1) scrollphat.set_pixel(10,1,1) scrollphat.set_pixel(9,2,1) scrollphat.set_pixel(10,2,1) scrollphat.set_pixel(9,3,1) scrollphat.set_pixel(10,3,1) scrollphat.set_pixel(9,4,1) scrollphat.set_pixel(10,4,1)
import math import time import sys from random import randint i = 0 buf = [0] * 11 while True: clear = (randint(0,1000)) # rnd var for timing of crashes change_brightness = (randint(0,2)) if change_brightness == 2: sp.set_brightness(randint(1,128)) y = randint(0,4) x = randint(0,10) sp.set_pixel(x,y,(randint(0,1))) sp.update() time.sleep(0.02) for r in range(0,2): y = randint(0,4) x = randint(0,10) sp.set_pixel(x,y,0) sp.update() time.sleep(0.01) if clear > 993: if clear > 996: for w in range(0,randint(3,9)): for x in range(0,11): for y in range(0,5): sp.set_pixel(x,y,randint(0,1)) sp.set_brightness(128)
#!/usr/bin/env python import scrollphat as sp import math import time import sys from random import randint while True: change_brightness = (randint(0,2)) if change_brightness == 2: sp.set_brightness(randint(1,32)) y = randint(0,4) x = randint(0,10) sp.set_pixel(x,y,(randint(0,1))) sp.update() time.sleep(0.02) for r in range(0,2): y = randint(0,4) x = randint(0,10) sp.set_pixel(x,y,0) sp.update() time.sleep(0.01)
#!/usr/bin/env python import math import time import scrollphat def millis(): return int(round(time.time() * 1000)) scrollphat.set_brightness(2) while True: for x in range(11): for y in range(5): scrollphat.set_pixel(x, y, 1) scrollphat.update() time.sleep(0.03) for x in range(11): for y in range(5): scrollphat.set_pixel(x, y, 0) scrollphat.update() time.sleep(0.03)
def mouthOpenColumn(self, columnNumber, position): '''Sets the columns for when it has the mouth open''' if self.args.verbose: print( 'Running PacmanRight.mouthOpenColumn, columnNumber: {}, position: {}' .format(columnNumber, position)) if columnNumber == 0: scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) elif columnNumber == 1: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 2: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 2, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 3: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 1, 1) scrollphat.set_pixel(position, 3, 1) scrollphat.set_pixel(position, 4, 1) elif columnNumber == 4: scrollphat.set_pixel(position, 0, 1) scrollphat.set_pixel(position, 4, 1) else: print('PacmanRight.mouthOpenColumn input error: {}'.format( columnNumber))
def switchon(): for x in range(11): for y in range(5): scrollphat.set_brightness(4) scrollphat.set_pixel(x,y,1) scrollphat.update();
def status(status): scrollphat.set_pixel(10,4,status) scrollphat.update()