correction des bugs et debugging fonctionne
This commit is contained in:
parent
c184231763
commit
33c9789fb2
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
|
@ -13,6 +12,7 @@
|
|||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "C:/MinGW/bin/gdb.exe", // <- adjust this path to your Windows gdb
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
|
|
@ -20,9 +20,7 @@
|
|||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"preLaunchTask": "build",
|
||||
"miDebuggerPath": "/usr/bin/gdb" // ou chemin vers gdb sous Windows
|
||||
"preLaunchTask": "C/C++: g++.exe build active file"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,50 @@
|
|||
{
|
||||
"C_Cpp.default.compilerPath": "C:/MinGW/bin/g++.exe"
|
||||
"C_Cpp.default.compilerPath": "C:/MinGW/bin/g++.exe",
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cctype": "cpp",
|
||||
"chrono": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"string": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++.exe build active file",
|
||||
"command": "C:/MinGW/bin/g++.exe",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}\\${fileBasenameNoExtension}.exe"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "C:/MinGW/bin"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "compiler: C:/MinGW/bin/g++.exe"
|
||||
}
|
||||
]
|
||||
}
|
||||
18
main.cpp
18
main.cpp
|
|
@ -2,16 +2,27 @@
|
|||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <windows.h>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
|
||||
// Seuils de BPM
|
||||
const int BPM_MIN = 50;
|
||||
const int BPM_MAX = 120;
|
||||
int fakeBPM = 60;
|
||||
const int secondsBetweenMeasures = 10;
|
||||
const int bufferSize = 60480; // une semaine à 1 mesure/10s
|
||||
int historique[bufferSize];
|
||||
int index = 0;
|
||||
|
||||
// === Simule la récupération de données du capteur ===
|
||||
int acquerirDonnees() {
|
||||
// Ici tu brancherais ton ADC ou capteur réel
|
||||
// Simulation d'une fréquence cardiaque variable
|
||||
static int fakeBPM = 70 + rand() % 60 - 30;
|
||||
fakeBPM = fakeBPM - 5 + rand() % 11 ;
|
||||
std::cout << "Le random BPM est "<<fakeBPM << std::endl;
|
||||
historique[index % bufferSize] = fakeBPM;
|
||||
index++;
|
||||
return fakeBPM;
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +45,7 @@ bool verifierAnomalie(int bpm) {
|
|||
|
||||
// === Déclenche une alerte ===
|
||||
void alerter(int bpm) {
|
||||
std::cout << "⚠ Alerte : rythme cardiaque anormal (" << bpm << " BPM) !" << std::endl;
|
||||
std::cout << " Alerte : rythme cardiaque anormal (" << bpm << " BPM) !" << std::endl;
|
||||
// Tu peux ici allumer une LED, déclencher un buzzer, etc.
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +62,7 @@ void afficher(int bpm, bool anomalie) {
|
|||
int main() {
|
||||
std::vector<int> bufferBPM;
|
||||
const int tailleBuffer = 5;
|
||||
std::srand(std::time(0));
|
||||
|
||||
while (true) {
|
||||
int mesure = acquerirDonnees();
|
||||
|
|
@ -68,7 +80,7 @@ int main() {
|
|||
alerter(bpm);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1)); // simulation de délai entre mesures
|
||||
sleep(1); // simulation de délai entre mesures
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue