Skip to content

Commit

Permalink
Change the judgment of the monitor after receiving the packet into a …
Browse files Browse the repository at this point in the history
…switch statement.
  • Loading branch information
ZhuYanzhen1 committed Sep 26, 2021
1 parent 2f20a9f commit bdf3693
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
1 change: 0 additions & 1 deletion program/algorithm/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ void report_local_variable(void) {
buffer[1] = (unsigned char) ((upload_var[counter * 2] >> 16UL) & 0x000000ffUL);
buffer[2] = (unsigned char) ((upload_var[counter * 2] >> 8UL) & 0x000000ffUL);
buffer[3] = (unsigned char) (upload_var[counter * 2] & 0x000000ffUL);

buffer[4] = (unsigned char) ((upload_var[counter * 2 + 1] >> 24UL) & 0x000000ffUL);
buffer[5] = (unsigned char) ((upload_var[counter * 2 + 1] >> 16UL) & 0x000000ffUL);
buffer[6] = (unsigned char) ((upload_var[counter * 2 + 1] >> 8UL) & 0x000000ffUL);
Expand Down
2 changes: 1 addition & 1 deletion tools/CMakeLists.txt.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2021-09-24T22:54:49. -->
<!-- Written by QtCreator 4.11.1, 2021-09-26T13:26:18. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
33 changes: 19 additions & 14 deletions tools/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,25 @@ MainWindow::~MainWindow(){
}

void MainWindow::mdtp_callback_handler(unsigned char pid, const unsigned char *data){
if(pid == 0){
uint32_t velocity = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
uint32_t angle = (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7];
curve_x.resize(curve_counter + 1);
curve_angle.resize(curve_counter + 1);
curve_velocity.resize(curve_counter + 1);
curve_x[curve_counter] = (curve_counter + 1) * 0.05f;
curve_angle[curve_counter] = (*((float *)(&angle)));
curve_velocity[curve_counter] = (*((float *)(&velocity)));
ui->custom_plot->graph(0)->setData(curve_x, curve_velocity);
ui->custom_plot->graph(1)->setData(curve_x, curve_angle);
ui->custom_plot->rescaleAxes();
ui->custom_plot->replot();
curve_counter = curve_counter + 1;
uint32_t data1, data2;
data1 = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
data2 = (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7];
switch (pid) {
case 0:
curve_x.resize(curve_counter + 1);
curve_angle.resize(curve_counter + 1);
curve_velocity.resize(curve_counter + 1);
curve_x[curve_counter] = (curve_counter + 1) * 0.05f;
curve_angle[curve_counter] = (*((float *)(&data2)));
curve_velocity[curve_counter] = (*((float *)(&data1)));
ui->custom_plot->graph(0)->setData(curve_x, curve_velocity);
ui->custom_plot->graph(1)->setData(curve_x, curve_angle);
ui->custom_plot->rescaleAxes();
ui->custom_plot->replot();
curve_counter = curve_counter + 1;
break;
default:
break;
}
}

Expand Down

0 comments on commit bdf3693

Please sign in to comment.