Page 100 - MDP2020-2
P. 100
| 인천전자마이스터고등학교 ·············································································································
94
[심박수 Display]
#include <Wire.h>
#include <U8glib.h>
#include <string.h>
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);
const int WIDTH=128;
const int HEIGHT=35;
const int LENGTH=WIDTH;
const int analogInPin = A0;
int x;
int y[LENGTH];
volatile int BPM;
volatile int Signal;
volatile int IBI = 600;
volatile boolean Pulse = false;
volatile boolean QS = false;
volatile int rate[10];
volatile unsigned long sampleCounter = 0;
volatile unsigned long lastBeatTime = 0;
volatile int P =512;
volatile int T = 512;
volatile int thresh = 525;
volatile int amp = 100;
volatile boolean firstBeat = true;
volatile boolean secondBeat = false;
void clearY(){
for(int i=0; i<LENGTH; i++){
y[i] = -1;
}
}
void draw() {
u8g.setFont(u8g_font_unifont);
char bpmStr[3];
char bpmOutput[81];
strcpy(bpmOutput, "BPM:");
sprintf(bpmStr,"%d", BPM);bpmStr (size 3)
strcat(bpmOutput, bpmStr);
u8g.drawStr( 0, 64, bpmOutput);
char ibiStr[3];