FamilyManFamilyMan
Participant
@familyman
Post count: 32

The programming code to simulate the ECG waveform (75bpm) according to the above settings is as follows.

First, define two variables as follows.

  Int num19_1 = 0;
Int num19_2 = 0;
Then generally in the main loop main.c, the ECG curve is depicted by the following code.
delay(10);

num19_1 += 1;
if(num19_1 >= 4){ // Draw one point every 40ms.
num19_1 = 0;
num19_2 += 1;
if(num19_2 == 3){
Serial.println(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series1\”,\”mode\”:\”push\”,\”value\” :10}>ET”);
}else if(num19_2 == 4){
Serial.println(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series1\”,\”mode\”:\”push\”,\”value\” :130}>ET”);
}else{
Serial.println(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series1\”,\”mode\”:\”push\”,\”value\” :40}>ET”);
}
if(num19_2 >= 20){  //every 20 data is a cycle
num19_2 = 0;
}
}