This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Accelerometer Demo</title> | |
<style> | |
.indicatorDot{ | |
width: 30px; | |
height: 30px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LED_pin 9 | |
// Track LED state | |
bool LED_state = false; | |
// Set frequency of LED | |
float blinkrate = 1; // In Hz | |
float delay_between_switch = 500.0/blinkrate; // Blink at N Hz means you switch every 1s/(N/2) | |
// Track blinking cycle times of LED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PPG Demo by Andy Kong | |
// FFT function in Javascript | |
// - Make sure to include the fft.js in a <script> tag in the HTML header. | |
// - We initialize the FFT object in Javascript using this command in the main | |
// fft = new window.kiss.FFTR(maxHistLen); | |
async function calcFFT(data){ | |
// Remove offset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Andy Kong 11/13/22 | |
// Code to control the Olympia Infoglobe message and transitions | |
// USAGE: | |
// Type a message > 2 chars into Serial and this script will try to write it out into the Infoglobe's IR LED attached to Pin D2 | |
// To send a String X to the Infoglobe, call infoAddMsg(X); | |
// Hardware setup can be found here: | |
// https://andykong.org/blog/infoglobetutorial1/ | |
// https://andykong.org/blog/infoglobetutorial2/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var px = 50; // Position x and y | |
var py = 50; | |
var vx = 0.0; // Velocity x and y | |
var vy = 0.0; | |
var updateRate = 1/60; // Sensor refresh rate | |
function getAccel(){ | |
DeviceMotionEvent.requestPermission().then(response => { | |
if (response == 'granted') { | |
// Add a listener to get smartphone orientation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SerialLogger { | |
public String portname; | |
public String filename; | |
public Process p; | |
SerialLogger(String portname, String filename) { | |
this.portname = portname; | |
this.filename = sketchPath() + "/data/" + filename + ".csv"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.highlight-popup { | |
position: absolute; | |
background-color: #0044b3; | |
color: white; | |
padding: 4px; | |
border-radius: 4px; | |
z-index: 9999; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import backtrader as bt | |
import pandas as pd | |
import time | |
############### Preprocess data | |
filename = "../data/BTC-USD_15min_2017-4-5.csv" | |
df = pd.read_csv(filename, header=0, parse_dates=['time'], index_col='time') | |
############### Create backtrader data feed, set up strategy and broker | |
# Create Cerebro backtesting instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import os | |
import re | |
# We are loading in a data export from Fitbit. | |
allExports = "raw/" | |
curExport = [allExports+x for x in os.listdir(allExports) if os.path.isdir(allExports+x)][0] | |
curExport = curExport + "/" + [x for x in os.listdir(curExport) if os.path.isdir(curExport+"/"+x)][0] | |
print(f"Data export we're converting is \n\t{curExport}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file uses the sleep stress file's timestamp to convert each sleep row to its proper timezone | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import copy | |
stressFile = "cooked/Stress_Stress Score.csv" | |
sleepFile = "cooked/Sleep_sleep.csv" | |
# Each line in sleep has a few time-associated cols: (dateOfSleep, startTime, endTime) | |
# These are given in the timezone of the user's device and not in UTC |
OlderNewer