Skip to content

Commit

Permalink
The display and upload of available information are realized.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuYanzhen1 committed Nov 4, 2021
1 parent 6f973d1 commit 590f2c4
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 10 deletions.
2 changes: 1 addition & 1 deletion firmware
Submodule firmware updated from 037cb0 to 8f6bd3
3 changes: 2 additions & 1 deletion program/algorithm/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ void report_local_variable(void) {
unsigned char buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};

/* compress the angle deviation and motor phase sequence into a 32-bit integer */
upload_var[0] = (machine_angle_offset << 16) | phase_sequence;
upload_var[0] = (machine_angle_offset << 16) | phase_sequence | foc_parameter_available_flag << 1
| pid_parameter_available_flag << 2;

/* converts user expect value to an integer */
switch (pid_control_mode_flag) {
Expand Down
25 changes: 25 additions & 0 deletions tools/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ MainWindow::~MainWindow(){
void MainWindow::update_minimum_maximum_value(float value, QLabel *value_widget, QSlider *value_slider,
QTextEdit *maximum_tb, QTextEdit *minimum_tb){
int32_t pow_counter = 0, maximum = 0, minimum = 0, error_value = 0, value_step = 0;
qDebug() << QString("value: %1").arg(value);
if(value != 0) {
if(value < 0) {
value = -1.0 * value;
Expand Down Expand Up @@ -87,6 +88,30 @@ void MainWindow::mdtp_callback_handler(unsigned char pid, const unsigned char *d
curve_counter = curve_counter + 1;
break;
case 1:
ui->angle_offset_lable->setText("Offset: " + QString::number(data1 >> 16));
ui->phase_lable->setText("Phase: " + QString::number(data1 & 0x0001));
if(((data1 & 0x0002) >> 1) == 0x01) {
QPalette pe;
ui->foc_available_lable->setText("FOC Available");
pe.setColor(QPalette::WindowText, Qt::green);
ui->foc_available_lable->setPalette(pe);
} else {
QPalette pe;
ui->foc_available_lable->setText("FOC Unavailable");
pe.setColor(QPalette::WindowText, Qt::red);
ui->foc_available_lable->setPalette(pe);
}
if(((data1 & 0x0004) >> 2) == 0x01) {
QPalette pe;
ui->pid_available_lable->setText("PID Available");
pe.setColor(QPalette::WindowText, Qt::green);
ui->pid_available_lable->setPalette(pe);
} else {
QPalette pe;
ui->pid_available_lable->setText("PID Unavailable");
pe.setColor(QPalette::WindowText, Qt::red);
ui->pid_available_lable->setPalette(pe);
}
update_minimum_maximum_value((*((float *)(&data2))), ui->slider_current_value,
ui->user_expect_slider, ui->slider_maximum_value, ui->slider_minimum_value);
break;
Expand Down
57 changes: 49 additions & 8 deletions tools/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@
<string>0</string>
</property>
</widget>
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="angle_offset_lable">
<property name="geometry">
<rect>
<x>720</x>
<y>210</y>
<width>72</width>
<height>15</height>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="font">
Expand All @@ -357,16 +357,57 @@
</font>
</property>
<property name="text">
<string>TextLabel</string>
<string>Offset: </string>
</property>
</widget>
<widget class="QLabel" name="label_12">
<widget class="QLabel" name="phase_lable">
<property name="geometry">
<rect>
<x>720</x>
<y>240</y>
<width>72</width>
<height>15</height>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Phase: </string>
</property>
</widget>
<widget class="QLabel" name="pid_available_lable">
<property name="geometry">
<rect>
<x>720</x>
<y>270</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>PID Available</string>
</property>
</widget>
<widget class="QLabel" name="foc_available_lable">
<property name="geometry">
<rect>
<x>720</x>
<y>300</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="font">
Expand All @@ -376,7 +417,7 @@
</font>
</property>
<property name="text">
<string>TextLabel</string>
<string>FOC Available</string>
</property>
</widget>
</widget>
Expand Down

0 comments on commit 590f2c4

Please sign in to comment.