示例#1
0
def main():
    micropython.kbd_intr(-1)
    machine.UART(0, 9600).init(
        9600)  # 9600 baud rate recommended by LoLin NodeMcu board
    for line in sys.stdin:

        raw = line

        if not nic.isconnected():
            led.on()
            if not network.STAT_CONNECTING:
                nic.connect('bloomu')

        else:
            led.off()
            if gprmcREG.match(raw):
                raw = raw.split(',')
                raw.pop(0)
                dateTime = raw[8] + raw[0]
                dateTime = dateTime.replace('.', '')
                locData = {
                    "lat": raw[2] + raw[3],
                    "long": raw[4] + raw[5],
                    "speed": raw[6]
                }
                data = {dateTime: locData}
                urequests.patch(dataBaseURL,
                                data=json.dumps(data),
                                headers={"content-type": "application/json"})
                data = {dateTime: raw}
                urequests.patch(
                    "https://bloombus-163620.firebaseio.com/rawLog/.json",
                    data=json.dumps(data),
                    headers={"content-type": "application/json"})
示例#2
0
def init():
    kbd_intr(-1)
    for p in PINS:
        if p in DPINS:
            p.set_pull(pin0.NO_PULL)
        else:
            p.is_touched()
示例#3
0
 def begin(self, type):
     micropython.kbd_intr(-1)
     try:
         while self.fin.any():
             self.fin.read()
     except AttributeError:
         pass
     self.write(bytearray([0x18, type]))
示例#4
0
 def deinit_tty(self):
     self.uart.deinit()  # clear out the UART
     self.display.show(None)  # remove the groups from the display
     try:
         from micropython import kbd_intr
         kbd_intr(3)
     except ImportError:
         pass
示例#5
0
 def __init__(self):
     try:
         from micropython import kbd_intr
         kbd_intr(-1)
     except ImportError:
         pass
     if hasattr(sys.stdin, "buffer"):
         self.rd_raw_fct = sys.stdin.buffer.read
     else:
         self.rd_raw_fct = sys.stdin.read
示例#6
0
 def init_tty(device):
     try:
         from micropython import kbd_intr
         kbd_intr(-1)
     except ImportError:
         pass
     if hasattr(sys.stdin, "buffer"):
         Editor.rd_raw_fct = sys.stdin.buffer.read
     else:
         Editor.rd_raw_fct = sys.stdin.read
    def __init__(self,
                 port=0,
                 data_rate=None,
                 host_id=2,
                 module_id=1,
                 debug=False):
        del data_rate
        tmcl_module_interface.__init__(self, host_id, module_id, debug)
        tmcl_host_interface.__init__(self, host_id, module_id, debug)

        self.__vcp = USB_VCP(port)
        self.__vcp.init()
        self.__vcp.setinterrupt(-1)
        micropython.kbd_intr(-1)
示例#8
0
    def __init__(self, Editor):
        self.init_display();
        self.init_terminal();

        Editor.KEYMAP['\x08'] = 0x08
        
        import busio, board
        self.uart = busio.UART(board.TX, board.RX, baudrate=115200,
                               timeout=0.1, receiver_buffer_size=64)
            
        try:
            from micropython import kbd_intr
            kbd_intr(-1)
        except ImportError:
            pass
示例#9
0
def start():
    if sys.implementation.name == "micropython":
        import micropython
        # ignore break
        micropython.kbd_intr(-1)
        fd = MicroPythonStdioNeoPixel()
    else:
        fd = StdioWrapper()

    srv = Server(fd, Noddy())

    while True:
        try:
            srv.next()
        except Exception as e:
            fd.write("\n\n\n+++ BAILING: %s\n\n\n" % e)
            if sys.implementation.name == "micropython":
                import machine
                fd.write("\n\n\n\n* RESETTING *\n\n\n")
                machine.reset()
            break
示例#10
0
def rx_callback(packet):
    micropython.kbd_intr(-1)
    if (packet != None):

        stdout.buffer.write(packet["payload"])
    micropython.kbd_intr(3)
示例#11
0
 def init_tty(device):
     try:
         from micropython import kbd_intr
         kbd_intr(-1)
     except ImportError:
         pass
示例#12
0
from microbit import *
import radio
import micropython

uart.init(115200)
# disable ctl-c interrupt in data stream
micropython.kbd_intr(-1)

radio.on()
radio.config(length=65)

buffer = bytearray(65)

display.show(Image.DIAMOND_SMALL)
value = 0

counter = 0

while (True):

    if button_b.was_pressed():
        value = value + 1
        buffer[1] = value
        radio.send_bytes(bytes([0, value, 0, 0]))

    if button_a.was_pressed():
        value = value - 1
        buffer[1] = value
        radio.send_bytes(bytes([0, value, 0, 0]))

    dat = uart.read(33)
示例#13
0
import micropython # to enable disabling of accidental keyboard interrupt
from microbit import *
import radio
radio.config(group=23)

