def plot(datos): import framebuf spi = SPI(1, baudrate=328125, polarity=0, phase=0) cs = Pin(2) #D4 dc = Pin(15) #D8 rst = Pin(0) #D3 #bl = Pin(12, Pin.OUT, value=1) #D6 print("Variables:OK") lcd = pcd8544.PCD8544(spi, cs, dc, rst) print("lcd ok") buffer = bytearray((lcd.height // 8) * lcd.width) framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height) framebuf.fill(1) lcd.data(buffer) time.sleep(1) framebuf.fill(0) lcd.data(buffer) for i,y in zip(range(84),datos): print(i, " {" ,round(y), "} ") time.sleep_ms(40) framebuf.pixel(i,round(y),1) #eje y #print(save) framebuf.vline(0, 0, 96, 0xffff) #eje x framebuf.hline(0, 24, 96, 0xffff) #escribiendo datas lcd.data(buffer)
def plotseno(w, phi, amplitud): import framebuf spi = SPI(1, baudrate=328125, polarity=0, phase=0) cs = Pin(2) #D4 dc = Pin(15) #D8 rst = Pin(0) #D3 #bl = Pin(12, Pin.OUT, value=1) #D6 print("Variables:OK") lcd = pcd8544.PCD8544(spi, cs, dc, rst) print("lcd ok") buffer = bytearray((lcd.height // 8) * lcd.width) framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height) framebuf.fill(1) lcd.data(buffer) time.sleep(1) framebuf.fill(0) lcd.data(buffer) save = [] for i in range(84): y = 24 - amplitud * math.sin((i * w) + phi) save.append(y) print(i, " {", round(y), "} ", y) time.sleep_ms(40) framebuf.pixel(i, round(y), 1) #eje y print(save) framebuf.vline(0, 0, 96, 0xffff) #eje x framebuf.hline(0, 24, 96, 0xffff) #escribiendo datas lcd.data(buffer)
lcd.init() # #termox #framebuf.pixel(8,47,1) #framebuf.pixel(7,46,1) #framebuf.pixel(6,45,1) #framebuf.pixel(5,44,1) #framebuf.pixel(4,43,1) #framebuf.pixel(3,42,1) #framebuf.pixel(2,41,1) #framebuf.pixel(1,40,1) #framebuf.pixel(0,39,1) # #w=0.09 #nice baja frecuencia w = 0.09 phi = 0 amplitud = 16 #Amplitud maxima 22. Aplitud minima 2. Sin DC. #Frecuencia minima 0.05. Frecuencia maxima 0.6 for i in range(84): y = 24 - amplitud * math.sin((i * w) + phi) print(i, round(y), y) time.sleep_ms(40) framebuf.pixel(i, round(y), 1) #framebuf.vline(5, 0, 96, 0xffff) framebuf.vline(0, 0, 96, 0xffff) framebuf.hline(0, 24, 96, 0xffff) lcd.data(buffer)
def urectangular(max, puntos, K, amplitud, w0, phi): print("urectangular") import framebuf spi = SPI(1, baudrate=328125, polarity=0, phase=0) cs = Pin(2) #D4 dc = Pin(15) #D8 rst = Pin(0) #D3 #bl = Pin(12, Pin.OUT, value=1) #D6 print("Variables:OK") lcd = pcd8544.PCD8544(spi, cs, dc, rst) print("lcd ok") buffer = bytearray((lcd.height // 8) * lcd.width) framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height) framebuf.fill(1) lcd.data(buffer) time.sleep(1) framebuf.fill(0) lcd.data(buffer) print("Iniciando...") count = 0 y_record = [] # y_res = [] T = calculadora.ulinspace(max, puntos) #print(T) for k in range(1, K + 1): #print("k -> ",k) for t in T: #print("Operacion: ", "k -> ",k, ", t -> ",t) y = amplitud * (4 / math.pi) * (math.sin( ((2 * k - 1) * (w0 * t + phi))) / (2 * k - 1)) y_record.append(y) #Lista de puntos de la funcion. time.sleep_ms(10) count = count + 1 gc.collect() #diseno: esta agregando a la lista ambas funciones. # print(count, "ok") time.sleep(1) print("Puntos: ", len(T), ", tamano del arreglo ", len(y_record), " presicion: ", K) for i in range(puntos): #print("Suma: ", i, " con ", i+(K-1)*puntos ) #time.sleep(0.2) y_res.append(y_record[i] + y_record[i + (K - 1) * puntos]) time.sleep_ms(10) K = K - 1 while K != 1: for i in range(puntos): #print("Suma while: ", i, " con ", i+(K-1)*puntos ) #time.sleep(0.2) y_res[i] = y_res[i] + y_record[i + (K - 1) * puntos] time.sleep_ms(10) print("Tamano del arreglo res", len(y_res), "presicion: ", K) K = K - 1 print(len(y_res)) count = 1 for y in y_res: print(y, round(y)) time.sleep_ms(10) framebuf.pixel(count, 24 - round(y), 1) count = count + 1 #eje y framebuf.vline(0, 0, 96, 0xffff) #eje x framebuf.hline(0, 24, 96, 0xffff) #escribiendo datas lcd.data(buffer)
framebuf.fill(0) framebuf.pixel(0, 0, 1) framebuf.pixel(0, 2, 1) framebuf.pixel(2, 0, 1) framebuf.pixel(2, 2, 1) lcd.data(buffer) # line(x1, y1, x2, y2, color) framebuf.fill(0) framebuf.line(0, 47, 83, 0, 1) framebuf.line(83, 47, 0, 0, 1) lcd.data(buffer) # hline(x, y, w, color) framebuf.fill(0) framebuf.hline(0, 10, 20, 1) framebuf.hline(0, 20, 41, 1) framebuf.hline(0, 30, 62, 1) framebuf.hline(0, 40, 83, 1) lcd.data(buffer) # vline(x, y, h, color) framebuf.fill(0) framebuf.vline(10, 0, 11, 1) framebuf.vline(20, 0, 23, 1) framebuf.vline(30, 0, 35, 1) framebuf.vline(40, 0, 47, 1) lcd.data(buffer) # rect(x, y, w, h, c) framebuf.fill(0)