mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-05 21:24:34 +00:00
Putting Modules back to position 0 and some trunk checks found
This commit is contained in:
parent
11d307c609
commit
3a5dc870e0
@ -775,6 +775,33 @@ void Screen::setFrames(FrameFocus focus)
|
|||||||
|
|
||||||
size_t numframes = 0;
|
size_t numframes = 0;
|
||||||
|
|
||||||
|
moduleFrames = MeshModule::GetMeshModulesWithUIFrames();
|
||||||
|
LOG_DEBUG("Show %d module frames", moduleFrames.size());
|
||||||
|
|
||||||
|
// put all of the module frames first.
|
||||||
|
// this is a little bit of a dirty hack; since we're going to call
|
||||||
|
// the same drawModuleFrame handler here for all of these module frames
|
||||||
|
// and then we'll just assume that the state->currentFrame value
|
||||||
|
// is the same offset into the moduleFrames vector
|
||||||
|
// so that we can invoke the module's callback
|
||||||
|
for (auto i = moduleFrames.begin(); i != moduleFrames.end(); ++i) {
|
||||||
|
// Draw the module frame, using the hack described above
|
||||||
|
normalFrames[numframes] = drawModuleFrame;
|
||||||
|
|
||||||
|
// Check if the module being drawn has requested focus
|
||||||
|
// We will honor this request later, if setFrames was triggered by a UIFrameEvent
|
||||||
|
MeshModule *m = *i;
|
||||||
|
if (m->isRequestingFocus())
|
||||||
|
fsi.positions.focusedModule = numframes;
|
||||||
|
if (m == waypointModule)
|
||||||
|
fsi.positions.waypoint = numframes;
|
||||||
|
|
||||||
|
indicatorIcons.push_back(icon_module);
|
||||||
|
numframes++;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG("Added modules. numframes: %d", numframes);
|
||||||
|
|
||||||
// If we have a critical fault, show it first
|
// If we have a critical fault, show it first
|
||||||
fsi.positions.fault = numframes;
|
fsi.positions.fault = numframes;
|
||||||
if (error_code) {
|
if (error_code) {
|
||||||
@ -847,36 +874,6 @@ void Screen::setFrames(FrameFocus focus)
|
|||||||
indicatorIcons.push_back(digital_icon_clock);
|
indicatorIcons.push_back(digital_icon_clock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Beware of what changes you make in this code!
|
|
||||||
// We pass numfames into GetMeshModulesWithUIFrames() which is highly important!
|
|
||||||
// Inside of that callback, goes over to MeshModule.cpp and we run
|
|
||||||
// modulesWithUIFrames.resize(startIndex, nullptr), to insert nullptr
|
|
||||||
// entries until we're ready to start building the matching entries.
|
|
||||||
// We are doing our best to keep the normalFrames vector
|
|
||||||
// and the moduleFrames vector in lock step.
|
|
||||||
moduleFrames = MeshModule::GetMeshModulesWithUIFrames(numframes);
|
|
||||||
LOG_DEBUG("Show %d module frames", moduleFrames.size());
|
|
||||||
|
|
||||||
for (auto i = moduleFrames.begin(); i != moduleFrames.end(); ++i) {
|
|
||||||
// Draw the module frame, using the hack described above
|
|
||||||
if (*i != nullptr) {
|
|
||||||
normalFrames[numframes] = drawModuleFrame;
|
|
||||||
|
|
||||||
// Check if the module being drawn has requested focus
|
|
||||||
// We will honor this request later, if setFrames was triggered by a UIFrameEvent
|
|
||||||
MeshModule *m = *i;
|
|
||||||
if (m && m->isRequestingFocus())
|
|
||||||
fsi.positions.focusedModule = numframes;
|
|
||||||
if (m && m == waypointModule)
|
|
||||||
fsi.positions.waypoint = numframes;
|
|
||||||
|
|
||||||
indicatorIcons.push_back(icon_module);
|
|
||||||
numframes++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_DEBUG("Added modules. numframes: %d", numframes);
|
|
||||||
|
|
||||||
// We don't show the node info of our node (if we have it yet - we should)
|
// We don't show the node info of our node (if we have it yet - we should)
|
||||||
size_t numMeshNodes = nodeDB->getNumMeshNodes();
|
size_t numMeshNodes = nodeDB->getNumMeshNodes();
|
||||||
if (numMeshNodes > 0)
|
if (numMeshNodes > 0)
|
||||||
@ -1252,7 +1249,7 @@ int Screen::handleInputEvent(const InputEvent *event)
|
|||||||
// Ask any MeshModules if they're handling keyboard input right now
|
// Ask any MeshModules if they're handling keyboard input right now
|
||||||
bool inputIntercepted = false;
|
bool inputIntercepted = false;
|
||||||
for (MeshModule *module : moduleFrames) {
|
for (MeshModule *module : moduleFrames) {
|
||||||
if (module && module->interceptingKeyboardInput())
|
if (module->interceptingKeyboardInput())
|
||||||
inputIntercepted = true;
|
inputIntercepted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,13 +244,9 @@ void setReplyTo(meshtastic_MeshPacket *p, const meshtastic_MeshPacket &to)
|
|||||||
p->decoded.request_id = to.id;
|
p->decoded.request_id = to.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MeshModule *> MeshModule::GetMeshModulesWithUIFrames(int startIndex)
|
std::vector<MeshModule *> MeshModule::GetMeshModulesWithUIFrames()
|
||||||
{
|
{
|
||||||
std::vector<MeshModule *> modulesWithUIFrames;
|
std::vector<MeshModule *> modulesWithUIFrames;
|
||||||
|
|
||||||
// Fill with nullptr up to startIndex
|
|
||||||
modulesWithUIFrames.resize(startIndex, nullptr);
|
|
||||||
|
|
||||||
if (modules) {
|
if (modules) {
|
||||||
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||||
auto &pi = **i;
|
auto &pi = **i;
|
||||||
@ -260,7 +256,6 @@ std::vector<MeshModule *> MeshModule::GetMeshModulesWithUIFrames(int startIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return modulesWithUIFrames;
|
return modulesWithUIFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class MeshModule
|
|||||||
*/
|
*/
|
||||||
static void callModules(meshtastic_MeshPacket &mp, RxSource src = RX_SRC_RADIO);
|
static void callModules(meshtastic_MeshPacket &mp, RxSource src = RX_SRC_RADIO);
|
||||||
|
|
||||||
static std::vector<MeshModule *> GetMeshModulesWithUIFrames(int startIndex);
|
static std::vector<MeshModule *> GetMeshModulesWithUIFrames();
|
||||||
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
||||||
static AdminMessageHandleResult handleAdminMessageForAllModules(const meshtastic_MeshPacket &mp,
|
static AdminMessageHandleResult handleAdminMessageForAllModules(const meshtastic_MeshPacket &mp,
|
||||||
meshtastic_AdminMessage *request,
|
meshtastic_AdminMessage *request,
|
||||||
|
@ -79,7 +79,8 @@ std::string MeshPacketSerializer::JsonSerialize(const meshtastic_MeshPacket *mp,
|
|||||||
msgPayload["relative_humidity"] = new JSONValue(decoded->variant.environment_metrics.relative_humidity);
|
msgPayload["relative_humidity"] = new JSONValue(decoded->variant.environment_metrics.relative_humidity);
|
||||||
}
|
}
|
||||||
if (decoded->variant.environment_metrics.has_barometric_pressure) {
|
if (decoded->variant.environment_metrics.has_barometric_pressure) {
|
||||||
msgPayload["barometric_pressure"] = new JSONValue(decoded->variant.environment_metrics.barometric_pressure);
|
msgPayload["barometric_pressure"] =
|
||||||
|
new JSONValue(decoded->variant.environment_metrics.barometric_pressure);
|
||||||
}
|
}
|
||||||
if (decoded->variant.environment_metrics.has_gas_resistance) {
|
if (decoded->variant.environment_metrics.has_gas_resistance) {
|
||||||
msgPayload["gas_resistance"] = new JSONValue(decoded->variant.environment_metrics.gas_resistance);
|
msgPayload["gas_resistance"] = new JSONValue(decoded->variant.environment_metrics.gas_resistance);
|
||||||
@ -125,13 +126,16 @@ std::string MeshPacketSerializer::JsonSerialize(const meshtastic_MeshPacket *mp,
|
|||||||
msgPayload["pm100"] = new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm100_standard);
|
msgPayload["pm100"] = new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm100_standard);
|
||||||
}
|
}
|
||||||
if (decoded->variant.air_quality_metrics.has_pm10_environmental) {
|
if (decoded->variant.air_quality_metrics.has_pm10_environmental) {
|
||||||
msgPayload["pm10_e"] = new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm10_environmental);
|
msgPayload["pm10_e"] =
|
||||||
|
new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm10_environmental);
|
||||||
}
|
}
|
||||||
if (decoded->variant.air_quality_metrics.has_pm25_environmental) {
|
if (decoded->variant.air_quality_metrics.has_pm25_environmental) {
|
||||||
msgPayload["pm25_e"] = new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm25_environmental);
|
msgPayload["pm25_e"] =
|
||||||
|
new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm25_environmental);
|
||||||
}
|
}
|
||||||
if (decoded->variant.air_quality_metrics.has_pm100_environmental) {
|
if (decoded->variant.air_quality_metrics.has_pm100_environmental) {
|
||||||
msgPayload["pm100_e"] = new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm100_environmental);
|
msgPayload["pm100_e"] =
|
||||||
|
new JSONValue((unsigned int)decoded->variant.air_quality_metrics.pm100_environmental);
|
||||||
}
|
}
|
||||||
} else if (decoded->which_variant == meshtastic_Telemetry_power_metrics_tag) {
|
} else if (decoded->which_variant == meshtastic_Telemetry_power_metrics_tag) {
|
||||||
if (decoded->variant.power_metrics.has_ch1_voltage) {
|
if (decoded->variant.power_metrics.has_ch1_voltage) {
|
||||||
|
@ -88,8 +88,8 @@ static const uint8_t A7 = PIN_A7;
|
|||||||
#define ADC_RESOLUTION 14
|
#define ADC_RESOLUTION 14
|
||||||
|
|
||||||
// Other pins
|
// Other pins
|
||||||
#define WB_I2C1_SDA (13) // SENSOR_SLOT IO_SLOT
|
#define WB_I2C1_SDA (13) // SENSOR_SLOT IO_SLOT
|
||||||
#define WB_I2C1_SCL (14) // SENSOR_SLOT IO_SLOT
|
#define WB_I2C1_SCL (14) // SENSOR_SLOT IO_SLOT
|
||||||
|
|
||||||
#define PIN_AREF (2)
|
#define PIN_AREF (2)
|
||||||
#define PIN_NFC1 (9)
|
#define PIN_NFC1 (9)
|
||||||
|
Loading…
Reference in New Issue
Block a user