Skip to content

Instantly share code, notes, and snippets.

View futureshocked's full-sized avatar

Peter Dalmaris futureshocked

View GitHub Profile
@futureshocked
futureshocked / gist:8d6b34e7e0abd0e121c5ff10a74cf483
Created August 20, 2024 21:24
convert the 4-bit code in the dip_switch array into an integer
byte encodebool(boolean* arr)
{
byte val = 0;
for (int i = 0; i<4; i++)
{
val <<= 1;
if (arr[i]) val |= 1;
}
return val;
}
boolean dip_switch[4];
dip_switch[0] = digitalRead(3);
dip_switch[1] = digitalRead(4);
dip_switch[2] = digitalRead(5);
dip_switch[3] = digitalRead(6);
@futureshocked
futureshocked / compass_animation.py
Last active June 2, 2024 02:47
This program plots heading, speed and altitude and creates an animated gif.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import sys
import os
# This is version 4 of the program
def create_compass_animation(file_path):
@futureshocked
futureshocked / Convert_CVS_toGPX-adjust_alt_to_YSCN_v2
Created June 1, 2024 03:15
This script will produce GPX and KML files from the flight data recorder CSV file. These output files can be used in Google Earth Pro, or other programs like Relive.
import csv
import os
import sys
from xml.etree.ElementTree import Element, SubElement, tostring
from xml.dom.minidom import parseString
from datetime import datetime
# Constants
GROUND_LEVEL_ALTITUDE_YSCN = 70 # Ground level altitude at Camden YSCN in meters
time (ms),datetime,speed (kn),lat (deg),lon (deg),alt (m),angle (deg),satellites,antenna,fix_quality,fix_quality3d,locus_speed,pressure (kpa),temperature (°C),humidity (%)
133,2024-05-29T03:06:55.023Z,2.36,-34.0417594910,150.6887817383,56.700,121.250,6,0,1,0,0,101.993,18.63,68.56
134,2024-05-29T03:06:56.023Z,2.66,-34.0417671204,150.6887817383,56.900,114.200,6,0,1,0,0,101.991,19.01,68.49
135,2024-05-29T03:06:57.023Z,1.62,-34.0417785645,150.6887817383,56.200,139.110,6,0,1,0,0,101.993,19.01,68.62
136,2024-05-29T03:06:58.023Z,1.16,-34.0417861938,150.6887664795,56.200,170.020,6,0,1,0,0,101.993,19.01,68.46
137,2024-05-29T03:06:59.023Z,1.35,-34.0417938232,150.6887664795,55.600,163.370,6,0,1,0,0,101.990,19.05,68.48
138,2024-05-29T03:07:00.023Z,2.04,-34.0418014526,150.6887664795,55.900,115.460,6,0,1,0,0,101.992,19.09,68.52
139,2024-05-29T03:07:01.023Z,1.71,-34.0418090820,150.6887664795,56.200,111.680,6,0,1,0,0,101.994,19.09,68.57
140,2024-05-29T03:07:02.023Z,1.03,-34.0418128967,150.6887664795,56.700,104.110,6,0,1,0,0,
@futureshocked
futureshocked / detect_circuits_patterns_v1.py
Created June 1, 2024 02:48
This program will detect these events during circuits at YSCN: take-off, landing, touch-and-go
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import sys
def analyze_flight_data(file_path):
# Load the GPS data
gps_data = pd.read_csv(file_path)
gps_data['datetime'] = pd.to_datetime(gps_data['datetime'])
@futureshocked
futureshocked / flight_controller.ino
Created March 7, 2022 01:18
This script implements a flight controller joystick for my X-Flight simulator. Works with an Arduino Micro or A-Star 32U4 Mini
// Requires Arduino Joystick Library https://github.com/MHeironimus/ArduinoJoystickLibrary
#include <Joystick.h>
const int8_t sw_1 = 18;
const int8_t sw_2 = 4;
const int8_t sw_3 = 6;
//Joystick_ Joystick;
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_JOYSTICK, 4, 0,
@futureshocked
futureshocked / Arduino_ticker.ino
Created September 7, 2021 08:10
Test Peter's four 8x8 LED matrix with Arduino PRo Mini PCB
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 4;
int numberOfVerticalDisplays = 1;
byte button_1 = 5;
byte button_2 = 4;
@futureshocked
futureshocked / LJ - 07.30 - sine_wave_DAC0.lua
Created April 26, 2021 04:45
This script creates a rudimentary sine wave on DAC0.
--[[
LJ - 07.30 - sine_wave_DAC0.lua
This script creates a rudimentary sine wave on DAC0.
Components
----------
- LabJack T4
- Oscilloscope
@futureshocked
futureshocked / LJ - 09.50 - blink_LED_FIO5.lua
Created April 26, 2021 02:27
This script shows how to control an LED with FIO5 with a Lua script.