Skip to content

Instantly share code, notes, and snippets.

View lesp's full-sized avatar
🏠
Working from home

Les lesp

🏠
Working from home
View GitHub Profile
@lesp
lesp / news_app.py
Created May 29, 2026 15:33
Pimoroni Presto News App
# ICON news
# NAME News Feed
# DESC The latest news, direct to your Presto
import requests
from presto import Presto
from picovector import PicoVector, ANTIALIAS_BEST
from time import sleep
import qrcode
presto = Presto()
@lesp
lesp / index.html
Created August 9, 2022 14:06
Tom's Hardware Raspberry Pi Pico W Web Server: Bootstrap Example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tom's Hardware...on a Raspberry Pi Pico W</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.min.js" integrity="sha384-ODmDIVzN+pFdexxHEHFBQH3/9/vQ9uori45z4JjnFsRydbmQbmL5t1tQ0culUzyK" crossorigin="anonymous"></script>
<style>
@lesp
lesp / button-test.py
Created June 27, 2022 10:58
BMO Playback
from gpiozero import Button #Much easier way to interact with the GPIO
from omxplayer.player import OMXPlayer
from pathlib import Path
from time import sleep
from signal import pause
button = Button(17) #Physical pin 11
def video_test():
VIDEO_PATH = Path("BMO_DontSayThings.mp4")
@lesp
lesp / allie-vlc.py
Created June 26, 2022 18:50
Plays a local video file at 50% volume
import vlc
import time
# creating vlc media player object
media_player = vlc.MediaPlayer()
# The video that we wish to play
media = vlc.Media("PiCast.mp4")
# Loading up the video ready for playback
media_player.set_media(media)
@lesp
lesp / capture.sh
Created May 20, 2022 10:14
Simon says...take a screenshot every minute and use the timestamp as the filename
#!/bin/bash
current_time=$(date "+%Y.%m.%d-%H.%M.%S")
echo "Current Time : $current_time"
scrot -d 60 "${current_time}.png"
@lesp
lesp / temp-check.py
Created March 21, 2022 10:20
Using a BME688 Temperature sensor with Pimoroni's Badger 2040. Code is based on the BME688 example, but with added Badger 2040 code.
"""BME688 / BME680 demo
This demo will work for both the BME680 and BME688.
"""
import time
from breakout_bme68x import BreakoutBME68X, STATUS_HEATER_STABLE
from pimoroni_i2c import PimoroniI2C
import badger2040
import machine
badger = badger2040.Badger2040()
@lesp
lesp / secrets.py
Created March 20, 2021 17:13
Secrets.py
# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it
secrets = {
'ssid' : 'YOUR SSID',
'password' : 'YOUR PASSWORD',
'timezone' : 'YOUR LOCATION', # http://worldtimeapi.org/timezones
}
@lesp
lesp / code.py
Created March 20, 2021 17:12
Wifi on a Raspberry Pi Pico
import board
import busio
from digitalio import DigitalInOut
import adafruit_requests as requests
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
from adafruit_esp32spi import adafruit_esp32spi
from secrets import secrets
print("Raspberry Pi Pico WiFi Weather Station")
JSON_URL = "http://api.openweathermap.org/data/2.5/weather?q=LOCATION&appid=API KEY&units=metric"
@lesp
lesp / Battery-RGB.py
Created September 13, 2020 09:55
When your battery level gets to a set point, press a key to trigger Terence's RGB keyboard
#! /usr/bin/env python3
from pynput.keyboard import Key, Controller
from time import sleep
keyboard = Controller()
while True:
charge_state = int(open("/sys/class/power_supply/BAT0/capacity","r").readline().strip())
if charge_state < 80:
keyboard.press("@")
keyboard.release("@")
@lesp
lesp / calibration.py
Created January 18, 2020 16:32
This is the code which is not working as expected, the Y value is wildly wrong.
import smbus
import time
bus = smbus.SMBus(1)
address = 0x48
print("Please ensure that the joystick is centred, the test will start in...")
for i in range(3,0,-1):
print(i)
time.sleep(1)
print("The resting value for each axis is as follows...")