Skip to content

Instantly share code, notes, and snippets.

View wyojustin's full-sized avatar

Justin Shaw wyojustin

View GitHub Profile
@wyojustin
wyojustin / webcam_aruco_capture.py
Created July 28, 2022 20:24
capture aruco codes from webcam using opencv2
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 October 11, 2020 16:37
Convert an image to a mono-bit dithered image.
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:
#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.
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 March 8, 2020 15:11
Plot animation of spread of COVID 19
'''
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 October 26, 2019 21:00
NavKey Test Code
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 September 7, 2019 18:48
Widget that implements NavKey
"""
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 February 28, 2019 00:03
Tkinter Long Press Detector (Credit: [laurentalacoque](/laurentalacoque))
#### 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 February 24, 2019 12:44
Google Photo Upload
### 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 October 28, 2018 12:07
ClockIOT for esp8266
#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>