dhiltonp / hexbright

The easiest way to start programming your hexbright.
BSD 2-Clause "Simplified" License
124 stars 114 forks source link

Replace Serial with Debug? #46

Open joshgoebel opened 10 years ago

joshgoebel commented 10 years ago

What if we changed...

#ifdef FREE_RAM
  Serial.print("Ram available: ");
  Serial.print(freeRam());
  Serial.println("/1024 bytes");
#endif

to

#ifdef FREE_RAM
  Debug.print("Ram available: ");
  Debug.print(freeRam());
  Debug.println("/1024 bytes");
#endif

A new Debug object could be introduced that checked for charge_state of BATTERY and if the user isn't plugged into USB all the serial statements short-circuit without wasting any time... and if it is plugged in then Serial.whatever runs as it usually would. The call overhead would be nothing compared to the Serial overhead itself.

Would that help?

dhiltonp commented 10 years ago

That would be quite nice from a run-time perspective. It wouldn't do anything for the string consumption of flash/ram, of course.

It's definitely worth considering.

joshgoebel commented 10 years ago

Right, if they don't turn them off in the compile it's about the best you could do.