If a custom board template is entered in the configuration, then ConfigManager::getBoardConfig() calls ConfigManager::parseBoardTemplate() to parse it using ArduinoJson, which is fairly expensive.
But it turns out getBoardConfig() is called a lot. Specifically, checkButton() calls it every time to discover the button pin, and checkButton() is called repeatedly in the main loop.
I set and cleared a GPIO pin inside parseBoardTemplate() and viewed it with a logic analyser. I measured parseBoardTemplate() being called 300 times per second and taking about 380us each time, consuming about 11% of the total CPU power.
It would be better if getBoardConfig() called parseBoardTemplate() once and cached the result.
If a custom board template is entered in the configuration, then
ConfigManager::getBoardConfig()
callsConfigManager::parseBoardTemplate()
to parse it using ArduinoJson, which is fairly expensive.But it turns out
getBoardConfig()
is called a lot. Specifically,checkButton()
calls it every time to discover the button pin, andcheckButton()
is called repeatedly in the main loop.I set and cleared a GPIO pin inside
parseBoardTemplate()
and viewed it with a logic analyser. I measuredparseBoardTemplate()
being called 300 times per second and taking about 380us each time, consuming about 11% of the total CPU power.It would be better if
getBoardConfig()
calledparseBoardTemplate()
once and cached the result.