correction des bugs et debugging fonctionne
This commit is contained in:
parent
c184231763
commit
33c9789fb2
|
|
@ -1,28 +1,26 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"name": "Debug C++",
|
||||||
"configurations": [
|
"type": "cppdbg",
|
||||||
{
|
"request": "launch",
|
||||||
"name": "Debug C++",
|
"program": "${workspaceFolder}/main",
|
||||||
"type": "cppdbg",
|
"args": [],
|
||||||
"request": "launch",
|
"stopAtEntry": false,
|
||||||
"program": "${workspaceFolder}/main",
|
"cwd": "${workspaceFolder}",
|
||||||
"args": [],
|
"environment": [],
|
||||||
"stopAtEntry": false,
|
"externalConsole": true,
|
||||||
"cwd": "${workspaceFolder}",
|
"MIMode": "gdb",
|
||||||
"environment": [],
|
"miDebuggerPath": "C:/MinGW/bin/gdb.exe", // <- adjust this path to your Windows gdb
|
||||||
"externalConsole": true,
|
"setupCommands": [
|
||||||
"MIMode": "gdb",
|
{
|
||||||
"setupCommands": [
|
"description": "Enable pretty-printing for gdb",
|
||||||
{
|
"text": "-enable-pretty-printing",
|
||||||
"description": "Enable pretty-printing for gdb",
|
"ignoreFailures": true
|
||||||
"text": "-enable-pretty-printing",
|
}
|
||||||
"ignoreFailures": true
|
],
|
||||||
}
|
"preLaunchTask": "C/C++: g++.exe build active file"
|
||||||
],
|
}
|
||||||
"preLaunchTask": "build",
|
]
|
||||||
"miDebuggerPath": "/usr/bin/gdb" // ou chemin vers gdb sous Windows
|
}
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 <vector>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
// Seuils de BPM
|
// Seuils de BPM
|
||||||
const int BPM_MIN = 50;
|
const int BPM_MIN = 50;
|
||||||
const int BPM_MAX = 120;
|
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 ===
|
// === Simule la récupération de données du capteur ===
|
||||||
int acquerirDonnees() {
|
int acquerirDonnees() {
|
||||||
// Ici tu brancherais ton ADC ou capteur réel
|
// Ici tu brancherais ton ADC ou capteur réel
|
||||||
// Simulation d'une fréquence cardiaque variable
|
// 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;
|
return fakeBPM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,7 +45,7 @@ bool verifierAnomalie(int bpm) {
|
||||||
|
|
||||||
// === Déclenche une alerte ===
|
// === Déclenche une alerte ===
|
||||||
void alerter(int bpm) {
|
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.
|
// Tu peux ici allumer une LED, déclencher un buzzer, etc.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,6 +62,7 @@ void afficher(int bpm, bool anomalie) {
|
||||||
int main() {
|
int main() {
|
||||||
std::vector<int> bufferBPM;
|
std::vector<int> bufferBPM;
|
||||||
const int tailleBuffer = 5;
|
const int tailleBuffer = 5;
|
||||||
|
std::srand(std::time(0));
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int mesure = acquerirDonnees();
|
int mesure = acquerirDonnees();
|
||||||
|
|
@ -68,7 +80,7 @@ int main() {
|
||||||
alerter(bpm);
|
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;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue