This file contains hidden or 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 | |
from machine import Pin, I2C | |
import time | |
CLEAR_DISPLAY = const(0x01) | |
RETURN_HOME = const(0x02) | |
SET_ENTRY_MODE = const(0x04) | |
DISPLAY_ON = const(0x0C) | |
FUNCTION_SET = const(0x20) | |
OSC_FREQUENCY = const(0x10) |
This file contains hidden or 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 | |
from machine import Pin, I2C | |
import time | |
CLEAR_DISPLAY = const(0x01) | |
RETURN_HOME = const(0x02) | |
SET_ENTRY_MODE = const(0x04) | |
DISPLAY_ON = const(0x0C) | |
FUNCTION_SET = const(0x20) | |
OSC_FREQUENCY = const(0x10) |
This file contains hidden or 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 | |
from ssd1306 import SSD1306_SPI | |
SET_LOW_COLUMN = const(0x00) | |
SET_HIGH_COLUMN = const(0x10) | |
SET_PAGE_ADDR = const(0xb0) | |
SET_DISP_START_LINE = const(0x40) | |
class SH1106_SPI(SSD1306_SPI): | |
def show(self): |
This file contains hidden or 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 main(): | |
import network, socket | |
from machine import Pin | |
nic = network.WIZNET5K(pyb.SPI(2), Pin('PB12'), Pin('PC8')) | |
addr = socket.getaddrinfo('towel.blinkenlights.nl', 23)[0][-1] | |
s = socket.socket() | |
s.connect(addr) | |
while True: | |
data = s.recv(1500) | |
print(data.decode('utf-8'), end='') |
This file contains hidden or 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 main(): | |
import network, socket, ujson | |
from machine import Pin | |
nic = network.WIZNET5K(pyb.SPI(2), Pin('PB12'), Pin('PC8')) | |
addr = socket.getaddrinfo('api.fixer.io',80)[0][-1] | |
s = socket.socket() | |
s.connect(addr) | |
s.send(bytes('GET /latest?base=USD&symbols=JPY HTTP/1.0\r\nHost: api.fixer.io\r\n\r\n', 'utf8')) | |
result = s.recv(1000) | |
s.close() |
This file contains hidden or 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 main(): | |
import urequests | |
r = urequests.get('http://api.fixer.io/latest?base=USD&symbols=JPY') | |
j = r.json() | |
print(j["date"]) | |
print("JPY/" + j["base"] + ": " + str(j["rates"]["JPY"])) |
This file contains hidden or 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 ST7735 import TFT,TFTColor | |
from machine import SPI,Pin | |
spi = SPI(2, baudrate=20000000, polarity=0, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12)) | |
tft=TFT(spi,16,17,18) | |
tft.initr() | |
tft.rgb(True) | |
tft.fill(TFT.BLACK) | |
minX = -2.0 | |
maxX = 1.0 |
This file contains hidden or 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
# Connect IO25 to DIN | |
import machine, neopixel, time | |
np = neopixel.NeoPixel(machine.Pin(25), 8) | |
for i in range(65): | |
np[(i + 7) % 8] = (0,0,0) | |
np[i % 8] = ((i * 4) % 64, (i * 8) % 64, (i * 16) % 64) | |
np.write() | |
time.sleep_ms(40) | |
This file contains hidden or 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 lan_connect(spi, cs, reset): | |
import network | |
nic = network.WIZNET5K(spi,cs,reset) | |
while not nic.isconnected(): | |
pass | |
nic.active(True) | |
nic.ifconfig('dhcp') | |
print('network config:', nic.ifconfig()) | |
def main(): |
This file contains hidden or 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 binascii | |
id = binascii.unhexlify("330051001551343236363539") | |
hash = 0x811c9dc5 | |
for b in id: | |
hash = 16777619 * hash ^ b | |
print(hex(hash & 0x00ffffff)) |
OlderNewer