Skip to content

Instantly share code, notes, and snippets.

@Corteil
Corteil / ibus_test.py
Created June 29, 2023 23:23
Circuitpython code for ibus servo protocal
import time
uart = busio.UART(rx=board.SLOT2.FAST2, tx=board.SLOT2.FAST1, baudrate=115200, bits=8, parity=None, stop=1 )
buffer=bytearray(31)
error_flag = False
while True:
c=uart.read(1)
#time.sleep(0.005)
@Corteil
Corteil / Balance-monitor-BMS.ino
Created May 20, 2023 08:20
added monitoring function and created a simple menu.
// CAN readout of VW type 5 modules
// ------- Programa adaptado por Alfonso para comunicar las celdas SDI de VW a 15-04-2022
// ------- Funciona con un Arduino nano, y el MCP2515, la interrupción del integrado interrumpe algunos comandos, pero en general va respondiendo con 1 módulo solo conectado.
//
// ------- Program adapted by Alfonso to communicate VW SDI cells to 04-15-2022
// ------- It works with an Arduino nano, and the MCP2515, the IC interrupt interrupts some commands, but in general it responds with only 1 module connected.
//
//
//
// Link información muy útil: https://openinverter.org/wiki/VW_Hybrid_Battery_Packs
@Corteil
Corteil / cheerlights.py
Created October 25, 2022 22:54
CheerLights MicroPython client for the Pimoroni Galactic Unicorn. You will need the secrets file with your network details, in the same folder as cheerlights.py to run on start rename cheerlights.py to main.py
# cheerlights
from time import sleep
from galactic import GalacticUnicorn
from picographics import PicoGraphics, DISPLAY_GALACTIC_UNICORN as DISPLAY
# setup graphics
gu = GalacticUnicorn()
graphics = PicoGraphics(DISPLAY)
@Corteil
Corteil / keybow.py
Last active October 4, 2022 19:53
Modified keybow.py file for KMK firmware
"""
KMK keyboard for Pimoroni Keybow.
WARNING: This doesn't currently function correctly on the Raspberry Pi Zero,
some of the keys are stuck in the 'pressed' position. There's either a bug in
the keypad implementation on the rpi0, or the pin numbers don't match the pins
in linux.
This is a 4x3 macro pad designed to fit the rpi's GPIO connector. Each key is
attached to a single GPIO and has an APA102 LED mounted underneath it.
@Corteil
Corteil / keybow.py
Last active September 24, 2022 20:22
Circuitpython code for the Keybow using a Raspberry Pico instead of a Raspberry Pi Zero
# based on example code from Adafruit and dglaude plus some of my own!
#
# https://github.com/dglaude/circuitpython_phat_on_pico/blob/main/keybow_mini.py
#
import time
import board
import digitalio
import adafruit_dotstar
@Corteil
Corteil / i2c_display.py
Last active January 4, 2022 20:04
helper python module for SSD1306 OLED displays
# Some of the below code is based on an example from Adafruit, please support them.
from time import sleep
import subprocess
from board import SCL, SDA
import busio
from PIL import Image, ImageDraw, ImageFont
import adafruit_ssd1306
import sys
@Corteil
Corteil / code.py
Created December 6, 2021 21:37
code for pocketmoneytronics.co.uk RGB Xmas tree for a Raspberry Pi or a Raspberry Pi Pico written in circuitpython
import board
import neopixel
from time import sleep
from random import randint
# Update this to match the number of NeoPixel LEDs connected to your board.
num_pixels = 6
pixels = neopixel.NeoPixel(board.GP18, num_pixels)
pixels.brightness = 0.05
@Corteil
Corteil / ServoTest.py
Created October 17, 2021 15:31
Simple servo test code for Dr Footleg's Sentinel hat.
import sentinelboard
from time import sleep
sb = sentinelboard.SentinelBoard()
sb.setServoPosition(1, 120)
sb.watchdogPause(0.2)
sleep(3)
@Corteil
Corteil / BasicRobotControl.py
Created October 16, 2021 18:40
Simple Rover robot manual drive code for Dr Footleg's Sentinel hat.
# Code for Brian Corteil's Tiny 4WD robot, based on code from Brian as modified by Emma Norling.
# Subsequently modified by Tom Oinn to add dummy functions when no explorer hat is available,
# use any available joystick, use the new function in 1.0.6 of approxeng.input to get multiple
# axis values in a single call, use implicit de-structuring of tuples to reduce verbosity, add
# an exception to break out of the control loop on pressing HOME etc.
# Modified by Brian Corteil to use @DrFootLeg's Sentinel robot controller hat
from time import sleep
try:
@Corteil
Corteil / Dtest.py
Created April 7, 2021 19:59
Dictionary example
colours = {'red': (254, 0, 0), 'green': (0, 254, 0), 'blue': (0, 0, 254), 'black': (0, 0, 0) }
# functions
def displayColour(colour):
global colours
print(f"{colour}'s RGB Value is { colours[colour] }")
# Main