def show_secret():
    framebuf.fill_rect(0, 9, 84, 38, 0)
    wt = wallet_types[wallets[wallet_index][0]][1]
    for y in range(1, 5):
        framebuf.text(
            decr(wallets[wallet_index][2],
                 wt)[(y - 1) * 10 + 40 * secret_page:y * 10 +
                     40 * secret_page], 0, 10 * y, 1)
    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 refresh_pin():
    framebuf.fill_rect(9, 26, 66, 9, 0)
    if entered_pin:
        framebuf.text("*" * len(entered_pin), 10, 27, 1)
    framebuf.text(str(pin_digit), 10 + 8 * len(entered_pin), 27, 1)
    lcd.data(buffer)
         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
         display_wallet()
Beispiel #6
0
#lcd.light_on()
#lcd.light_off()

# Use a framebuffer to store the 4032 pixels (84x48):

import framebuf
width = 84
height = 48
pages = height // 8
buffer = bytearray(pages * width)
framebuf = framebuf.FrameBuffer1(buffer, width, height)

# Print Hello, World! using the 8x8 font:

framebuf.text("Hello,", 0, 0, 1)
framebuf.text("World!", 0, 9, 1)
lcd.data(buffer)
sleep(5)


def elTime(sec):
    m, s = divmod(seconds, 60)
    h, m = divmod(m, 60)
    return "%02d:%02d:%02d" % (h, m, s)


import dht
DHTPIN = Pin(2)
dht = dht.DHT22(DHTPIN)
Beispiel #7
0
print("Variables:OK")
lcd = pcd8544.PCD8544(spi, cs, dc, rst)
print("lcd ok")
#bl.value(0)
#time.sleep(2)
#bl.value(1)
import framebuf
buffer = bytearray((lcd.height // 8) * lcd.width)
framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height)
framebuf.fill(1)
lcd.data(buffer)
time.sleep(2)
framebuf.fill(0)
lcd.data(buffer)
#
framebuf.text("Hello,", 0, 0, 1)
framebuf.text("World!", 0, 9, 1)
lcd.data(buffer)
time.sleep(1)
#
#
framebuf.fill(0)
framebuf.text("Bye!", 0, 9, 1)
lcd.data(buffer)
#
time.sleep(2)
framebuf.fill(0)
lcd.data(buffer)
#
lcd.data(bytearray([0x55, 0xAA] * 42 * 6)) #imprime puntutos separados:test pattern (50% on)
time.sleep(1)
Beispiel #8
0
bl = Pin(12, Pin.OUT, value=1)

lcd = pcd8544.PCD8544(spi, cs, dc, rst)

import framebuf
buffer = bytearray((pcd8544.HEIGHT // 8) * pcd8544.WIDTH)
framebuf = framebuf.FrameBuffer(buffer, pcd8544.WIDTH, pcd8544.HEIGHT,
                                framebuf.MONO_VLSB)

# fill(color)
framebuf.fill(1)
lcd.data(buffer)

# text(string, x, y, color)
framebuf.fill(0)
framebuf.text('Nokia 5110', 0, 0, 1)
framebuf.text('PCD8544', 0, 10, 1)
framebuf.text('84x48', 0, 20, 1)
framebuf.text('uPython1.9', 0, 30, 1)
framebuf.text('ESP8266', 0, 40, 1)
lcd.data(buffer)

# pixel(x, y, colour)
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)
Beispiel #9
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)
Beispiel #10
0
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, ())
# should see sensor at [92]

dht = dht12.DHT12(i2c)

# Initialise SPI for display
spi = SPI(1, baudrate=80000000, polarity=0, phase=0)
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)

# Initialise framebuffer for display
buffer = bytearray((lcd.height // 8) * lcd.width)
framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height)

# Update display
while(True):
	dht.measure()
	framebuf.fill(0)
	framebuf.text("DHT12 I2C", 0, 0, 1)
	framebuf.text("Temp", 0, 11, 1)
	framebuf.text("%.1f" % dht.temperature(), 0, 20, 1)
	framebuf.text("Humidity", 0, 31, 1)
	framebuf.text("%.1f" % dht.humidity(), 0, 40, 1)
	lcd.data(buffer)
	time.sleep_ms(4000)
Beispiel #12
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)

while True:
    framebuf.fill(0)
    lcd.data(buffer)
    date, time = getDateTime()
    framebuf.text(date, 3, 16, 1)
    framebuf.text(time, 10, 26, 1)
    lcd.data(buffer)
    utime.sleep(1)
          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)

framebuf.text("Hello", 22, 16, 1)
framebuf.text("World", 22, 26, 1)
lcd.data(buffer)
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)

while True:	
	for i in range(10):
		framebuf.fill(0)
		lcd.data(buffer)
		framebuf.text(str(i), 10, 12, 1)
		lcd.data(buffer)
		utime.sleep(1)

Beispiel #15
0
          baudrate=2000000,
          polarity=0,
          phase=0,
          pins=('P23', 'P22', 'P17'))
cs = Pin('P20')
dc = Pin('P21')
rst = Pin('P19')

# backlight on
bl = Pin('P11', Pin.OUT, value=1)

lcd = pcd8544.PCD8544(spi, cs, dc, rst)

buffer = bytearray((lcd.height // 8) * lcd.width)
framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height)
framebuf.text('192.168.', 0, 0, 1)
lcd.data(buffer)
#TX(PIN 3) RX(PIN 4)
uart = UART(1, 9600)  # init with given baudrate
uart.init(9600, bits=8, parity=None, stop=1)  # init with given parameters

#Fichero HTML a mandar
html1 = """
<html>
<script>
var lastX=128;
var lastY=128;
var myVar = setInterval(loadDoc, 200);
function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
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)
Beispiel #17
0
print("Variables:OK")
lcd = pcd8544.PCD8544(spi, cs, dc, rst)
print("lcd ok")
#bl.value(0)
#time.sleep(2)
#bl.value(1)
import framebuf
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)
#
framebuf.text("Hello,", 0, 0, 1)
lcd.data(buffer)
#
time.sleep(1)
framebuf.fill(0)
lcd.data(buffer)
#
time.sleep(1)
lcd.clear()
#draw 8x16 in bank 0 (rows 0..7)
#lcd.position(0, 0)
#lcd.data(bytearray(b'\xE0\x38\xE4\x22\xA2\xE1\xE1\x61\xE1\x21\xA2\xE2\xE4\x38\xE0\x00'))
# draw 8x16 in bank 1 (rows 8..15)
#lcd.position(0, 1)
#lcd.data(bytearray(b'\x03\x0C\x10\x21\x21\x41\x48\x48\x48\x49\x25\x21\x10\x0C\x03\x00'))
#time.sleep(1)
from machine import Pin, SPI
import time
import pcd8544
import framebuf
import machine
spi = SPI(2)
spi.init(baudrate=80000000, polarity=0, phase=0)
cs = Pin(2)
dc = Pin(15)
rst = Pin(0)
bl = Pin(12, Pin.OUT, value=1)

lcd = pcd8544.PCD8544(spi, cs, dc, rst)
buffer = bytearray((lcd.height // 8) * lcd.width)
framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height)

framebuf.fill(0)
framebuf.text("ESP32", 25, 9, 1)
framebuf.text("uPython", 15, 18, 1)
framebuf.text("Nokia-5110", 2, 27, 1)
lcd.data(buffer)