def graphAnim(): sphd.set_brightness(0.2) sphd.set_graph(values, 3, 7, 1.0, 0, 0, 17, 6) sphd.show() for index in range(0, 17): changeValue(index) time.sleep(0.008)
def display_fft(self, bins): if self.busy: return self.busy = True scrollphathd.set_graph(bins, low=0, high=65535, brightness=0.5, x=0, y=0) scrollphathd.show() self.busy = False
def do_graph(self, this_program): min_value = 0 max_value = 50 values = [0] * WIDTH while self.program == this_program and not self._got_stop_event(): values.insert(0, random.randrange(min_value, max_value)) values = values[:WIDTH] scrollphathd.set_graph(values, low=min_value, high=max_value, brightness=0.3) scrollphathd.show() time.sleep(0.03)
Press Ctrl+C to exit! """) MIN_VALUE = 0 MAX_VALUE = 50 # Uncomment the below if your display is upside down # (e.g. if you're using it in a Pimoroni Scroll Bot) scrollphathd.rotate(degrees=180) # Begin with a list of 17 zeros values = [0] * scrollphathd.DISPLAY_WIDTH while True: # Insert a random value at the beginning values.insert(0, random.randrange(MIN_VALUE, MAX_VALUE)) # Get rid of the last value, keeping the list at 17 (DISPLAY_WIDTH) items values = values[:scrollphathd.DISPLAY_WIDTH] # Plot the random values onto Scroll pHAT HD scrollphathd.set_graph(values, low=MIN_VALUE, high=MAX_VALUE, brightness=0.3) scrollphathd.show() time.sleep(0.05)
print(""" Scroll pHAT HD: CPU Displays a graph with CPU values. Press Ctrl+C to exit! """) i = 0 cpu_values = [0] * scrollphathd.DISPLAY_WIDTH # Uncomment the below if your display is upside down # (e.g. if you're using it in a Pimoroni Scroll Bot) scrollphathd.rotate(degrees=180) while True: try: cpu_values.pop(0) cpu_values.append(psutil.cpu_percent()) scrollphathd.set_graph(cpu_values, low=0, high=25, brightness=0.25) scrollphathd.show() time.sleep(0.2) except KeyboardInterrupt: scrollphathd.clear() sys.exit(-1)
#!/usr/bin/env python import time import random import scrollphathd print(""" Scroll pHAT HD: Graph Displays a graph with random values. Press Ctrl+C to exit! """) scrollphathd.rotate(180) values = [] for i in range(17): values.append(0) while True: values.insert(0, random.randrange(0, 50)) if len(values) > 17: values.pop(-1) scrollphathd.set_graph(values, low=0, high=50, brightness=0.1) scrollphathd.show() time.sleep(0.05)
import scrollphathd as sphd print(""" Scroll pHAT HD: CPU Displays a graph with CPU values. Press Ctrl+C to exit! """) i = 0 cpu_values = [0] * sphd.DISPLAY_WIDTH sphd.rotate(180) while True: try: cpu_values.pop(0) cpu_values.append(psutil.cpu_percent()) sphd.set_graph(cpu_values, low=0, high=25, brightness=0.25) sphd.show() time.sleep(0.2) except KeyboardInterrupt: sphd.clear() sys.exit(-1)