uart.init(baudrate=10000, bits=8, parity=None, stop=1, tx=None, rx=pin1)
micropython.kbd_intr(-1) # disable accidental keyboard interrupt, no idea if this works or is needed
dataList = []
delay = 250
capsLock = True
message = ''

keyCodes = {
  139: 'Q', 207: 'W', 210: 'E', 215: 'R', 150: 'T', 219: 'Y', 222: 'U', 161: 'I', 226: 'O', 231: 'P', 
  142: 'A', 205: 'S', 145: 'D', 213: 'F', 154: 'G', 217: 'H', 157: 'J', 224: 'K', 224: 'K', 229: 'L', 
  140: 'Z', 208: 'X', 209: 'C', 148: 'V', 152: 'B', 153: 'N', 220: 'M', 225: ',', 165: '.', 149: '_', 164: '?', 
  138: '1', 206: '2', 146: '3', 147: '4', 214: '5', 218: '6', 159: '7', 158: '8', 162: '9', 163: '0'
}

while True:
    if uart.any():
        data = bytearray(1)
        uart.readinto(data, 1)
        dataList.append(data[0])
        if len(dataList) == 3:
            if dataList[0] in keyCodes:
                if capsLock:
                    letter = keyCodes[dataList[0]]
                else:
                    letter = keyCodes[dataList[0]].lower()
                display.show(letter)
示例#14
0
# test the micropython.kbd_intr() function

import micropython

try:
    micropython.kbd_intr
except AttributeError:
    print('SKIP')
    import sys
    sys.exit()

# just check we can actually call it
micropython.kbd_intr(3)
示例#15
0
from microbit import *
from micropython import kbd_intr

kbd_intr(-1)
uart.init(baudrate=115200, rx=pin0)

while True:
    if uart.any():
        b = uart.read(1)
        b = b[0]
        display.show(str(b))
        sleep(250)
    else:
        display.show(Image.DIAMOND)


import ustruct, time, machine, os

if os.uname()[0] == "esp8266":
    import micropython
    micropython.kbd_intr(
        -1)  # disable keyboard interrupts as otherwise gets killed by Ctrl-Cs
    uartUBX = machine.UART(0, baudrate=9600)
else:
    # The RX2 and TX2 on side of ESP32
    uartUBX = machine.UART(1, baudrate=9600, rx=16, tx=17)


def sendNMEA(comm):
    s = 0
    for c in comm:
        s ^= c
    uartUBX.write(b"${:s}*{:02x}\r\n".format(comm, s))


def appendchecksumUBX(comm):
    ca, cb = 0, 0
    for c in comm[2:]:
        ca = (ca + c) & 0xFF
        cb = (cb + ca) & 0xFF
    comm.append(ca)
    comm.append(cb)


def sendUBX(clsID, msgID, payload):  # look up on p138
    comm = bytearray((0xb5, 0x62, clsID, msgID, len(payload) & 0xFF,
                      (len(payload) >> 8) & 0xFF))
 def close(self):
     self.__vcp.setinterrupt(3)
     micropython.kbd_intr(3)
     self.__vcp.close()
     return 0
示例#18
0
 def init_tty(device):
     try:
         from micropython import kbd_intr
         kbd_intr(-1)
     except ImportError:
         pass
示例#19
0
 def end(self):
     micropython.kbd_intr(3)
示例#20
0
 def deinit_tty():
     try:
         from micropython import kbd_intr
         kbd_intr(3)
     except ImportError:
         pass
示例#21
0
# test the micropython.kbd_intr() function

import micropython

try:
    micropython.kbd_intr
except AttributeError:
    print('SKIP')
    raise SystemExit

# just check we can actually call it
micropython.kbd_intr(3)
示例#22
0
 def deinit_tty():
     try:
         from micropython import kbd_intr
         kbd_intr(3)
     except ImportError:
         pass
示例#23
0
    gps_data = str(u.read(), 'utf8')
    # Close the UART.
    u.deinit()

    # Get latitude and longitude from the read GPS data.
    lat = extract_latitude(extract_gps(gps_data))
    lon = extract_longitude(extract_gps(gps_data))

    return lat, lon

### End GPS Helper ###

### Initialize ###
mprint("Will resume bootup in {} seconds".format(INITIAL_BOOT_WAIT_SECONDS))
time.sleep(INITIAL_BOOT_WAIT_SECONDS) # allow time for keyboard interrupt during boot for interactive development
micropython.kbd_intr(-1) # disable keyboard interrupt

# determine which env to communicate with
check_last_env()

# Create a HDC1080 Temp/Humidity Sensor instance
sensor = HDC1080(I2C(1))

# Create a UART instance (this will talk to the GPS module).
u = UART(1, 9600)


while True:
    try:
        wdt.feed()       # refresh watchdog
        if state == INIT_CELLULAR: