Skip to content

Instantly share code, notes, and snippets.

@Neradoc
Neradoc / write_file_to_eeprom.py
Last active January 24, 2022 01:36
Write a file to an EEPROM (that uses a single byte address) AT24C01A-AT24C16A
import board
import time
ADDRESS = 0x54
FILE_NAME = "eeprom_edit.bin"
####################################################################
# read the file
####################################################################
from keyboard_layout import KeyboardLayout
class KeyboardLayoutWinLang(KeyboardLayout):
ASCII_TO_KEYCODE = (
b'\x00' #
b'\x00' #
b'\x00' #
b'\x00' #
b'\x00' #
b'\x00' #
b'\x00' #
To format code on discord, using syntax highlighting, use 3 backticks (`)
- Start with 3 backticks followed by the language without spaces on the first line: ```python
Language name or language extensions are admissible, try and see (py, C, C++, etc.)
- Type your code in the following lines.
Note that the return key will not send the message until the code block is closed.
- End with 3 backticks alone on the closing line: ```
Example:
Hello, I get an error in this code in line 4, can someone help me ?
import time
import board
import busio
import neopixel
from adafruit_neokey.neokey1x4 import NeoKey1x4
from adafruit_debouncer import Debouncer
from collections import namedtuple
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
import board
import time
import socketpool
import ssl
import wifi
import adafruit_requests
try:
from secrets import secrets
except ImportError:
import board
import rtc
import struct
import time
import wifi
import socketpool
import displayio
import terminalio
from adafruit_display_text import bitmap_label as label
@Neradoc
Neradoc / displayio_pages.py
Last active June 24, 2021 16:52
This is a demo of using displayio to display different pages on button clicks (or timer). The second version requires Circuitpython 7.x with the fix for issue 4193 and adds the temperature sensor of the Clue.
import board
import displayio
from digitalio import DigitalInOut, Pull
import gc
import microcontroller
import terminalio
import time
from adafruit_display_text.bitmap_label import Label
from adafruit_debouncer import Debouncer
"""
Slightly over-engineered script to filter the versions on circuitpython.org
Prints out information to stderr while the resulting json file is printed to stdout
Run with:
python3 filter_cpyorg_version.py path/circuitpython-org.git/_data/files.json > new-files.json
Then replace the file and compare with:
git diff --diff-algorithm=histogram
"""
Manual commit to main
MOCK COMPILE,push,,refs/heads/main
MOCK UPLOAD,push,,refs/heads/main
Manual commit to not-main
MOCK COMPILE,push,,refs/heads/not-main
PR via a patch branch
MOCK COMPILE,push,,refs/heads/Neradoc-patch-1
MOCK COMPILE,pull_request,opened,refs/pull/4/merge
@Neradoc
Neradoc / cleanup_cp_interfaces.py
Created May 20, 2021 23:42
Generates a SystemConfiguration preferences file without the Circuitpython boards
"""
Generates a SystemConfiguration preferences file without the Circuitpython boards
Removes everything that has an interface in "usbmodem"
Creates a "output_preferences.plist" to replace the original with:
sudo cp output_preferences.plist /Library/Preferences/SystemConfiguration/preferences.plist
Might not work on Big Sur's heightened security.
Not tested with a reboot.
There might a better way to do that using the defaults command, once the python script has found all the service_id to remove.