Skip to content

Instantly share code, notes, and snippets.

View bmidgley's full-sized avatar

Brad Midgley bmidgley

  • Utah
  • 07:15 (UTC -06:00)
View GitHub Profile
@bmidgley
bmidgley / pioneer600.txt
Last active January 4, 2021 01:55
pioneer600 pi board detective work. what is on it?
ssd1306 on SPI bus:
# Raspberry Pi pin configuration:
RST = 19
# Note the following are only used with SPI:
DC = 16
bus = 0
device = 0
# 128x64 display with hardware SPI:
disp = SSD1306.SSD1306(RST, DC, SPI.SpiDev(bus,device))
@bmidgley
bmidgley / gist:40eb457db41a0dc04fd6227c8ccddb58
Created January 4, 2021 01:31
Code that runs the flashing pattern on the make salt lake "Zebra" from the arts festival
#include <FastLED.h>
#define piezoPin 3
#define LED_PIN 4
#define NUM_LEDS 15
#define BRIGHTNESS 25
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
radio.onReceivedString(function (receivedString) {
basic.showString(receivedString)
})
input.onButtonPressed(Button.A, function () {
radio.sendString("" + control.deviceSerialNumber())
})
let message = ""
basic.showString("ok")
serial.redirectToUSB()
radio.setGroup(11)
@bmidgley
bmidgley / marquee.js
Created January 7, 2020 15:51
microbit code to listen at 115k on usb serial for messages; print and broadcast the messages received
radio.onReceivedString(function (receivedString) {
basic.showString(receivedString)
})
input.onButtonPressed(Button.A, function () {
radio.sendString("" + control.deviceSerialNumber())
})
let message = ""
basic.showString("ok")
serial.redirectToUSB()
radio.setGroup(11)
@bmidgley
bmidgley / missing-assignments.py
Created January 7, 2020 04:21
send missing assignments out to the microbit to be printed and scrolled
#!/usr/bin/env python3
# sudo apt install python3-bs4
# curl -d 'sessionid=123&encses=456' https://skyward.alpinedistrict.org/scripts/wsisa.dll/WService=wsEAplus/sfgradebook001.w | ./missing-assignments.py >/dev/ttyACM0
from bs4 import BeautifulSoup
import sys
import time
soup = BeautifulSoup(sys.stdin.read(), 'html.parser')
@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
#!/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 / 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)
@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) {
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))