forked from OpenPanzerProject/OP-Config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow_tab_misc.cpp
93 lines (83 loc) · 3.62 KB
/
mainwindow_tab_misc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "mainwindow.h"
#include "ui_mainwindow.h"
//------------------------------------------------------------------------------------------------------------------------>>
// FORM CONTROLS - MISC TAB
//------------------------------------------------------------------------------------------------------------------------>>
void MainWindow::SetupControls_MiscTab()
{
// Setup baud rate combo boxes
//ui->cboUSBBaud->setCategory(bcUSBSerial); // Leaving this hard-coded for now
ui->cboAuxSerialBaud->setCategory(bcAuxSerial);
ui->cboMotorSerialBaud->setCategory(bcMotorSerial);
ui->cboSer3Baud->setCategory(bcSerial3);
// Sabertooth configuration button, label and flag
connect(ui->cboMotorSerialBaud, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSabertoothBaudLabel()));
connect(ui->cmdSetSabertoothBaud, SIGNAL(released()), this, SLOT(cmdSetSabertoothBaud_clicked()));
ui->lblSetSabertoothBaud->setText(QString("Set Sabertooth baud rate to: %1").arg(ui->cboMotorSerialBaud->currentData().toUInt()));
ui->cmdSetSabertoothBaud->setEnabled(false);
ui->cmdSetSabertoothBaud->setChecked(false);
setSabertoothBaudRate = false;
// Pololu configuration buttons and flags
connect(ui->cmdConfigPololuDrive, SIGNAL(released()), this, SLOT(cmdConfigurePololuDrive_clicked()));
connect(ui->cmdConfigPololuTurret, SIGNAL(released()), this, SLOT(cmdConfigurePololuTurret_clicked()));
ui->cmdConfigPololuDrive->setEnabled(false);
ui->cmdConfigPololuTurret->setEnabled(false);
configurePololuDrive = false;
configurePololuTurret = false;
}
void MainWindow::updateSabertoothBaudLabel()
{
ui->lblSetSabertoothBaud->setText(QString("Set Sabertooth baud rate to: %1").arg(ui->cboMotorSerialBaud->currentData().toUInt()));
}
void MainWindow::cmdSetSabertoothBaud_clicked()
{
uint8_t desired_baud;
// Tell the TCB to configure the Sabertooth device (V2 versions only) for the current Serial2 baud rate
if (!setSabertoothBaudRate) // Don't start configuration if one is already going
{
switch (ui->cboMotorSerialBaud->currentData().toUInt())
{
case 2400:
desired_baud = SABERTOOTH_BAUD_2400;
break;
case 9600:
desired_baud = SABERTOOTH_BAUD_9600;
break;
case 19200:
desired_baud = SABERTOOTH_BAUD_19200;
break;
case 38400:
desired_baud = SABERTOOTH_BAUD_38400;
break;
case 115200:
desired_baud = SABERTOOTH_BAUD_115200;
break;
default:
// Should not end up here
desired_baud = 0;
return;
}
ui->cmdSetSabertoothBaud->setChecked(true);
ui->cmdSetSabertoothBaud->setText(QString("Please Wait"));
comm->SetSabertoothBaudRate(desired_baud);
setSabertoothBaudRate = true; // Set flag
}
}
void MainWindow::cmdConfigurePololuDrive_clicked()
{
// Tell the TCB to configure the Pololu device for drive motor
if (!configurePololuDrive && !configurePololuTurret) // Don't start configuration if one is already going
{
comm->ConfigurePololu_Drive();
configurePololuDrive = true; // Set flag
}
}
void MainWindow::cmdConfigurePololuTurret_clicked()
{
// Tell the TCB to configure the Pololu device for turret motor
if (!configurePololuDrive && !configurePololuTurret) // Don't start configuration if one is already going
{
comm->ConfigurePololu_Turret();
configurePololuTurret = true; // Set flag
}
}