Commit 4ac9443a authored by Zach Fredin's avatar Zach Fredin

reorg

parent 9d6cf7ce
# Image Statistics Info Example
#
# This script computes the statistics of the image and prints it out.
import sensor, image, time, ustruct
from pyb import UART
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE) # or RGB565.
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must be turned off for color tracking
sensor.set_auto_whitebal(False) # must be turned off for color tracking
clock = time.clock()
uart = UART(3, 19200)
seg_thresh = 60
SpO2 = 0;
# ---A1--- ---A2---
# | | | |
# F1 B1 F2 B2
# | | | |
# ---G1--- ---G2---
# | | | |
# E1 C1 E2 C2
# | | | |
# ---D1--- ---D2---
while(True):
clock.tick()
SpO2 = 0;
img = sensor.snapshot()
# segment 1 (left)
if(img.get_statistics(roi=(43,50,8,20)).mean() > seg_thresh): #F1
if(img.get_statistics(roi=(45,131,6,17)).mean() > seg_thresh): #E1
if(img.get_statistics(roi=(77,96,18,7)).mean() > seg_thresh): #G1
if(img.get_statistics(roi=(117,50,9,17)).mean() > seg_thresh): #B1
SpO2 += 80
else:
SpO2 += 60
else:
SpO2 += 0
elif(img.get_statistics(roi=(79,174,15,8)).mean() > seg_thresh): #D1
if(img.get_statistics(roi=(117,50,9,17)).mean() > seg_thresh): #B1
SpO2 += 90
else:
SpO2 += 50
else:
SpO2 += 40
elif(img.get_statistics(roi=(77,96,18,7)).mean() > seg_thresh): #G1
if(img.get_statistics(roi=(70,16,22,10)).mean() > seg_thresh): #A1
if(img.get_statistics(roi=(45,131,6,17)).mean() > seg_thresh): #E1
SpO2 += 20
else:
SpO2 += 30
else:
SpO2 = 0
elif(img.get_statistics(roi=(70,16,22,10)).mean() > seg_thresh): #A1
SpO2 += 70
elif(img.get_statistics(roi=(117,50,9,17)).mean() > seg_thresh): #B1
SpO2 += 10
else:
SpO2 += 0
# segment 2 (right)
if(img.get_statistics(roi=(154,47,10,22)).mean() > seg_thresh): #F1
if(img.get_statistics(roi=(156,133,10,19)).mean() > seg_thresh): #E1
if(img.get_statistics(roi=(188,94,18,8)).mean() > seg_thresh): #G1
if(img.get_statistics(roi=(234,43,8,22)).mean() > seg_thresh): #B1
SpO2 += 8
else:
SpO2 += 6
else:
SpO2 += 0
elif(img.get_statistics(roi=(188,176,21,8)).mean() > seg_thresh): #D1
if(img.get_statistics(roi=(234,43,8,22)).mean() > seg_thresh): #B1
SpO2 += 9
else:
SpO2 += 5
else:
SpO2 += 4
elif(img.get_statistics(roi=(188,94,18,8)).mean() > seg_thresh): #G1
if(img.get_statistics(roi=(183,13,21,8)).mean() > seg_thresh): #A1
if(img.get_statistics(roi=(156,133,10,19)).mean() > seg_thresh): #E1
SpO2 += 2
else:
SpO2 += 3
else:
SpO2 = 0
elif(img.get_statistics(roi=(183,13,21,8)).mean() > seg_thresh): #A1
SpO2 += 7
elif(img.get_statistics(roi=(234,43,8,22)).mean() > seg_thresh): #B1
SpO2 += 1
else:
SpO2 += 0
uart.write(ustruct.pack("<b", SpO2))
print(SpO2)
# print(clock.fps())
# You can also pass get_statistics() an "roi=" to get just the statistics of that area.
# get_statistics() allows you to quickly determine the color channel information of
# any any area in the image.
#include <IntervalTimer.h>
#include <SD.h>
#include <SPI.h>
#define LED_red 0
#define LED_IR 1
int SpO2_OpenMV = 0;
int SpO2_Raw_Zacurate = 0;
int SpO2_Raw_Fab = 0;
int Arr_SpO2_OpenMV[25000];
int Arr_SpO2_Raw_Zacurate[25000];
int Arr_SpO2_Raw_Fab[25000];
int Arr_micros[25000];
int counter = 0;
int led_counter = 0;
IntervalTimer sampleTimer;
IntervalTimer ledTimer;
void writelog() {
Arr_SpO2_OpenMV[counter] = SpO2_OpenMV;
Arr_SpO2_Raw_Zacurate[counter] = SpO2_Raw_Zacurate;
Arr_SpO2_Raw_Fab[counter] = SpO2_Raw_Fab;
Arr_micros[counter] = micros();
counter++;
}
void updateLEDs() {
if (led_counter < 6) {
digitalWrite(0, HIGH);
}
else if (led_counter < 12) {
digitalWrite(0, LOW);
}
else if (led_counter < 18) {
digitalWrite(1, HIGH);
}
else {
digitalWrite(1, LOW);
}
led_counter++;
if (led_counter > 72) {
led_counter = 0;
}
}
void setup() {
Serial.begin(115200); //USB serial port
Serial5.begin(19200); //OpenMV UART
analogReadResolution(16);
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(13, OUTPUT);
SD.begin(BUILTIN_SDCARD);
delay(5000); //mostly to let the OpenMV board boot up
sampleTimer.begin(writelog, 200); // 200 us period
ledTimer.begin(updateLEDs, 100); // 100 us period
}
void loop() {
int i;
digitalWrite(13, HIGH);
if (Serial5.available() > 0) {
SpO2_OpenMV = Serial5.read();
}
SpO2_Raw_Zacurate = analogRead(4);
SpO2_Raw_Fab = analogRead(9);
if (counter == 25000) {
noInterrupts();
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if (dataFile) {
for (i = 0; i < 25000; i++) {
dataFile.print(Arr_micros[i]);
dataFile.print(",");
dataFile.print(Arr_SpO2_OpenMV[i]);
dataFile.print(",");
dataFile.print(Arr_SpO2_Raw_Zacurate[i]);
dataFile.print(",");
dataFile.println(Arr_SpO2_Raw_Fab[i]);
}
dataFile.close();
}
counter = 0;
interrupts();
}
}
This diff is collapsed.
This diff is collapsed.
(fp_lib_table
(lib (name v1_teensy)(type KiCad)(uri ${KIPRJMOD}/v1_teensy.pretty)(options "")(descr ""))
)
(sym_lib_table
(lib (name v1_teensy)(type Legacy)(uri ${KIPRJMOD}/v1_teensy.lib)(options "")(descr ""))
)
This diff is collapsed.
EESchema-LIBRARY Version 2.4
#encoding utf-8
#
# Amplifier_Operational_AD8603
#
DEF Amplifier_Operational_AD8603 U 0 5 Y Y 1 F N
F0 "U" 0 200 50 H V L CNN
F1 "Amplifier_Operational_AD8603" 0 -200 50 H V L CNN
F2 "Package_TO_SOT_SMD:TSOT-23-5" 0 0 50 H I C CNN
F3 "" 0 200 50 H I C CNN
ALIAS OPA188xxDBV
$FPLIST
TSOT*23*
$ENDFPLIST
DRAW
P 4 0 1 10 -200 200 200 0 -200 -200 -200 200 f
X V- 2 -100 -300 150 U 50 50 0 1 W
X V+ 5 -100 300 150 D 50 50 0 1 W
X ~ 1 300 0 100 L 50 50 1 1 O
X + 3 -300 100 100 R 50 50 1 1 I
X - 4 -300 -100 100 R 50 50 1 1 I
ENDDRAW
ENDDEF
#
# Connector_Generic_Conn_01x06
#
DEF Connector_Generic_Conn_01x06 J 0 40 Y N 1 F N
F0 "J" 0 300 50 H V C CNN
F1 "Connector_Generic_Conn_01x06" 0 -400 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_1x??_*
$ENDFPLIST
DRAW
S -50 -295 0 -305 1 1 6 N
S -50 -195 0 -205 1 1 6 N
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 105 0 95 1 1 6 N
S -50 205 0 195 1 1 6 N
S -50 250 50 -350 1 1 10 f
X Pin_1 1 -200 200 150 R 50 50 1 1 P
X Pin_2 2 -200 100 150 R 50 50 1 1 P
X Pin_3 3 -200 0 150 R 50 50 1 1 P
X Pin_4 4 -200 -100 150 R 50 50 1 1 P
X Pin_5 5 -200 -200 150 R 50 50 1 1 P
X Pin_6 6 -200 -300 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Device_C
#
DEF Device_C C 0 10 N Y 1 F N
F0 "C" 25 100 50 H V L CNN
F1 "Device_C" 25 -100 50 H V L CNN
F2 "" 38 -150 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
C_*
$ENDFPLIST
DRAW
P 2 0 1 20 -80 -30 80 -30 N
P 2 0 1 20 -80 30 80 30 N
X ~ 1 0 150 110 D 50 50 1 1 P
X ~ 2 0 -150 110 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Device_D_Photo
#
DEF Device_D_Photo D 0 20 N N 1 F N
F0 "D" 20 70 50 H V L CNN
F1 "Device_D_Photo" -40 -110 50 H V C CNN
F2 "" -50 0 50 H I C CNN
F3 "" -50 0 50 H I C CNN
DRAW
P 2 0 1 8 -100 50 -100 -50 N
P 2 0 1 0 -80 70 -60 70 N
P 2 0 1 0 0 0 -100 0 N
P 3 0 1 0 -20 130 -80 70 -80 90 N
P 4 0 1 8 0 -50 0 50 -100 0 0 -50 N
P 5 0 1 0 30 130 -30 70 -30 90 -30 70 -10 70 N
X K 1 -200 0 100 R 50 50 1 1 P
X A 2 100 0 100 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Device_LED
#
DEF Device_LED D 0 40 N N 1 F N
F0 "D" 0 100 50 H V C CNN
F1 "Device_LED" 0 -100 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
LED*
LED_SMD:*
LED_THT:*
$ENDFPLIST
DRAW
P 2 0 1 8 -50 -50 -50 50 N
P 2 0 1 0 -50 0 50 0 N
P 4 0 1 8 50 -50 50 50 -50 0 50 -50 N
P 5 0 1 0 -120 -30 -180 -90 -150 -90 -180 -90 -180 -60 N
P 5 0 1 0 -70 -30 -130 -90 -100 -90 -130 -90 -130 -60 N
X K 1 -150 0 100 R 50 50 1 1 P
X A 2 150 0 100 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Device_R
#
DEF Device_R R 0 0 N Y 1 F N
F0 "R" 80 0 50 V V C CNN
F1 "Device_R" 0 0 50 V V C CNN
F2 "" -70 0 50 V I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
R_*
$ENDFPLIST
DRAW
S -40 -100 40 100 0 1 10 N
X ~ 1 0 150 50 D 50 50 1 1 P
X ~ 2 0 -150 50 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# power_GND
#
DEF power_GND #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -250 50 H I C CNN
F1 "power_GND" 0 -150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
X GND 1 0 0 0 D 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# v1_teensy_teensy_4-0
#
DEF v1_teensy_teensy_4-0 U 0 40 Y Y 1 F N
F0 "U" 0 0 50 H V C CNN
F1 "v1_teensy_teensy_4-0" 0 -350 50 H V C CNN
F2 "" -100 -50 50 H I C CNN
F3 "" -100 -50 50 H I C CNN
DRAW
S -350 300 400 -300 0 1 0 N
X GND 1 -450 200 100 R 50 50 1 1 I
X VIN 10 500 200 100 L 50 50 1 1 I
X ARD_0 2 -450 100 100 R 50 50 1 1 I
X ARD_1 3 -450 0 100 R 50 50 1 1 I
X ARD_2 4 -450 -100 100 R 50 50 1 1 I
X ARD_3 5 -450 -200 100 R 50 50 1 1 I
X ARD_22 6 500 -200 100 L 50 50 1 1 I
X ARD_23 7 500 -100 100 L 50 50 1 1 I
X 3v3 8 500 0 100 L 50 50 1 1 I
X GND 9 500 100 100 L 50 50 1 1 I
ENDDRAW
ENDDEF
#
#End Library
EESchema-DOCLIB Version 2.0
#
#End Doc Library
EESchema-DOCLIB Version 2.0
#
#End Doc Library
This diff is collapsed.
(kicad_pcb (version 20171130) (host pcbnew 5.1.5-52549c5~84~ubuntu18.04.1)
(general
(thickness 1.6)
(drawings 4)
(tracks 0)
(zones 0)
(modules 11)
(nets 22)
)
(page A4)
(layers
(0 F.Cu signal)
(31 B.Cu signal)
(32 B.Adhes user)
(33 F.Adhes user)
(34 B.Paste user)
(35 F.Paste user)
(36 B.SilkS user)
(37 F.SilkS user)
(38 B.Mask user)
(39 F.Mask user)
(40 Dwgs.User user)
(41 Cmts.User user)
(42 Eco1.User user)
(43 Eco2.User user)
(44 Edge.Cuts user)
(45 Margin user)
(46 B.CrtYd user)
(47 F.CrtYd user)
(48 B.Fab user)
(49 F.Fab user)
)
(setup
(last_trace_width 0.5)
(trace_clearance 0.5)
(zone_clearance 0.508)
(zone_45_only no)
(trace_min 0.2)
(via_size 1.2)
(via_drill 0.8)
(via_min_size 0.4)
(via_min_drill 0.3)
(uvia_size 0.3)
(uvia_drill 0.1)
(uvias_allowed no)
(uvia_min_size 0.2)
(uvia_min_drill 0.1)
(edge_width 0.05)
(segment_width 0.2)
(pcb_text_width 0.3)
(pcb_text_size 1.5 1.5)
(mod_edge_width 0.12)
(mod_text_size 1 1)
(mod_text_width 0.15)
(pad_size 1.524 1.524)
(pad_drill 0.762)
(pad_to_mask_clearance 0.051)
(solder_mask_min_width 0.25)
(aux_axis_origin 0 0)
(visible_elements FFFFF77F)
(pcbplotparams
(layerselection 0x010fc_ffffffff)
(usegerberextensions false)
(usegerberattributes false)
(usegerberadvancedattributes false)
(creategerberjobfile false)
(excludeedgelayer true)
(linewidth 0.100000)
(plotframeref false)
(viasonmask false)
(mode 1)
(useauxorigin false)
(hpglpennumber 1)
(hpglpenspeed 20)
(hpglpendiameter 15.000000)
(psnegative false)
(psa4output false)
(plotreference true)
(plotvalue true)
(plotinvisibletext false)
(padsonsilk false)
(subtractmaskfromsilk false)
(outputformat 1)
(mirror false)
(drillshape 1)
(scaleselection 1)
(outputdirectory ""))
)
(net 0 "")
(net 1 "Net-(C1-Pad1)")
(net 2 "Net-(C1-Pad2)")
(net 3 "Net-(D1-Pad2)")
(net 4 "Net-(D1-Pad1)")
(net 5 "Net-(D2-Pad2)")
(net 6 "Net-(D3-Pad2)")
(net 7 "Net-(J1-Pad1)")
(net 8 "Net-(J1-Pad2)")
(net 9 "Net-(J1-Pad3)")
(net 10 "Net-(J1-Pad4)")
(net 11 "Net-(J1-Pad5)")
(net 12 "Net-(J2-Pad5)")
(net 13 "Net-(J2-Pad4)")
(net 14 "Net-(J2-Pad3)")
(net 15 "Net-(J2-Pad2)")
(net 16 "Net-(J2-Pad1)")
(net 17 "Net-(U1-Pad4)")
(net 18 "Net-(U1-Pad5)")
(net 19 "Net-(U1-Pad6)")
(net 20 "Net-(U1-Pad8)")
(net 21 "Net-(U1-Pad10)")
(net_class Default "This is the default net class."
(clearance 0.5)
(trace_width 0.5)
(via_dia 1.2)
(via_drill 0.8)
(uvia_dia 0.3)
(uvia_drill 0.1)
(add_net "Net-(C1-Pad1)")
(add_net "Net-(C1-Pad2)")
(add_net "Net-(D1-Pad1)")
(add_net "Net-(D1-Pad2)")
(add_net "Net-(D2-Pad2)")
(add_net "Net-(D3-Pad2)")
(add_net "Net-(J1-Pad1)")
(add_net "Net-(J1-Pad2)")
(add_net "Net-(J1-Pad3)")
(add_net "Net-(J1-Pad4)")
(add_net "Net-(J1-Pad5)")
(add_net "Net-(J2-Pad1)")
(add_net "Net-(J2-Pad2)")
(add_net "Net-(J2-Pad3)")
(add_net "Net-(J2-Pad4)")
(add_net "Net-(J2-Pad5)")
(add_net "Net-(U1-Pad10)")
(add_net "Net-(U1-Pad4)")
(add_net "Net-(U1-Pad5)")
(add_net "Net-(U1-Pad6)")
(add_net "Net-(U1-Pad8)")
)
(module fab:fab-C1206FAB (layer F.Cu) (tedit 200000) (tstamp 5EBCBD43)
(at 118 51 90)
(path /5EBC78CD)
(attr smd)
(fp_text reference C1 (at 0.762 -1.778 90) (layer F.SilkS)
(effects (font (size 1.016 1.016) (thickness 0.1524)))
)
(fp_text value 10p (at 1.27 1.778 90) (layer F.SilkS)
(effects (font (size 1.016 1.016) (thickness 0.1524)))
)
(fp_line (start -2.032 -1.016) (end 2.032 -1.016) (layer B.SilkS) (width 0.127))
(fp_line (start 2.032 -1.016) (end 2.032 1.016) (layer B.SilkS) (width 0.127))
(fp_line (start 2.032 1.016) (end -2.032 1.016) (layer B.SilkS) (width 0.127))
(fp_line (start -2.032 1.016) (end -2.032 -1.016) (layer B.SilkS) (width 0.127))
(pad 1 smd rect (at -1.651 0 90) (size 1.27 1.905) (layers F.Cu F.Paste F.Mask)
(net 1 "Net-(C1-Pad1)"))
(pad 2 smd rect (at 1.651 0 90) (size 1.27 1.905) (layers F.Cu F.Paste F.Mask)
(net 2 "Net-(C1-Pad2)"))
)
(module fab:fab-LED1206FAB (layer F.Cu) (tedit 200000) (tstamp 5EBCBD4D)
(at 112.276 67.899501)
(descr "LED1206 FAB STYLE (SMALLER PADS TO ALLOW TRACE BETWEEN)")
(tags "LED1206 FAB STYLE (SMALLER PADS TO ALLOW TRACE BETWEEN)")
(path /5EBE1F3C)
(attr smd)
(fp_text reference D1 (at 0.762 -1.778) (layer F.SilkS)
(effects (font (size 1.016 1.016) (thickness 0.1524)))
)
(fp_text value LED (at 1.27 1.778) (layer F.SilkS)
(effects (font (size 1.016 1.016) (thickness 0.1524)))
)
(fp_line (start -2.032 1.016) (end -2.032 -1.016) (layer B.SilkS) (width 0.127))
(fp_line (start 2.032 1.016) (end -2.032 1.016) (layer B.SilkS) (width 0.127))
(fp_line (start 2.032 -1.016) (end 2.032 1.016) (layer B.SilkS) (width 0.127))
(fp_line (start -2.032 -1.016) (end 2.032 -1.016) (layer B.SilkS) (width 0.127))
(pad 2 smd rect (at 1.651 0) (size 1.27 1.905) (layers F.Cu F.Paste F.Mask)
(net 3 "Net-(D1-Pad2)"))
(pad 1 smd rect (at -1.651 0) (size 1.27 1.905) (layers F.Cu F.Paste F.Mask)
(net 4 "Net-(D1-Pad1)"))
)
(module LED_SMD:LED_1210_3225Metric_Pad1.42x2.65mm_HandSolder (layer F.Cu) (tedit 5B4B45C9) (tstamp 5EBCC3F1)
(at 115 46.465001)
(descr "LED SMD 1210 (3225 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: http://www.tortai-tech.com/upload/download/2011102023233369053.pdf), generated with kicad-footprint-generator")
(tags "LED handsolder")
(path /5EBC70F0)
(attr smd)
(fp_text reference D2 (at 0 -2.28) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value D_Photo (at 0 2.28) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start 1.6 -1.25) (end -0.975 -1.25) (layer F.Fab) (width 0.1))
(fp_line (start -0.975 -1.25) (end -1.6 -0.625) (layer F.Fab) (width 0.1))
(fp_line (start -1.6 -0.625) (end -1.6 1.25) (layer F.Fab) (width 0.1))
(fp_line (start -1.6 1.25) (end 1.6 1.25) (layer F.Fab) (width 0.1))
(fp_line (start 1.6 1.25) (end 1.6 -1.25) (layer F.Fab) (width 0.1))
(fp_line (start 1.6 -1.585) (end -2.46 -1.585) (layer F.SilkS) (width 0.12))
(fp_line (start -2.46 -1.585) (end -2.46 1.585) (layer F.SilkS) (width 0.12))
(fp_line (start -2.46 1.585) (end 1.6 1.585) (layer F.SilkS) (width 0.12))
(fp_line (start -2.45 1.58) (end -2.45 -1.58) (layer F.CrtYd) (width 0.05))
(fp_line (start -2.45 -1.58) (end 2.45 -1.58) (layer F.CrtYd) (width 0.05))
(fp_line (start 2.45 -1.58) (end 2.45 1.58) (layer F.CrtYd) (width 0.05))
(fp_line (start 2.45 1.58) (end -2.45 1.58) (layer F.CrtYd) (width 0.05))
(fp_text user %R (at 0 0) (layer F.Fab)
(effects (font (size 0.8 0.8) (thickness 0.12)))
)
(pad 1 smd roundrect (at -1.4875 0) (size 1.425 2.65) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.175439)
(net 2 "Net-(C1-Pad2)"))
(pad 2 smd roundrect (at 1.4875 0) (size 1.425 2.65) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.175439)
(net 5 "Net-(D2-Pad2)"))
(model ${KISYS3DMOD}/LED_SMD.3dshapes/LED_1210_3225Metric.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(module fab:fab-LED1206FAB (layer F.Cu) (tedit 200000) (tstamp 5EBCBD6A)
(at 117.846 68.199501)
(descr "LED1206 FAB STYLE (SMALLER PADS TO ALLOW TRACE BETWEEN)")
(tags "LED1206 FAB STYLE (SMALLER PADS TO ALLOW TRACE BETWEEN)")
(path /5EBC7B3C)