mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
283 Add support of INA3221 to Promicro telemetry
This commit is contained in:
parent
d072e7b575
commit
b035487101
6 changed files with 214 additions and 3 deletions
|
|
@ -7,6 +7,12 @@
|
|||
|
||||
#define TELEM_CHANNEL_SELF 1 // LPP data channel for 'self' device
|
||||
|
||||
#define TELEM_INA3221_ADDRESS 0x40 // INA3221 3 channel current, voltage, power sensor I2C address
|
||||
#define TELEM_INA3221_SHUNT_VALUE 0.100 // most variants will have a 0.1 ohm shunts
|
||||
#define TELEM_INA3221_SETTING_CH1 "INA3221 Channel 1"
|
||||
#define TELEM_INA3221_SETTING_CH2 "INA3221 Channel 2"
|
||||
#define TELEM_INA3221_SETTING_CH3 "INA3221 Channel 3"
|
||||
|
||||
class SensorManager {
|
||||
public:
|
||||
double node_lat, node_lon; // modify these, if you want to affect Advert location
|
||||
|
|
|
|||
72
src/helpers/sensors/SensorSettingsManager.h
Normal file
72
src/helpers/sensors/SensorSettingsManager.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class SensorSettingsManager {
|
||||
private:
|
||||
std::vector<std::pair<std::string, bool>> settings;
|
||||
|
||||
public:
|
||||
|
||||
int getSettingCount() const {
|
||||
return static_cast<int>(settings.size());
|
||||
};
|
||||
|
||||
bool addSetting(const std::string& name, bool defaultValue = false){
|
||||
for (const auto& setting : settings) {
|
||||
if (setting.first == name) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
settings.emplace_back(name, defaultValue);
|
||||
return true;
|
||||
};
|
||||
|
||||
bool removeSetting(const std::string& name) {
|
||||
for (auto it = settings.begin(); it != settings.end(); ++it) {
|
||||
if (it->first == name) {
|
||||
settings.erase(it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const char* getSettingValue(const std::string& name) const{
|
||||
for (const auto& setting : settings) {
|
||||
if (setting.first == name) {
|
||||
return setting.second ? "true" : "false";
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
const char* getSettingValue(int index) const {
|
||||
if (index >= 0 && index < getSettingCount()) {
|
||||
return settings[index].second ? "true" : "false";
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
bool setSettingValue(const std::string& name, const std::string& value) {
|
||||
for (auto& setting : settings) {
|
||||
if (setting.first == name) {
|
||||
// Convert value to boolean
|
||||
if (value == "1" || value == "true") {
|
||||
setting.second = true;
|
||||
} else {
|
||||
setting.second = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* getSettingName(int index) const {
|
||||
if (index >= 0 && index < getSettingCount()){
|
||||
return settings[index].first.c_str();
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue