Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Shaw wyojustin

View GitHub Profile
@wyojustin
wyojustin / webcam_aruco_capture.py
Created Jul 28, 2022
capture aruco codes from webcam using opencv2
View webcam_aruco_capture.py
import cv2
import cv2.aruco as aruco
markerSize = 4
totalMarkers=100
key = getattr(aruco, f'DICT_{markerSize}X{markerSize}_{totalMarkers}')
arucoDict = aruco.Dictionary_get(key)
def findArucoMarkers(img, draw=True):
@wyojustin
wyojustin / dither.py
Created Oct 11, 2020
Convert an image to a mono-bit dithered image.
View dither.py
from PIL import ImageOps
from PIL import Image
import numpy as np
import pylab as pl
import sys
usage = '''USAGE:
python dither.py <input_image_fn> [dim]
'''
if len(sys.argv) < 2:
View LightEasel.ino
#include "FastLED.h"
FASTLED_USING_NAMESPACE
// FastLED "100-lines-of-code" demo reel, showing just a few
// of the kinds of animation patterns you can quickly and easily
// compose using FastLED.
//
// This example also shows one easy way to define multiple
// animations patterns and have them automatically rotate.
View GravitationalAcceleration
from pylab import *
from numpy import *
Me = 5.98E+24 # KG
G = 6.67E-11 # KG^2/(MS^2)
Re = 6378137 # M
Rp = 6356752 # M
DEG = pi/180
lat = arange(-90, 91, 1) * DEG
@wyojustin
wyojustin / COVID19 Timeseries Plot
Last active Mar 8, 2020
Plot animation of spread of COVID 19
View COVID19 Timeseries Plot
'''
Download data from github: https://github.com/CSSEGISandData/COVID-19
Place this file in
COVID-19/csse_covid_19_data/csse_covid_19_time_series/plotme.py
REQUIRES:
matplotlib
numpy
pillow
@wyojustin
wyojustin / NavKey.py
Created Oct 26, 2019
NavKey Test Code
View NavKey.py
import time
import smbus2
I2C = smbus2.SMBus(1)
NAVKEY_ADDR = 0x10
FLOAT_DATA = 0x01
INT_DATA = 0x00
WRAP_ENABLE = 0x02
WRAP_DISABLE = 0x00
@wyojustin
wyojustin / NavKey.py
Created Sep 7, 2019
Widget that implements NavKey
View NavKey.py
"""
Send serial messages based on button presses and thum wheel movement
See: https://github.com/Fattoresaimon/I2CNavKey
""'
from tkinter import *
from numpy import *
import serial
s = serial.Serial('/dev/ttyUSB0', baudrate=115200, timeout=.1)
@wyojustin
wyojustin / LongPress.py
Last active Feb 28, 2019
Tkinter Long Press Detector (Credit: [laurentalacoque](/laurentalacoque))
View LongPress.py
#### USAGE! Attach to self.image (not self.root) that way button clicks do not count as long presses.
#### otherwise the button call backs hang long enough to trigger the long press
## self.longpress_obj = LongPressDetector(self.image, long_press_cb)
class LongPressDetector:
"""Helper class that calls a callback after a long press/click"""
# call_back will get the long_click duration as parameter
def __init__(self, root, call_back, long_press_duration = 1000 ):
"""Creates the LongPressDetector
@wyojustin
wyojustin / gphoto_upload.py
Created Feb 24, 2019
Google Photo Upload
View gphoto_upload.py
### downloaded from web. Contact me if you developed this and would like attribution. wyojustin
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import AuthorizedSession
from google.oauth2.credentials import Credentials
import json
import os.path
import argparse
import logging
def parse_args(arg_input=None):
@wyojustin
wyojustin / ClockIOT.ino
Last active Oct 28, 2018
ClockIOT for esp8266
View ClockIOT.ino
#include <Time.h>
#include <Wire.h>
#include <WiFiManager.h>
#include <FastLED.h>
#include <PubSubClient.h>
#include <EEPROM.h>
#include <EEPROMAnything.h>
#include <NTPClient.h>
#include <WebSocketsServer.h>