Skip to content

Instantly share code, notes, and snippets.

View mattgaidica's full-sized avatar
💭
Spending most my time at https://github.com/Neurotech-Hub

Matt Gaidica, Ph.D. mattgaidica

💭
Spending most my time at https://github.com/Neurotech-Hub
View GitHub Profile
const ulp_insn_t ulp_program[] = {
// Label to loop back to
M_LABEL(1),
// Read GPIO18 state (bit 28) via RTC_GPIO_IN_REG
I_RD_REG(RTC_GPIO_IN_REG, RTC_GPIO_INDEX + RTC_GPIO_IN_NEXT_S, RTC_GPIO_INDEX + RTC_GPIO_IN_NEXT_S),
// Check if GPIO18 is low (R0 < 1). If low, wake up the CPU.
M_BL(2, 1), // If R0 < 1 (i.e., if GPIO18 is low, branch to wakeup)
const ulp_insn_t ulp_program[] = {
// Initialize transition counter (R3 <- 0)
I_MOVI(R3, 0), // Set R3 to 0 (counter)
I_MOVI(R2, 1), // Set R2 to address RTC_SLOW_MEM[1]
// Increment 1
I_ADDI(R3, R3, 1), // Increment R3 by 1
I_ST(R3, R2, 0), // Store R3 in RTC_SLOW_MEM[1]
// Increment 2
#define GPIO_SENSOR_PIN GPIO_NUM_18 // GPIO pin connected to the sensor
#define RTC_GPIO_INDEX 18 // Serial.println(rtc_io_number_get(GPIO_SENSOR_PIN));
#define LED_PIN GPIO_NUM_13
#define LED_GPIO_INDEX 13
const ulp_insn_t ulp_program[] = {
// Main loop
M_LABEL(1),
// Example to enter deep sleep after 10 seconds and wake up with a GPIO pin
void setup() {
// Initialize Serial for debugging
Serial.begin(115200);
delay(1000); // Wait for the serial to initialize
// Set GPIO pin for wakeup
esp_sleep_enable_ext0_wakeup(GPIO_NUM_0, 0); // Wake on low signal on GPIO 0
// Start deep sleep
@mattgaidica
mattgaidica / InnovationHyptheses.m
Created May 29, 2024 11:27
Two models of innovation vs. funding.
% Parameters
num_points = 100;
noise_level = 0.25; % Adjust this value to control the amount of noise
% Generate x values
x_curve = linspace(0, 1, 1000); % Generate 1000 points between 0 and 1
y_curve = log(1 + 99 * x_curve) / log(100); % Compute y values for the curve
% Select 12 random points along the curve
indices = randperm(length(x_curve), num_points);
% Neodymium magnet parameters
radius_mm = 10; % Magnet radius in millimeters
thickness_mm = 3; % Magnet thickness in millimeters
M = 1.0; % Magnetization in A m (adjust this value)
% Conversion factor from Gauss to voltage change
gauss_to_voltage = 1.5 / 1000;
% Permeability of free space
mu0 = 4 * pi * 1e-7;
@mattgaidica
mattgaidica / index_snip.html
Last active May 26, 2023 20:36
Rotating text snippet
<div class="is-content-justification-center" style="text-align:center">
<p>Did you know? <span id="rotatingText"><a target="_blank" href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0094215">Your brain slow down at 24, but peaks for some cognitive skills at other ages</a>.</span></p>
</div>
<script>
var textArray = [
'<a target="_blank" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2754571/">The human brain is the fattest organ in the body, consisting of at least 60% fat</a>.',
'<a target="_blank" href="https://pubmed.ncbi.nlm.nih.gov/20329590/">Your brain can generate about 20 watts of electrical power</a>.',
'<a target="_blank" href="https://www.frontiersin.org/articles/10.3389/fnmol.2018.00216/full">Your brain uses about 20% of your bodys total energy and oxygen intake</a>.',
'<a target="_blank" href="https://www.brainline.org/author/brian-greenwald/qa/can-brain-itself-feel-pain">Your brain is incapable of feeling pain</a>.',
% Hargens et al. (1985) Figure 2 Recreation
xs = 30:10:70;
fitxs = 0:100;
% backed out from plot
loadCenter = [49,40,33,20,10];
loadErrorUpper = [50.5,42.5,38,25,12.5];
tensionCenter = [50,57,66,78,85];
tensionErrorUpper = [55,59,70,83,88];
// CMSIS Math
#include "arm_math.h"
#include "arm_const_structs.h"
#define SIG_SAMPLES 1024
#define BLOCK_SIZE 32;
#include "SWAsignal.h"
static float32_t filtSignal[SIG_SAMPLES];
// FILTER
extern float32_t inputSignal[SIG_SAMPLES] = { 2.09186630161801,
2.17981806111224, 2.2458345331045, 2.20702098281261, 2.05451765784143,
1.85916546584311, 1.7767591356537, 1.79267779175089, 1.85004295412198,
1.82818508686074, 1.72760166685638, 1.54716102329878, 1.39328525785108,
1.37279362871747, 1.37225304331087, 1.31022305067551, 1.21566162283513,
1.24287644762541, 1.38510735478485, 1.60578710124569, 1.93459280511249,
2.26110788479076, 2.43559114351632, 2.44546630752519, 2.37477587905096,
2.14026122136909, 1.77405580991932, 1.36350765781611, 0.998258176086951,
0.77357268824843, 0.567933484496516, 0.384275954063506,
0.288059029461084, 0.311287985207322, 0.323805443624895,