-
Notifications
You must be signed in to change notification settings - Fork 1
/
piezospeaker.cpp
49 lines (39 loc) · 1.13 KB
/
piezospeaker.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
#include <utils/utils.h>
#include "piezospeaker.h"
#include "ui_piezo.h"
PiezoSpeaker::PiezoSpeaker(QWidget *parent, const char *title, bool isV2)
: SensorInterface(parent)
, uiSpeaker(new Ui::PiezoSpeaker())
{
uiSpeaker->setupUi(this);
uiSpeaker->groupBox->setTitle(title);
connectTooltipTo(uiSpeaker->groupBox);
statusLED = uiSpeaker->statusLED;
if (isV2)
setLedOn(true);
connect(this, &PiezoSpeaker::valueChanged, this, &PiezoSpeaker::updateUi);
connect(this, &PiezoSpeaker::ledChanged, this, &PiezoSpeaker::updateLed);
}
PiezoSpeaker::~PiezoSpeaker()
{
delete uiSpeaker;
}
/**
* @brief Sensor::updateUi signal receiver method when a value changes
* @param newValue
*/
void PiezoSpeaker::updateUi(int newValue)
{
char buffer[32];
currentValue = newValue;
uiSpeaker->lcdNumber->display(utils::itoa(buffer, newValue));
}
/**
* @brief PiezoSpeaker::updateLed signal receiver method when the led state changes
* @param ledValue
*/
void PiezoSpeaker::updateLed(bool ledValue)
{
// printf("PiezoSpeaker::setLedOn(%d), led = %p\n", ledValue, statusLED);
setLedOn(ledValue);
}