melkati / CO2-Gadget

An advanced CO2 Monitor/Meter firmware for ESP32 with Android and iOS App for real time visualization and charting of air data, data logger, a variety of communication options (BLE, WIFI, MQTT, ESP-Now) and many supported sensors.
https://emariete.com/medidor-co2-gadget/
GNU General Public License v3.0
63 stars 13 forks source link

Slow down after swapping between battery and external power #185

Closed melkati closed 7 months ago

melkati commented 7 months ago

To reproduce:

I make sure nothing is connected to CO2 Gadget from the PC (platformio connects automatically if the terminal is open) and:

  1. I restart CO2 Gadget on battery and it works.
  2. I connect via USB and it starts to work poorly.
  3. I restart CO2 Gadget from the hardware button (the PC makes a double sound, like it stops detecting it and detects it again) and it works fine again.

It appears like the menu system is working extremely slow (around 5-15 seconds to respond to a button press). Really everything is working extremely slow.

melkati commented 7 months ago

looks like the issue is related to the serial port TX filling and slowing down on new data.

If I avoid writing the menu to serial port, it works fine.

To do so, modify this line:

https://github.com/melkati/CO2-Gadget/blob/3c7363ae7a0a3c47a3d01049ce11fc4b9dff820a/CO2_Gadget_Menu.h#L921

As:

menuOut *constMEM outputs[] MEMMODE = {&eSpiOut};

melkati commented 7 months ago

If serial communication does not start after boot (because there was never a serial port) it does not happen. It's only when you remove the serial port after it's receiving data.

melkati commented 7 months ago

I implemented some fixes on v.0.12.006-beta #186

@Coscolin already tested the fix. Looks like it's working fine.

Available on web installer at https://emariete.com/en/co2-meter-gadget/#CO2_Gadget_Version_Beta-Desarrollo until it's merged into master and a new release published (after some feedback from users have been received).