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
from micropython import const | |
import time | |
_CMD_TIMEOUT = const(100) | |
_R1_IDLE_STATE = const(1 << 0) | |
#R1_ERASE_RESET = const(1 << 1) | |
_R1_ILLEGAL_COMMAND = const(1 << 2) | |
#R1_COM_CRC_ERROR = const(1 << 3) |
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 utime as time | |
import umachine as machine | |
sht20_i2c_addr = 0b1000000 #0b1000000 = 0x40 | |
cmd_reset = 0b11111110 # 0b11111110 = 0xFE | |
cmd_trigger_temp_measurement_with_hold = 0b11100011 | |
cmd_trigger_humi_measurement_with_hold = 0b11100101 | |
cmd_trigger_temp_measurement_without_hold = 0b11110011 | |
cmd_trigger_humi_measurement_without_hold = 0b11110101 | |
cmd_user_register_read = 0b11100111 |
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 utime as time | |
import umachine as machine | |
import ubinascii as binascii | |
ds1338_address = 0b1101000 | |
def _bcd_to_int(bcd): | |
out = 0 | |
for d in (bcd >> 4, bcd): | |
for p in (1, 2, 4 ,8): |
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
from umachine import UART | |
import utime as time | |
debug = False | |
class Driver: | |
def __init__(self, uart): | |
if type(uart) is not UART: | |
raise ValueError("%s is not a valid type" % uart) | |
self.uart = uart |
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
#LCD 1602 I2C Driver | |
import utime as time | |
from umachine import I2C | |
LCD_CLEARDISPLAY = 0x01 | |
LCD_RETURNHOME = 0x02 | |
LCD_ENTRYMODESET = 0x04 | |
LCD_DISPLAYCONTROL = 0x08 | |
LCD_CURSORSHIFT = 0x10 |
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
from umachine import Pin, UART, WDT | |
import utime, ameba | |
relay_ctrl_pin = Pin("PD_4", mode=Pin.OUT) | |
uart = UART(0, rx="PA_6", tx="PA_7") | |
uart.init() | |
wdt = WDT() | |
utime.sleep(3) |
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, gc | |
import umachine as machine | |
import uterminal | |
from umachine import SPI, Pin, I2C | |
sys.path.append("/flash/lib") | |
#debug_uart = machine.UART(2, tx="PA_4", rx="PA_0", baudrate=115200) | |
#debug_uart.init() | |
#uterminal.register(debug_uart) |
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 usocket as socket | |
telnet_server_fd = socket.socket() | |
telnet_server_fd.bind(("0.0.0.0", 23)) | |
telnet_server_fd.listen(2) | |
telnet_client_fd = None | |
def setup_telnet(s): | |
global telnet_client_fd | |
telnet_client_fd, addr = telnet_server_fd.accept() | |
uterminal.register(telnet_client_fd) | |
telnet_client_fd.setblocking(False) |
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
ssh-copy-id -i ~/.ssh/id_rsa.pub USER@HOST |
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
try: | |
import ameba | |
import time | |
import uio as io | |
import array | |
import uctypes | |
from utils import fast_copy | |
except: | |
raise ImportError("ameba module import failed") |
OlderNewer