Skip to content

Instantly share code, notes, and snippets.

View RobCranfill's full-sized avatar

Rob Cranfill RobCranfill

View GitHub Profile
@RobCranfill
RobCranfill / feather_rp2040.ino
Created October 9, 2024 00:49
Test of new anemometer hardware with Feather RP2040 and Arduino code
// Based on https://how2electronics.com/interfacing-anemometer-npn-pulse-output-with-arduino/
unsigned long DEBOUNCE_DELAY = 1000; // the debounce time; increase if the output flickers
int PIN_INTERRUPT = 25;
unsigned long lastDebounceTime_ = 0; // the last time the output pin was toggled
int count_ = 0;
int iter_ = 0;
@RobCranfill
RobCranfill / GigabyteDesktop_Sleep_Fix.sh
Last active October 4, 2024 20:55
Fix for Gigabyte Linux suspend bug - from DAK404
#!/bin/bash
############################################################
# Sleep/Wakeup Fix For Gigabyte Motherboards
#
# ----------------------------------------------------------
# ATTENTION!
# This script can be run in a single line from your shell!
# Simply run the following in the Terminal:
#
@RobCranfill
RobCranfill / LEDMatrixDisplay.py
Created August 24, 2024 17:24
Display text on an Adafruit 8x8 LED matrix; either scroll a line of text, or display a single updatable character at a time.
# New version for CircuitPython on a microcontroller - (c)2024
# Now packaged as a class, with single-character mode
# based on
# displayText.py
# (c)2020 [email protected]
#
import board
import time
@RobCranfill
RobCranfill / index-down.html
Created August 22, 2024 00:17
Bash script to check how old the Crandard file is, and copy the "down" file if it's too old.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="30">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<link href='https://fonts.googleapis.com/css?family=Stylish' rel='stylesheet'>
@RobCranfill
RobCranfill / open_page.sh
Created June 22, 2024 00:07
Startup script for Raspberry Pi weather kiosk
#!/bin/bash
# Open the Weewx page
# other flags are possible. which?
chromium-browser --start-fullscreen http://pi4/weewx/Crandard &
@RobCranfill
RobCranfill / backupwee.sh
Created May 25, 2024 19:03
Back up data files for WeeWX
#!/bin/bash
# back up weewx
# as per https://www.weewx.com/docs/4.10/usersguide.htm#backup
# param: $1: archive name (date?)
# will create directory in cd
# run this as root to only get prompted once for pw (if that)
BASE_NAME=$1
@RobCranfill
RobCranfill / neopixel_test.py
Created February 29, 2024 18:03
My standard "Hello, world" for a micro-controller with a NeoPixel on it.
# Based on code from Adafruit Industries
# SPDX-License-Identifier: MIT
"""Rob's CircuitPython blink example for built-in NeoPixel LED"""
import time
import board
import neopixel
import random
k = 20 # number of steps up or down
@RobCranfill
RobCranfill / lcd_util.py
Created November 30, 2023 18:05
Turn Adafruit miniPiTFT backlight on/off
# For the Adafruit miniPiTFT 3.3" LCD display: turn the backlight on/off (usually off).
# robcranfill
import board
import digitalio
import sys
def set_backlight_state(backlight_on: bool) -> None:
backlight_ = digitalio.DigitalInOut(board.D22)
backlight_.switch_to_output()
@RobCranfill
RobCranfill / no_auto_reload.md
Last active March 13, 2025 05:40
Turn off automatic reload of the code in CircuitPython
# To make a CP device stop auto-reloading code,

<code>
import supervisor
supervisor.runtime.autoreload = False  # CirPy 8 and above
print("supervisor.runtime.autoreload = False")

@RobCranfill
RobCranfill / bootloader.py
Last active July 27, 2024 14:15
Put CircuitPython device into bootloader mode; useful on my QTPy that I broke the BOOTSEL button on!
import microcontroller
microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER)
microcontroller.reset()