This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urequests | |
import ujson | |
import time | |
# APIkey findes under Profil -> Account -> API | |
apiKey = "keyCGxxXYZXYZXYZ" | |
# baseID findes under din base -> Help -> API documentation | |
baseID = "app0UKKXYZXYZXYZ" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import network | |
# Connect to a specific wifi network | |
def connect(essid, password, timeout=30000): | |
wifi = network.WLAN(network.STA_IF) | |
wifi.active(True) | |
if not wifi.isconnected(): | |
print("Connecting to WiFi network...") | |
wifi.connect(essid, password) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import PySide2.QtCore as QtCore | |
import PySide2.QtWidgets as QtWidgets | |
class Worker(QtCore.QObject): | |
on_start = QtCore.Signal() | |
def on_start(self): | |
print("This line is executed!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ure | |
def parseDateTime(datestr): | |
regex = ("^(19|2[0-9][0-9][0-9])-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])" | |
"T(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(.([0-9]*))?" | |
"((\\+|-)[0-1][0-9]:[0-9][0-9])?$") | |
match = ure.match(regex, datestr) | |
if match: | |
year = int(match.group(1)) | |
month = int(match.group(2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def enter_raw_repl(self): | |
# Brief delay before sending RAW MODE char if requests | |
if _rawdelay > 0: | |
time.sleep(_rawdelay) | |
self.serial.write(b'\x02') # ctrl-B: exit RAW repl | |
time.sleep(0.5) | |
self.serial.write(b'\x03') # ctrl-C | |
time.sleep(0.5) | |
self.serial.write(b'\r\x03\x03') # ctrl-C twice: interrupt any running program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import machine | |
import time | |
import network | |
import urequests | |
# Function to connect to a specific wifi network | |
def connectToWifi(wifi, essid, password, timeout): | |
if not wifi.isconnected(): | |
print("Connecting to WiFi network...") | |
wifi.connect(essid, password) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import machine | |
import time | |
# Python version of | |
# https://www.arduino.cc/reference/en/language/functions/advanced-io/pulsein/ | |
# returns duration in MICRO seconds | |
def pulseIn(pin, value): | |
# Wait till we hit the wanted value | |
while pin.value() != value: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tilstandsvariablen | |
lockState = "LOCKED" | |
# Tegner en lås givet (x,y) koordinat, størrelsesangivelse og | |
# en boolean open, der angiver om låsen skal tegnes som låst | |
# eller åben (True = Åben) | |
def drawLock(x, y, size, open): | |
fill(0) | |
rect(x-1.3*size/2,y-size/2, 1.3*size, size, size/10) | |
noFill() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int colour = 0; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
colour = (colour + 1) % 255; | |
Serial.println(colour); | |
delay(10); |
NewerOlder