コード例 #1
0
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)
コード例 #2
0
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)
コード例 #3
0
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)
コード例 #4
0
 def __init__(self):
     self.spi = SPI(1)
     self.spi.init(baudrate=8000000, polarity=0, phase=0)
     self.cs = Pin(2)
     self.dc = Pin(15)
     self.rst = Pin(0)
     self.bl = Pin(12, Pin.OUT)
     self.lcd = pcd8544.PCD8544(self.spi, self.cs, self.dc, self.rst)
     self.buffer = bytearray((self.lcd.height // 8) * self.lcd.width)
     self.framebuf = framebuf.FrameBuffer1(self.buffer, self.lcd.width, self.lcd.height)
コード例 #5
0
def test():
    print("Prueba exitosa")
    spi = SPI(1, baudrate=80000000, polarity=0, phase=0)
    #antes
    ##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)
    buffer = bytearray((lcd.height // 8) * lcd.width)
コード例 #6
0
def init():
    global lcd
    global bl
    spi = SPI(1)
    spi.init(baudrate=2000000, 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)

    lcd.init()
    print('LCD init')
    lcd.contrast(50)
コード例 #7
0
def test():
    print("Prueba exitosa")
    spi = SPI(1, baudrate=80000000, polarity=0, phase=0)
    #antes
    ##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)
    buffer = bytearray((lcd.height // 8) * lcd.width)
    #framebuf = framebuf.FrameBuffer1(buffer, lcd.width, lcd.height)
    gc.collect()
    bl.value(0)
    time.sleep(2)
    bl.value(1)
    time.sleep(2)
    bl.value(0)
コード例 #8
0
from utime import sleep
import pcd8544
import framebuf
import random

btn_1 = Pin(21, Pin.IN, Pin.PULL_UP)
btn_2 = Pin(26, Pin.IN, Pin.PULL_UP)
btn_3 = Pin(28, Pin.IN, Pin.PULL_UP)

spi = SPI(0)
spi.init(baudrate=2000000, polarity=0, phase=0)
print(spi)
cs = Pin(5)
dc = Pin(4)
rst = Pin(8)
lcd = pcd8544.PCD8544(spi, cs, dc, rst)
buffer = bytearray((lcd.height // 8) * lcd.width)
framebuf = framebuf.FrameBuffer(buffer, lcd.width, lcd.height,
                                framebuf.MONO_VLSB)

xor_key = []
entered_pin = ""
pin_digit = 0
key = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
reader = MFRC522(spi_id=1, sck=14, miso=12, mosi=15, cs=13, rst=20)
blocks = [
    1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, 26,
    28, 29, 30, 32, 33, 34, 36, 37, 38, 40, 41, 42, 44, 45, 46, 48, 49, 50, 52,
    53
]
data = []
コード例 #9
0
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)
コード例 #10
0
    def __init__(self, config_file='_config.json'):
        """
        Load wifi and octoprint configuration from a file
        :param config_file: provide config json file or default is _config.json
        """
        with open(config_file, 'r') as f:
            config = ujson.load(f)
            lcd_config = config.get('lcd_config')
            octoprint_config = config.get('octoprint_config')
            self.octoprint_url = octoprint_config.get('octoprint_base_url')
            self.api_key = octoprint_config['api_key']

            self.lcd_sck = int(lcd_config.get('sck'))
            self.lcd_bl = int(lcd_config.get('bl'))
            self.lcd_cs = int(lcd_config.get('cs'))
            self.lcd_dc = int(lcd_config.get('dc'))
            self.lcd_rst = int(lcd_config.get('rst'))
            self.lsd_miso = int(lcd_config.get('miso'))
            self.lsd_mosi = int(lcd_config.get('mosi'))

            wifi_config = config.get('wifi_config')
            self.wifi_ssid = wifi_config.get('ssid')
            self.wifi_pass = wifi_config.get("wifi_pass")

            self.lcd = None
            self.frame_buff = None
            bl = Pin(27, Pin.OUT, value=1)

            # def init(self) -> None:
            spi = SPI(1)
            spi.init(baudrate=2000000,
                     polarity=0,
                     phase=0,
                     bits=8,
                     firstbit=0,
                     sck=Pin(self.lcd_sck),
                     mosi=Pin(self.lsd_mosi),
                     miso=Pin(self.lsd_miso))

            self.lcd = pcd8544.PCD8544(spi=spi,
                                       cs=Pin(self.lcd_cs),
                                       dc=Pin(self.lcd_dc),
                                       rst=Pin(self.lcd_rst))

            self.buffer = bytearray((pcd8544.HEIGHT // 8) * pcd8544.WIDTH)
            self.frame_buff = _framebuf.FrameBuffer(self.buffer, pcd8544.WIDTH,
                                                    pcd8544.HEIGHT,
                                                    _framebuf.MONO_VLSB)

            self.lcd.contrast()
            # self.lcd.data(bytearray(
            #     [0x38, 0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34]))

            self.lcd.text(txt='Init...', clear_screen=True)
            wlan_connect = network.WLAN(network.STA_IF)
            wlan_connect.active(True)
            wlan_connect.connect(self.wifi_ssid, self.wifi_pass)

            self.lcd.text('Connecting to ', clear_screen=True)
            self.lcd.text(txt=self.wifi_ssid, y=2)
            while wlan_connect.status() != network.STAT_GOT_IP:
                sleep(1)

            self.lcd.text('Connecting to', clear_screen=True)
            self.lcd.text('OctoPrint', y=2)
            self.octoprint_client = OctoPrintClient(
                octoprint_url=self.octoprint_url, api_key=self.api_key)
            octoprint_version = self.octoprint_client.get_version_info()

            self.lcd.text('Connected:', clear_screen=True)
            self.lcd.text(str(octoprint_version['text']), y=2)