Skip to content

Instantly share code, notes, and snippets.

"""
NOTE: requires the usual secrets.py file
The test
- connects to the server
- sends headers to switch to websockets mode
- reads the headers that the server sends back
Note: the code doesn't do anything else with the connection,
it will hang or disconnect, but it should receive the headers first.
@Neradoc
Neradoc / picopico_safe_mode_boot.py
Last active July 12, 2023 07:49
boot.py implementing waiting to start into safe mode on Raspberry pico
import board
import time
from digitalio import DigitalInOut,Pull
led = DigitalInOut(board.LED)
led.switch_to_output()
safe = DigitalInOut(board.GP14) # <----- choose your pin with a button on it
safe.switch_to_input(Pull.UP)
@Neradoc
Neradoc / oled_temperature.py
Created March 3, 2021 16:15
Display a temperature sensor on an I2C OLED REPL with the QT PY Haxpress
import time
import board
print("I2C")
i2c = board.I2C()
while not i2c.try_lock():
i2c.unlock()
#i2c.unlock()
try:
scan = i2c.scan()
@Neradoc
Neradoc / code_openlcd_temp.py
Last active March 3, 2021 16:25
Display temperature on a Sparkfun SerLCD with a minimal driver
import time
import board
DISPLAY_ADDRESS1 = 0x72
i2c = board.I2C()
# from sparkfun_serlcd import Sparkfun_SerLCD_I2C
# lcd = Sparkfun_SerLCD_I2C(i2c,DISPLAY_ADDRESS1)
import openlcd_mini
# The MIT License (MIT)
#
# Copyright (c) 2017 Dan Halbert
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
AtoQ = {
"0" : ")",
"1" : "!",
"2" : "@",
"3" : "#",
"4" : "$",
"5" : "%",
"6" : "^",
"7" : "&",
"8" : "*",
@Neradoc
Neradoc / code_potar_neopixel_naive.py
Created March 13, 2021 04:17
My exploration of naive (bad) async, and a tasko version, of a potentiometer controlling neopixels
import board
import time
from analogio import AnalogIn
from digitalio import DigitalInOut,Pull
from simpleio import map_range
from neopixel import NeoPixel
# LED to blink
led = DigitalInOut(board.LED)
led.switch_to_output()
@Neradoc
Neradoc / test-circuitpython-build-tools.sh
Last active March 15, 2021 07:09
This is how I test circuitpython-build-tools (creation of the Circuitpython Librairies Bundle)
# https://github.com/adafruit/circuitpython-build-tools/
echo "don't run this script, it's more a list of commands to copy and paste as you need them"
exit 1
# installing the repositories, run only once
gh repo clone adafruit/Adafruit_CircuitPython_Bundle
cd Adafruit_CircuitPython_Bundle
git submodule init
@Neradoc
Neradoc / code_potar_blink_tasko.py
Last active May 1, 2021 18:43
My first example to discover how to use tasko (with a while True task and a scheduled task)
@Neradoc
Neradoc / compare_board_info_files.py
Last active March 25, 2021 02:33
Compare `files.json` files generated by Circuitpython `build_board_info.py`
import json
liste = set()
def print_once(text):
global liste
if text not in liste:
liste.add(text)
print(text)
def compare_files(oldfile_name,newfile_name):