timmbogner / Farm-Data-Relay-System

A system that uses ESP-NOW, LoRa, and other protocols to transport sensor data in remote areas without relying on WiFi.
MIT License
485 stars 108 forks source link

Add ability for debug output to not have a newline or debug with newline #63

Closed aviateur17 closed 1 year ago

aviateur17 commented 1 year ago

Changed DBG -> DBGLN and added new #define DBG that does not generate a newline. Gives developers ability to output different types of data on the same line instead of generating a new line each time.

aviateur17 commented 1 year ago

I guess this really isn't needed. Can use existing DBG with concatenation and String().

Example: DBG("Incoming LoRa. RSSI: " + String(LoRa.packetRssi()) + " SNR: " + String(LoRa.packetSnr()));

I hadn't reviewed everything in the project before making this change. I actually prefer to use printf() or ESP LOGx() functions but that would be a big change so I don't suggest that at this point. We can probably reject this PR.

timmbogner commented 1 year ago

I agree that it's not needed currently. The spirit of DBG() is to not obscure the code very much, but this change would encourage more lines of debug code to be added. It may be worth looking into whether the String() concatenation method is the best one. I started using it a while ago, but don't often see it used elsewhere. I think I saw someone using sprintf(), which is maybe more dev-approved.

aviateur17 commented 1 year ago

Probably not high priority. When I write code for microprocessors I always have memory conservation in mind. String class seems to use up a lot of memory (probably not a concern with ESP32) and has had reports of memory leaks. Therefore I try to use what Espressif has provided LOGx() or C printf(). String() does make manipulation easy though.