Skip to content

Instantly share code, notes, and snippets.

View joeycastillo's full-sized avatar

Joey Castillo joeycastillo

View GitHub Profile
@joeycastillo
joeycastillo / gatsby.txt
Created June 15, 2022 16:24
The Great Gatsby, plain text with ASCII control characters
---
TITL: The Great Gatsby
AUTH: F. Scott Fitzgerald
DESC: The decadent and mysterious Jay Gatsby pursues the American Dream in Jazz Age New York.
GNRE: Traffic accidents--Fiction
LANG: en
---
Dedication
Once again
to
@joeycastillo
joeycastillo / convert.py
Created June 15, 2022 16:16
Convert Standard Ebooks EPUBs to plain text with front matter
import io
import sys
from epub2txt import epub2txt
# Designed for use with Standard Ebooks EPUB files.
# May work with others, but their structure is excellent.
try:
filepath = sys.argv[1]
except:
print('usage: python3 convert.py book_to_convert.epub')
@joeycastillo
joeycastillo / code.py
Created May 22, 2022 19:43
LCD clock with ambient conditions on ESP32-S2 Feather
import board
import rtc
import time
import alarm
from adafruit_bme280 import basic as adafruit_bme280
from adafruit_lc709203f import LC709203F, PackSize
from oso_lcd.lcdwing_lite import LCDWingLite, Indicator
display = LCDWingLite(board.I2C())
display.clear_indicator(Indicator.MOON)
@joeycastillo
joeycastillo / segments.py
Created March 25, 2022 18:17
Ancient script to generate Sensor Watch segment map
rev_01_map = [[(1, 18), (2, 19), (0, 19), (1, 18), (0, 18), (2, 18), (1, 19), None],
[(2, 20), (2, 21), (1, 21), (0, 21), (0, 20), (1, 17), (1, 20), None],
[(0, 22), (2, 23), (0, 23), (0, 22), (1, 22), (2, 22), (1, 23), None],
[(2, 1), (2, 10), (0, 1), (0, 0), (1, 0), (2, 0), (1, 1), None],
[(2, 2), (2, 3), (0, 4), (0, 3), (0, 2), (1, 2), (1, 3), None],
[(2, 4), (2, 5), (1, 6), (0, 6), (0, 5), (1, 4), (1, 5), None],
[(1, 9), (0, 9), (2, 9), (1, 9), (0, 10), None , (1, 9), None],
[(0, 7), (1, 7), (2, 7), (2, 6), (2, 8), (0, 8), (1, 8), None],
[(0, 13), (1, 13), (2, 13), (2, 15), (2, 14), (0, 14), (1, 15), (1, 14)],
[(0, 11), (1, 11), (1, 11), (2, 11), (1, 12), (1, 12), (2, 12), (0, 12)],
@joeycastillo
joeycastillo / code.py
Created March 22, 2022 01:47
PyPen Calculator
import time
import board
import displayio
import framebufferio
import sharpdisplay
from digitalio import DigitalInOut, Direction, Pull
from adafruit_debouncer import Debouncer
extcomin = DigitalInOut(board.DISPLAY_EXTCOMIN)
extcomin.direction = Direction.OUTPUT
@joeycastillo
joeycastillo / ringthing.scad
Created February 7, 2022 02:20
An OpenSCAD script to generate a ring for wearing
// Adapted from a script by @Oskar_mbr: https://twitter.com/Oskar_mbr/status/1490429921893756928
ring_height = 12;
ring_height_taper = 5;
ring_inner_diameter = 18;
ring_thickness = 1;
cavity_diameter = 10;
cavity_depth = 6;
cavity_width = 1;
cavity_extension = 1.5;
@joeycastillo
joeycastillo / bt.py
Created January 17, 2022 16:45
ancient Pythonista script to interface with a bluetooth thermal printer
import cb
class PrinterManager(object):
def __init__(self):
self.peripheral = None
self.finished = False
def did_discover_peripheral(self, p):
print(p.name, p.uuid)
if p.name and 'BlueTooth Printer' in p.name and not self.peripheral:
@joeycastillo
joeycastillo / code.py
Last active January 31, 2021 17:31
PyCorder LCARS environment display
import board
import busio
import displayio
import framebufferio
import sharpdisplay
displayio.release_displays()
bus = busio.SPI(board.DISPLAY_CLOCK, MOSI=board.DISPLAY_DATA)
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, board.DISPLAY_CS, 400, 240)
display = framebufferio.FramebufferDisplay(framebuffer, auto_refresh = True, rotation=270)
display.show(None)
@joeycastillo
joeycastillo / code.py
Created January 20, 2021 02:04
LiPo profiling script for the Pycorder, using an LC709023F LiPo fuel gauge, INA219 current sensor and DS3231 RTC
import board
import busio
import displayio
import framebufferio
import sharpdisplay
displayio.release_displays()
bus = busio.SPI(board.DISPLAY_CLOCK, MOSI=board.DISPLAY_DATA)
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, board.DISPLAY_CS, 400, 240)
display = framebufferio.FramebufferDisplay(framebuffer, auto_refresh = True, rotation=270)
display.show(None)
@joeycastillo
joeycastillo / code.py
Created January 18, 2021 05:39
Display upcoming SpaceX launches on a Sharp Memory Display
import board
import busio
import displayio
import framebufferio
import sharpdisplay
displayio.release_displays()
bus = busio.SPI(board.DISPLAY_CLOCK, MOSI=board.DISPLAY_DATA)
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, board.DISPLAY_CS, 400, 240)
display = framebufferio.FramebufferDisplay(framebuffer, auto_refresh = True, rotation=270)
display.show(None)