mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-08 20:44:58 +00:00
Merge branch 'master' into arduino-esp32-v3.2
This commit is contained in:
commit
76bcd05259
@ -184,8 +184,13 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
|||||||
type = RTC_RV3028;
|
type = RTC_RV3028;
|
||||||
logFoundDevice("RV3028", (uint8_t)addr.address);
|
logFoundDevice("RV3028", (uint8_t)addr.address);
|
||||||
rtc.initI2C(*i2cBus);
|
rtc.initI2C(*i2cBus);
|
||||||
rtc.writeToRegister(0x35, 0x07); // no Clkout
|
// Update RTC EEPROM settings, if necessary
|
||||||
rtc.writeToRegister(0x37, 0xB4);
|
if (rtc.readEEPROMRegister(0x35) != 0x07) {
|
||||||
|
rtc.writeEEPROMRegister(0x35, 0x07); // no Clkout
|
||||||
|
}
|
||||||
|
if (rtc.readEEPROMRegister(0x37) != 0xB4) {
|
||||||
|
rtc.writeEEPROMRegister(0x37, 0xB4);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1264,7 +1264,7 @@ int Screen::handleTextMessage(const meshtastic_MeshPacket *packet)
|
|||||||
if (shouldWakeOnReceivedMessage()) {
|
if (shouldWakeOnReceivedMessage()) {
|
||||||
setOn(true); // Wake up the screen first
|
setOn(true); // Wake up the screen first
|
||||||
forceDisplay(); // Forces screen redraw
|
forceDisplay(); // Forces screen redraw
|
||||||
|
}
|
||||||
// === Prepare banner content ===
|
// === Prepare banner content ===
|
||||||
const meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(packet->from);
|
const meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(packet->from);
|
||||||
const char *longName = (node && node->has_user) ? node->user.long_name : nullptr;
|
const char *longName = (node && node->has_user) ? node->user.long_name : nullptr;
|
||||||
@ -1299,7 +1299,6 @@ int Screen::handleTextMessage(const meshtastic_MeshPacket *packet)
|
|||||||
screen->showSimpleBanner(banner, 3000);
|
screen->showSimpleBanner(banner, 3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
currentKey ^= ((size_t)mp.id << 24);
|
currentKey ^= ((size_t)mp.id << 24);
|
||||||
|
|
||||||
if (cachedKey != currentKey) {
|
if (cachedKey != currentKey) {
|
||||||
LOG_INFO("Message cache key is misssed cachedKey=0x%0x, currentKey=0x%x", cachedKey, currentKey);
|
LOG_INFO("Onscreen message scroll cache key needs updating: cachedKey=0x%0x, currentKey=0x%x", cachedKey, currentKey);
|
||||||
|
|
||||||
// Cache miss - regenerate lines and heights
|
// Cache miss - regenerate lines and heights
|
||||||
cachedLines = generateLines(display, headerStr, messageBuf, textWidth);
|
cachedLines = generateLines(display, headerStr, messageBuf, textWidth);
|
||||||
|
@ -761,8 +761,17 @@ void setup()
|
|||||||
|
|
||||||
#if defined(USE_SH1107_128_64)
|
#if defined(USE_SH1107_128_64)
|
||||||
screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // keep dimension of 128x64
|
screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // keep dimension of 128x64
|
||||||
|
screen_geometry = GEOMETRY_128_64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// if we have one of the fixed overrides in the settings, adjust display type accordingly.
|
||||||
|
if (screen_model == meshtastic_Config_DisplayConfig_OledType_OLED_SH1107) {
|
||||||
|
screen_geometry = GEOMETRY_128_128;
|
||||||
|
} else if (screen_model == meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_128_64) {
|
||||||
|
screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107;
|
||||||
|
screen_geometry = GEOMETRY_128_64;
|
||||||
|
}
|
||||||
|
|
||||||
#if !MESHTASTIC_EXCLUDE_I2C
|
#if !MESHTASTIC_EXCLUDE_I2C
|
||||||
#if !defined(ARCH_STM32WL)
|
#if !defined(ARCH_STM32WL)
|
||||||
if (acc_info.type != ScanI2C::DeviceType::NONE) {
|
if (acc_info.type != ScanI2C::DeviceType::NONE) {
|
||||||
|
@ -32,16 +32,42 @@ void INA226Sensor::begin(TwoWire *wire, uint8_t addr)
|
|||||||
_addr = addr;
|
_addr = addr;
|
||||||
ina226 = INA226(_addr, _wire);
|
ina226 = INA226(_addr, _wire);
|
||||||
_wire->begin();
|
_wire->begin();
|
||||||
|
ina226.setMaxCurrentShunt(0.8, 0.100);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool INA226Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
bool INA226Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||||
|
{
|
||||||
|
switch (measurement->which_variant) {
|
||||||
|
case meshtastic_Telemetry_environment_metrics_tag:
|
||||||
|
return getEnvironmentMetrics(measurement);
|
||||||
|
|
||||||
|
case meshtastic_Telemetry_power_metrics_tag:
|
||||||
|
return getPowerMetrics(measurement);
|
||||||
|
}
|
||||||
|
|
||||||
|
// unsupported metric
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool INA226Sensor::getEnvironmentMetrics(meshtastic_Telemetry *measurement)
|
||||||
{
|
{
|
||||||
measurement->variant.environment_metrics.has_voltage = true;
|
measurement->variant.environment_metrics.has_voltage = true;
|
||||||
measurement->variant.environment_metrics.has_current = true;
|
measurement->variant.environment_metrics.has_current = true;
|
||||||
|
|
||||||
// mV conversion to V
|
|
||||||
measurement->variant.environment_metrics.voltage = ina226.getBusVoltage();
|
measurement->variant.environment_metrics.voltage = ina226.getBusVoltage();
|
||||||
measurement->variant.environment_metrics.current = ina226.getCurrent_mA();
|
measurement->variant.environment_metrics.current = ina226.getCurrent_mA();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool INA226Sensor::getPowerMetrics(meshtastic_Telemetry *measurement)
|
||||||
|
{
|
||||||
|
measurement->variant.power_metrics.has_ch1_voltage = true;
|
||||||
|
measurement->variant.power_metrics.has_ch1_current = true;
|
||||||
|
|
||||||
|
measurement->variant.power_metrics.ch1_voltage = ina226.getBusVoltage();
|
||||||
|
measurement->variant.power_metrics.ch1_current = ina226.getCurrent_mA();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@ class INA226Sensor : public TelemetrySensor, VoltageSensor, CurrentSensor
|
|||||||
TwoWire *_wire = &Wire;
|
TwoWire *_wire = &Wire;
|
||||||
INA226 ina226 = INA226(_addr, _wire);
|
INA226 ina226 = INA226(_addr, _wire);
|
||||||
|
|
||||||
|
bool getEnvironmentMetrics(meshtastic_Telemetry *measurement);
|
||||||
|
bool getPowerMetrics(meshtastic_Telemetry *measurement);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setup() override;
|
virtual void setup() override;
|
||||||
void begin(TwoWire *wire = &Wire, uint8_t addr = INA_ADDR);
|
void begin(TwoWire *wire = &Wire, uint8_t addr = INA_ADDR);
|
||||||
|
Loading…
Reference in New Issue
Block a user