/*
-- st?thoscope --
Code g?n?r? par RemoteXY + ajout? la logique capteur et BPM.
N?cessite la biblioth?que RemoteXY : [Link]
*/
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600
#include <RemoteXY.h>
// Configuration graphique g?n?r?e par RemoteXY
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = {
255,0,0,39,0,70,1,19,0,0,0,0,24,4,106,200,200,60,200,80,
200,84,1,1,12,0,130,4,50,21,133,11,11,52,46,11,20,72,56,8,
23,86,51,27,111,68,9,57,21,133,12,12,50,44,13,21,68,54,10,25,
82,48,17,24,35,129,5,246,97,40,80,3,63,9,70,4,83,12,64,1,
76,11,64,97,83,84,69,84,72,79,83,67,79,80,69,0,129,33,58,73,
30,121,17,22,9,119,23,61,7,119,20,61,7,0,139,98,97,116,116,101,
109,101,110,116,32,100,101,32,99,111,101,117,114,0,129,33,145,73,30,121,
44,22,9,120,51,45,7,120,47,45,7,64,139,69,116,97,116,32,99,97,
114,100,105,97,113,117,101,0,130,42,40,21,100,79,12,40,30,114,24,4,
4,113,21,5,5,2,195,130,46,88,21,100,86,26,40,30,115,52,4,4,
114,48,5,5,2,167,67,64,90,21,25,120,27,40,8,120,36,40,10,124,
32,38,9,109,64,8,3,67,64,158,21,25,120,47,40,8,120,63,40,10,
125,59,38,9,101,64,8,31,129,236,249,73,30,20,254,22,9,7,3,36,
12,4,77,49,7,128,111,80,97,114,32,73,108,104,97,109,32,69,108,104,
105,104,105,0,129,235,19,71,29,16,6,22,9,14,8,27,11,13,14,35,
7,64,139,83,105,103,110,97,108,32,69,67,71,0,130,0,254,21,95,0,
255,40,29,0,255,40,38,7,14,5,5,2,167
};
// Variables de l'interface
struct {
float onlineGraph_01_var1;
float BPM;
char Etat[31];
uint8_t connect_flag;
} RemoteXY;
#pragma pack(pop)
//////////////////////////////////////////////
void setup() {
RemoteXY_Init();
[Link](9600); // Pour afficher dans le moniteur s?rie
pinMode(A0, INPUT);
}
void loop() {
RemoteXY_Handler();
// Lire le signal analogique
int signal = analogRead(A0);
// Mettre ? l'?chelle pour RemoteXY Graph (0-255)
RemoteXY.onlineGraph_01_var1 = signal / 4.0;
// Calcul BPM avec d?tection de pics
static unsigned long lastTime = 0;
static int beatCount = 0;
static unsigned long startTime = millis();
static bool lastPulse = false;
bool currentPulse = signal > 530; // seuil ajustable selon ton capteur
if (currentPulse && !lastPulse) {
beatCount++;
lastTime = millis();
}
lastPulse = currentPulse;
// Calcul toutes les 10 secondes
if (millis() - startTime >= 10000) {
float bpm = beatCount * 6.0; // 10s ? multiplier par 6 pour obtenir BPM
[Link] = bpm;
if (bpm > 70 and bpm <= 100) {
snprintf([Link], sizeof([Link]), "Etat normal");
} else {
snprintf([Link], sizeof([Link]), "Etat anormale");
}
beatCount = 0;
startTime = millis();
}
RemoteXY_delay(20); // Rafra?chissement fluide
[Link](signal);
}