currentMeas
This commit is contained in:
1 parent
f93a8aaabd
commit
d2b8e1de3c
9 files changed
+92
-27
No files matched your search
+38
-3
@@ -20,9 +20,11 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "Ads1115.hpp"
|
||||
#include "MqttClient.hpp"
|
||||
#include "coreExcept.hpp"
|
||||
#include "gpioPort.hpp"
|
||||
#include "i2cPort.hpp"
|
||||
#include "logging.hpp"
|
||||
#include "queue.hpp"
|
||||
#include "textUtils.hpp"
|
||||
@@ -50,6 +52,39 @@ class LinMot {
|
||||
}
|
||||
};
|
||||
|
||||
class CurrMon {
|
||||
// https://www.monolithicpower.com/en/documentview/productdocument/index/version/2/document_type/Datasheet/lang/EN/sku/MCS1802/document_id/5066/
|
||||
public:
|
||||
CurrMon(AdcAds1115& adc)
|
||||
: _adc(adc) {
|
||||
adc.setPga(AdcAds1115::Pga::FSR_4_096V);
|
||||
adc.startContinuousConversion();
|
||||
|
||||
float val{};
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
val += sampe();
|
||||
}
|
||||
_refVal = val / 8;
|
||||
}
|
||||
|
||||
float sampleCurrent() {
|
||||
auto val = sampe() - _refVal;
|
||||
val = val / 0.264;
|
||||
fmt::println("{:.2} A", val);
|
||||
return val;
|
||||
}
|
||||
|
||||
private:
|
||||
float _refVal{};
|
||||
AdcAds1115& _adc;
|
||||
|
||||
float sampe() {
|
||||
float volt;
|
||||
_adc.readConversionVoltage(volt);
|
||||
return volt;
|
||||
}
|
||||
};
|
||||
|
||||
class DeviceIoState {
|
||||
public:
|
||||
DeviceIoState(pal::InputTransAware& entry,
|
||||
@@ -75,7 +110,7 @@ class DeviceIoState {
|
||||
|
||||
std::chrono::seconds PromoDelay{150};
|
||||
int Volume{50};
|
||||
bool Mute{false};
|
||||
bool Mute{true};
|
||||
};
|
||||
|
||||
struct SwordConfig {
|
||||
@@ -113,7 +148,7 @@ class MediaPlayer {
|
||||
return;
|
||||
}
|
||||
thread audioThread([filePath]() {
|
||||
auto cmd = fmt::format("aplay '{}' 2>/dev/null", filePath);
|
||||
auto cmd = fmt::format("aplay '{}'", filePath);
|
||||
auto result = system(cmd.c_str());
|
||||
if (result != 0) {
|
||||
fmt::println(stderr, "ERROR: Failed to play audio file: '{}'", filePath);
|
||||
@@ -134,7 +169,7 @@ class MediaPlayer {
|
||||
fmt::println(stderr, "ERROR: No ALSA volume control found");
|
||||
return;
|
||||
}
|
||||
auto cmd = fmt::format("amixer -q sset '{}' {}% 2>/dev/null", control, volume);
|
||||
auto cmd = fmt::format("amixer -q sset '{}' {}%", control, volume);
|
||||
auto result = system(cmd.c_str());
|
||||
if (result != 0) {
|
||||
fmt::println(stderr, "ERROR: Failed to set volume to {}%", volume);
|
||||
|
||||
Reference in new issue
Block a user