Skip to content

Instantly share code, notes, and snippets.

View bmidgley's full-sized avatar

Brad Midgley bmidgley

  • Utah
  • 21:20 (UTC -06:00)
View GitHub Profile
void setup() {
// put your setup code here, to run once:
pinMode(15, OUTPUT);
pinMode(14, OUTPUT);
tone(15, 40);
tone(14, 40);
}
void loop() {
// put your main code here, to run repeatedly:
@bmidgley
bmidgley / image.py
Created February 16, 2019 20:58
ssd1306 python
#!/usr/bin/env python
# pip install Adafruit-GPIO Adafruit-PureIO Adafruit-SSD1306
import time
import Adafruit_GPIO.SPI as SPI
import Adafruit_SSD1306
from PIL import Image
RST = 24
DC = 23
SPI_PORT = 0
SPI_DEVICE = 0
@bmidgley
bmidgley / selfie.py
Last active February 20, 2019 04:50
#!/usr/bin/env python
import io
import time
import picamera
import Adafruit_SSD1306
from Adafruit_GPIO import SPI
from PIL import Image
RST = 24
@bmidgley
bmidgley / video.py
Created February 21, 2019 14:04
capture from camera in raw format for display
#!/usr/bin/env python3
import cv2
import io
import time
import picamera
import Adafruit_SSD1306
import numpy as np
from Adafruit_GPIO import SPI
from PIL import Image
#!/usr/bin/env python3
# sudo apt install build-essential python3-dev python3-pip libhdf5-100 libcblas3 libatlas3-base libjasper1
# pip3 install picamera opencv-contrib-python-headless luma.oled
import cv2
import io
import time
import math
from picamera import PiCamera
let sprite3: game.LedSprite = null
let sprite2: game.LedSprite = null
let sprite1: game.LedSprite = null
input.onButtonPressed(Button.B, function () {
sprite1.move(1)
radio.sendValue("movedto", sprite1.get(LedSpriteProperty.X))
})
input.onButtonPressed(Button.A, function () {
sprite1.move(-1)
radio.sendValue("movedto", sprite1.get(LedSpriteProperty.X))
@bmidgley
bmidgley / rc-car.js
Last active June 24, 2019 03:32
Use the accelerometer to drive an rc car made from the microbit and the elecfreaks.com servo driver board (probably also runs ring:bit car)
let reversing = 0
let pitch = 0
let roll = 0
radio.onReceivedValue(function (name, value) {
if (name == "roll") {
roll = value / 50
} else if (name == "pitch") {
pitch = (0 - value) / 50
}
if (pitch > 0) {
@bmidgley
bmidgley / pioneer600.py
Created June 8, 2019 02:44
Use luma to drive pioneer600 ssd1306 display
import os
import time
from PIL import Image
from luma.core.interface.serial import spi
from luma.oled.device import ssd1306
serial = spi(device=0, port=0, gpio_DC=16, gpio_RST=19) # luma defaults are gpio_DC=24, gpio_RST=25
device = ssd1306(serial)
image = Image.open(os.path.dirname(os.path.realpath(__file__)) +"/pioneer600.bmp").convert('1')
device.display(image)
#!/usr/bin/python
# Display host and IP on the "LCD RGB KEYPAD For RPi"
# invoke with hostname and ip address
# displaynet.py `hostname` `hostname -I`
# using deprecated Adafruit_CharLCD
# I don't know why Backpack has to be used to light the backlight
# Plate turns on the LED that is not part of the display
import sys
@bmidgley
bmidgley / ethernotes.txt
Created November 10, 2019 21:09
pi g-ether setup
# sudo su
sudo apt install dnsmasq -y
echo “dtoverlay=dwc2” >> /boot/config.txt
# Edit /boot/cmdline.txt and after rootwait, add:
modules-load=dwc2,g_ether
cat >/etc/network/interfaces.d/usb0 <<EOF
auto usb0