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 __init__: sckPin = Pin(18) mosiPin = Pin(23) misoPin = Pin(19) spi = SPI(1, baudrate=328125, bits=8, polarity=0, phase=1, sck=sckPin, mosi=mosiPin, miso=misoPin) spi.init() cs = Pin(2) dc = Pin(15) rst = Pin(0) # backlight on bl = Pin(12, Pin.OUT, value=1) lcd = pcd8544.PCD8544(spi, cs, dc, rst) lcd.contrast(0x3c, pcd8544.BIAS_1_40, pcd8544.TEMP_COEFF_0) lcd.reset() lcd.init() lcd.clear() buffer = bytearray((lcd.height // 8) * lcd.width) framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height) framebuf.fill(0) 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)
def decrypt_screen(): framebuf.fill(0) framebuf.text(wallets[wallet_index][0], 0, 0, 1) framebuf.text("secret", 36, 0, 1) framebuf.line(0, 8, 84, 8, 1) framebuf.text("Enter pin", 6, 15, 1) framebuf.text("to decrypt", 2, 38, 1) framebuf.rect(8, 25, 68, 11, 1) framebuf.text("0", 10, 27, 1) lcd.data(buffer)
def start_screen(): global wallets global wallet_index global wallet_page wallets = [] wallet_index = 0 wallet_page = 0 framebuf.fill(0) if state == 1000: framebuf.text('Writing', 0, 0, 1) else: framebuf.text('Scan the', 0, 0, 1) framebuf.text('card...', 0, 10, 1) framebuf.rect(8, 28, 68, 8, 1) lcd.data(buffer)
def display_wallet(): framebuf.fill(0) if wallet_index < len(wallets): framebuf.text(wallets[wallet_index][0], 0, 0, 1) framebuf.text("wallet", 36, 0, 1) framebuf.line(0, 8, 84, 8, 1) for y in range(1, 5): framebuf.text( wallets[wallet_index][1][(y - 1) * 10 + 40 * wallet_page:y * 10 + 40 * wallet_page], 0, 10 * y, 1) else: framebuf.text("End", 30, 0, 1) framebuf.text("session?", 10, 10, 1) framebuf.text('Press (3)', 6, 25, 1) framebuf.text('to restart', 2, 35, 1) lcd.data(buffer)
for i in range(5): a = data[i * 128:i * 128 + 128] address_type = ''.join(chr(i) for i in a[:4]) if address_type in wallet_types: print(address_type + " wallet detected") wallets.append([]) wallets[-1].append(address_type) wallets[-1].append(get_addr(a[4:64], address_type)) wallets[-1].append(a[64:]) if wallets: #print(wallets) display_wallet() state = 2 else: print("No wallets detected!") framebuf.fill(0) framebuf.text('No wallets', 0, 0, 1) framebuf.text('detected!', 0, 10, 1) framebuf.text('Press (3)', 6, 25, 1) framebuf.text('to restart', 2, 35, 1) lcd.data(buffer) state = -1 elif state == 2: if btn_1.value() == 0 and wallet_index != len(wallets): if len(wallets[wallet_index][1]) > 40: wallet_page = (wallet_page + 1) % 2 display_wallet() sleep(0.5) elif btn_2.value() == 0: wallet_index = (wallet_index + 1) % (len(wallets) + 1) wallet_page = 0
>>> bl.value(0) ``` Switch on the backlight: ```python >>> bl.value(1) ``` >>> import framebuf >>> buffer = bytearray((lcd.height // 8) * lcd.width) >>> framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height) Light every pixel: >>> framebuf.fill(1) >>> lcd.data(buffer) Clear screen: >>> framebuf.fill(0) >>> lcd.data(buffer) Print Hello, World! using the 8x8 font: >>> framebuf.text("Hello,", 0, 0, 1) >>> framebuf.text("World!", 0, 9, 1) >>> lcd.data(buffer) ## Referencias [Modulo para pcd8544](https://github.com/mcauser/micropython-pcd8544 ) [Con sensor DHT](https://github.com/mcauser/MicroPython-ESP8266-DHT-Nokia-5110)
lcd.init() lcd.clear() buffer = bytearray((lcd.height // 8) * lcd.width) framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height) rtc = machine.RTC() rtc.ntp_sync('a.ntp.br') rtc.init(rtc.now()) def watch(): data = strftime('%d/%m/%y') relogio = strftime('%H:%M:%S') lcd.position(0, 0) while True: framebuf.text(data, 10, 12, 1) framebuf.text(relogio, 10, 24, 1) lcd.data(buffer) agora = strftime('%H:%M:%S') if relogio != agora: relogio = agora framebuf.fill(0) # clear framebuffer utime.sleep(1) lcd.data(buffer) _thread.start_new_thread("clock", watch, ())
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)