31 #include "ui_brainre1configuration.h"
33 #include "hwbrainre1.h"
64 connect(ui->pbGenerateILap, &QAbstractButton::clicked,
this,
65 &BrainRE1Configuration::generateILapID);
66 connect(ui->pbGenerateTrackmate, &QAbstractButton::clicked,
this,
67 &BrainRE1Configuration::generateTrackmateID);
71 ui->sbVideoSyncDetectorThreshold);
83 img = QPixmap(
":/brainfpv/images/brainre1.png");
84 ui->imgLabel->setPixmap(img);
86 connect(ui->cmbMultiPortMode, SIGNAL(currentIndexChanged(
int)),
this, SLOT(mpChanged(
int)));
87 connect(ui->cmbI2CExtMag, SIGNAL(currentIndexChanged(
int)),
this, SLOT(extMagChanged(
int)));
89 mpChanged(re1_settings_obj->getMultiPortMode());
90 extMagChanged(re1_settings_obj->getI2CExtMag());
98 void BrainRE1Configuration::widgetsContentsChanged()
102 if ((ui->cmbUsbHidPort->currentIndex() == HwBrainRE1::USB_HIDPORT_USBTELEMETRY)
103 && (ui->cmbUsbVcpPort->currentIndex() == HwBrainRE1::USB_VCPPORT_USBTELEMETRY)) {
105 ui->lblMsg->setText(tr(
"Warning: you have configured both USB HID Port and USB VCP Port "
106 "for telemetry, this currently is not supported"));
107 }
else if ((ui->cmbUsbHidPort->currentIndex() != HwBrainRE1::USB_HIDPORT_USBTELEMETRY)
108 && (ui->cmbUsbVcpPort->currentIndex() != HwBrainRE1::USB_VCPPORT_USBTELEMETRY)) {
110 ui->lblMsg->setText(tr(
"Warning: you have disabled USB Telemetry on both USB HID Port and "
111 "USB VCP Port, this currently is not supported"));
113 ui->lblMsg->setText(
"");
118 void BrainRE1Configuration::generateILapID()
120 ui->sbILapID->setValue(generateRandomNumber(9999999));
123 void BrainRE1Configuration::generateTrackmateID()
125 uint16_t trackmate_id;
128 trackmate_id = generateRandomNumber(0xFFF);
132 valid = ((trackmate_id & 0x0F00) >> 8) != 0x0;
133 valid = valid && (((trackmate_id & 0x0F00) >> 8) != 0x1);
134 valid = valid && (((trackmate_id & 0x0F00) >> 8) != 0x8);
135 valid = valid && (((trackmate_id & 0x0F00) >> 8) != 0xF);
136 valid = valid && (((trackmate_id & 0x00F0) >> 4) != 0x0);
137 valid = valid && (((trackmate_id & 0x00F0) >> 4) != 0xF);
138 valid = valid && ((trackmate_id & 0x000F) != 0x0);
139 valid = valid && ((trackmate_id & 0x000F) != 0xF);
141 ui->sbTrackmateID->setValue(trackmate_id);
144 int BrainRE1Configuration::generateRandomNumber(
int max)
147 std::random_device generator;
148 std::uniform_int_distribution<int> distribution(0, max);
150 return distribution(generator);
153 void BrainRE1Configuration::mpChanged(
int idx)
156 if (idx == HwBrainRE1::MULTIPORTMODE_NORMAL) {
157 img = QPixmap(
":/brainfpv/images/re1_mp_normal.png");
158 ui->cmbMultiPortSerial2->setHidden(
true);
159 ui->labelMultiPortSerial2->setHidden(
true);
161 img = QPixmap(
":/brainfpv/images/re1_mp_4pwm.png");
162 ui->cmbMultiPortSerial2->setHidden(
false);
163 ui->labelMultiPortSerial2->setHidden(
false);
165 ui->imgLabelMp->setPixmap(img);
168 void BrainRE1Configuration::extMagChanged(
int idx)
171 ui->cmbExtMagOrientation->setHidden(
true);
172 ui->labelExtMagOrientation->setHidden(
true);
174 ui->cmbExtMagOrientation->setHidden(
false);
175 ui->labelExtMagOrientation->setHidden(
false);
BrainRE1Configuration(QWidget *parent=nullptr)