s.close() print(ip) i = 0 scrollphat.set_brightness(20) #scrollphat.write_string("This is a test, hurrah! The quick brown fox jumps over the lazy dog. y2 = (math.sin(((i/2.0)+(x*10.0))/10.0) + 1) * 2.5", 0) cpu_values = [0] * 11 while True: cpu_values.pop(0) cpu_values.append(psutil.cpu_percent()) scrollphat.graph(cpu_values, 0, 25) time.sleep(0.2) # scrollphat.clear() # scrollphat.write_string("IP: " + ip + " ", 11) # for i in range(0, scrollphat.buffer_len() - 11): # scrollphat.scroll() # time.sleep(0.05) # scrollphat.clear() # scrollphat.write_string("Have a nice day! :-D ", 11) # for i in range(0, scrollphat.buffer_len() - 11): # scrollphat.scroll() # time.sleep(0.05)
import scrollphat as sp import time sp.set_brightness(64) while True: print("0 to 5") sp.graph([0,1,2,3,4,5]) time.sleep(1.0) sp.clear() print("0 to 10") sp.graph([0,2,4,6,8,10]) time.sleep(1.0) sp.clear()
ip = s.getsockname()[0] s.close() print(ip) i = 0 scrollphat.set_brightness(20) #scrollphat.write_string("This is a test, hurrah! The quick brown fox jumps over the lazy dog. y2 = (math.sin(((i/2.0)+(x*10.0))/10.0) + 1) * 2.5", 0) cpu_values = [0] * 11 while True: cpu_values.pop(0) cpu_values.append(psutil.cpu_percent()) scrollphat.graph(cpu_values, 0, 25) time.sleep(0.2) # scrollphat.clear() # scrollphat.write_string("IP: " + ip + " ", 11) # for i in range(0, scrollphat.buffer_len() - 11): # scrollphat.scroll() # time.sleep(0.05) # scrollphat.clear() # scrollphat.write_string("Have a nice day! :-D ", 11) # for i in range(0, scrollphat.buffer_len() - 11): # scrollphat.scroll() # time.sleep(0.05)
#!/usr/bin/env python import time import scrollphat scrollphat.set_brightness(64) while True: print("0 to 5") scrollphat.graph([0, 1, 2, 3, 4, 5]) time.sleep(1.0) scrollphat.clear() print("0 to 10") scrollphat.graph([0, 2, 4, 6, 8, 10]) time.sleep(1.0) scrollphat.clear()
#!/usr/bin/env python # https://www.hackster.io/masteruan/play-with-raspberry-pi-zero-and-phat-140b9ap import time import random import scrollphat scrollphat.set_brightness(10) values = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] while True: print("Generating random") for i in range(0, 11): values[i] = random.randint(0, 5) print values scrollphat.graph(values, 0, 5) time.sleep(0.2) scrollphat.clear()
#!/usr/bin/env python import time import scrollphat scrollphat.set_brightness(64) while True: print("0 to 5") scrollphat.graph([0,1,2,3,4,5]) time.sleep(1.0) scrollphat.clear() print("0 to 10") scrollphat.graph([0,2,4,6,8,10]) time.sleep(1.0) scrollphat.clear()
import scrollphat as sp import time sp.set_brightness(64) while True: print("0 to 5") sp.graph([0, 1, 2, 3, 4, 5]) time.sleep(1.0) sp.clear() print("0 to 10") sp.graph([0, 2, 4, 6, 8, 10]) time.sleep(1.0) sp.clear()
fourier = np.fft.rfft(data) fourier = np.delete(fourier, len(fourier) - 1) power = np.abs(fourier) matrix[0] = int(np.mean(power[power_index(0):power_index(156):1])) matrix[1] = int(np.mean(power[power_index(156):power_index(313):1])) matrix[2] = int(np.mean(power[power_index(313):power_index(625):1])) matrix[3] = int(np.mean(power[power_index(625):power_index(1000):1])) matrix[4] = int(np.mean(power[power_index(1000):power_index(2000):1])) matrix[5] = int(np.mean(power[power_index(2000):power_index(3000):1])) matrix[6] = int(np.mean(power[power_index(3000):power_index(4000):1])) matrix[7] = int(np.mean(power[power_index(4000):power_index(5000):1])) matrix[8] = int(np.mean(power[power_index(5000):power_index(6000):1])) matrix[9] = int(np.mean(power[power_index(6000):power_index(7000):1])) matrix[10] = int(np.mean(power[power_index(7000):power_index(8000):1])) matrix = np.divide(np.multiply(matrix, weighting), 1000000) matrix = matrix.clip(0, 5) matrix = [float(m) for m in matrix] return matrix list_devices() while True: data = stream.read(chunk) matrix = compute_fft(data, chunk, sample_rate) scrollphat.graph(matrix, 0, 5)
def show_graph(self, graph): scrollphat.graph(graph) if len(graph) > self.MATRIX_COLS: self.scroll_graph(len(graph)) self.sleep()
import scrollphat as hat import time str = 'Merry Christmas ' hat.set_brightness(2) hat.write_string(str) # for i in range(len(str) * 5): # hat.scroll() # time.sleep(0.150) hat.graph([2, 4, 6, 8, 10, 8, 6, 4, 2, 0, 3]) hat.update()