1
0

boilerplate

This commit is contained in:
dtb 2023-08-01 20:41:32 -04:00
parent 3d5eddc0d9
commit 7cdd6cefe5
2 changed files with 110 additions and 0 deletions

41
tekubi/Makefile Normal file
View File

@ -0,0 +1,41 @@
i2cdevlib_url = https://github.com/jrowberg/i2cdevlib.git
setup: I2Cdev.cpp I2Cdev.h MPU6050.cpp MPU6050.h
clean_setup:
rm -rf i2cdevlib i2cdevlib_tmp
rm -f I2Cdev.cpp I2Cdev.h
rm -f MPU6050.cpp MPU6050.h
i2cdevlib:
rm -rf i2cdevlib_tmp
git init i2cdevlib_tmp
git -C i2cdevlib_tmp remote add -f origin $(i2cdevlib_url)
git -C i2cdevlib_tmp config core.sparseCheckout true
git -C i2cdevlib_tmp sparse-checkout set
git -C i2cdevlib_tmp checkout master
mv i2cdevlib_tmp i2cdevlib
i2cdevlib/Arduino/I2Cdev: i2cdevlib
git -C i2cdevlib sparse-checkout add Arduino/I2Cdev
git -C i2cdevlib sparse-checkout reapply
git fetch
i2cdevlib/Arduino/MPU6050: i2cdevlib
git -C i2cdevlib sparse-checkout add Arduino/MPU6050
git -C i2cdevlib sparse-checkout reapply
git fetch
I2Cdev.cpp: i2cdevlib/Arduino/I2Cdev
cp i2cdevlib/Arduino/I2Cdev/I2Cdev.cpp ./
I2Cdev.h: i2cdevlib/Arduino/I2Cdev
cp i2cdevlib/Arduino/I2Cdev/I2Cdev.h ./
MPU6050.cpp: i2cdevlib/Arduino/MPU6050
cp i2cdevlib/Arduino/MPU6050/MPU6050.cpp ./
MPU6050.h: i2cdevlib/Arduino/MPU6050
cp i2cdevlib/Arduino/MPU6050/MPU6050.h ./
.PHONY: setup clean_setup

69
tekubi/main.ino Normal file
View File

@ -0,0 +1,69 @@
#include <SPI.h>
#include <Wire.h>
/* https://github.com/jrowberg/i2cdevlib/ */
#include "I2Cdev.h"
#include "MPU6050.h"
#define RAD_LOG_PERIOD 5000 /* milliseconds; sample rate */
#define MINUTE 60000 /* milliseconds in a minute */
/* USB power
* 5V -> Teensy Vin (100mA)
* GND -> Teensy GND
* 5V -> Geiger 5V (100mA?)
* GND -> Geiger GND
* 5V -> Gyro Vcc (10mA)
* GND -> Gyro GND
* 5V -> ECG Vcc (4mA)
* GND -> ECG GND */
/* teensy 4.0
* https://www.pjrc.com/store/teensy40.html */
/* geiger counter
* https://www.rhelectronics.store
* /radiation-detector-geiger-counter-diy-kit-second-edition
* INT -> Teensy D3 */
/* gyro
* https://www.elecrow.com/crowtail-mpu6050-accelerometer-gyro.html
* SDA -> Teensy SDA0
* SCL -> Teensy SCL0 */
/* ecg
* https://www.elecrow.com/crowtail-pulse-sensor-p-1673.html
* SDA -> Teensy SDA0
* SCL -> Teensy SCL0 */
unsigned long rad_count = 0;
unsigned long rad_cpm;
/* https://www.pjrc.com/teensy/td_timing_elaspedMillis.html */
elapsedMillis rad_period = 0;
void rad_interrupt(){
++rad_count;
}
void setup(){
/* geiger counter */{
pinMode(3, INPUT);
digitalWrite(3, HIGH);
attachInterrupt(0, rad_interrupt, FALLING);
}
}
void loop(){
/* geiger counter */{
if(rad_period > RAD_LOG_PERIOD){
rad_cpm = rad_count * (MINUTE / RAD_LOG_PERIOD);
rad_period = 0;
}
}
}