Exemplo n.º 1
0
def _try_update():
    os.sdconfig(os.SDMODE_SPI,
                clk=Pin(18),
                mosi=Pin(23),
                miso=Pin(19),
                cs=Pin(4))
    try:
        os.mountsd()
        print('SD card mounted')
    except OSError:
        print('SD card not found')
        return
    directories = os.listdir(SD_FOLDER)
    if 'update' not in directories:
        print('No update folder found')
        return
    print('Update folder found. Updating...')
    for filename in os.listdir(FLASH_FOLDER):
        if filename in [BACKUP_FILE, RUNTIME_CONFIG_FILE]:
            continue
        os.remove(filename)
        print('- removed {0}'.format(filename))
    for filename in os.listdir(UPDATE_FOLDER):
        with open(UPDATE_FILE.format(filename), 'r') as source:
            content = '\n'.join(source.readlines())
        with open(FLASH_FILE.format(filename), 'w') as destination:
            destination.write(content)
        print('- added {0}'.format(filename))
    for filename in os.listdir(UPDATE_FOLDER):
        os.remove(UPDATE_FILE.format(filename))
    os.rmdir(UPDATE_FOLDER)
    os.umountsd()
    print('Update completed')
Exemplo n.º 2
0
    def setup(self):
        """
        Setup ALL hardware devices attached to HUZZAH32
        """
        '''
        ## SD
        ## GPS:
        - Mode: # TODO
        ## OLED
        ## CELLULAR
        '''
        if self.sd:
            os.mountsd()

        self.gps.send_command(adafruit_gps.NMEA_OUTPUT_RMCGGA)
        self.gps.send_command(adafruit_gps.NMEA_UPDATE_2HZ)
        self.gps.send_command(adafruit_gps.FIX_CTL_1HZ)

        self.oled.contrast(255)
Exemplo n.º 3
0
def sd_mount():
    import os
    os.sdconfig(os.SDMODE_SPI, clk=18, mosi=23, miso=19, cs=4, maxspeed=40)
    os.mountsd()
Exemplo n.º 4
0
import os
import time
import json
import machine
from machine import Pin
import xfpga

os.mountsd()

boot_btn = Pin(0,mode=Pin.IN)
if(boot_btn()):
  start = time.ticks_ms()
  xfpga.overlay('esp32.bit')
  print(time.ticks_ms()-start)

f_cfg=open("/sd/board_config.json")
Board_Config=json.loads(f_cfg.read())
OverList=Board_Config["Overlay_List"]
print(OverList)


#I2C and cmd
def my_task(res): 
    global OverList
    cbtype = res[0]
    #display when slave send to master 
    if (cbtype == machine.I2C.CBTYPE_TXDATA):
        print("ESP32 Data sent to Arduino : addr={}, len={}, ovf={}, data={}".format(res[1], res[2], res[3], res[4]))
    #display when slave receive from master 
    elif (cbtype == machine.I2C.CBTYPE_RXDATA):
        print("ESP32 Data received from master: addr={}, len={}, ovf={}, data: [{}]".format(res[1], res[2], res[3], res[4]))
def prepareForWakeup():
    mpr121.set(10, True)
    time.sleep(0.05)  # Give the SD card time to initialize itself
    os.mountsd()
Exemplo n.º 6
0
def prepareForWakeup():
	time.sleep(0.05) # Give the SD card time to initialize itself
	os.mountsd()
Exemplo n.º 7
0
# old_tv project
__author__ = "HeSixian"

import json
import socket
import network
from time import sleep
from machine import Pin, SPI, Timer
from ssd1351 import Display
import os
#挂载sd卡
try:
    os.sdconfig(os.SDMODE_4LINE)
    os.mountsd(1)
except:
    print("mounted sd card failed!")

class OTV():
    def __init__(self):
        spi = SPI(2, sck=Pin(18), mosi=Pin(23), miso=Pin(19),baudrate=14500000)
        self.display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16))
        # self.display("连接MQTT服务器...")
        self.mqtt = network.mqtt("otv", "mqtt://t.hsxsix.com", user="******", password="******", 
                        cleansession=True, connected_cb=self.conncb, disconnected_cb=self.disconncb, 
                        subscribed_cb=self.subscb, published_cb=self.pubcb, data_cb=self.datacb)
        self.weather_data = {} 
        self.weather_api = 'http://118.24.144.127/weather/v1?city={}&node=micropython_ssd1351'
        self.weather_tm = Timer(2)
        self.weather_tm.init(period=1000*60*20, 
                mode=self.weather_tm.PERIODIC, callback=self.update_weather)
Exemplo n.º 8
0
def prepareForWakeup():
    sdcardPower.value(True)
    time.sleep(0.05)  # Give the SD card time to initialize itself
    os.mountsd()