So, whose code is the function?void formatFreq() in the V6?
Recognition to Jack for code size reduction by removal of? sprintf, but where is the correct place to discuss a potential improvement?
IMO, it's also posting 'simple stuff' to this group so active folks can grab it and have a look too.?
I'm not a real c coder, but I have a lot of code that I know has holes when used outside the intended purpose. Much as formatFreq() below 1 MHz.
The real coders are working on bigger issues, but since I was thinking about it:
I scratched out a change that addresses the 'feature' / comments about tuning below 1 MHz. (which is outside of the TX operating range, so IMO nothing to complain about)
Keeping in the spirit, it should actually use less program space.? I don't have a V6 / TFT to test.? It's really just a replacement of an if/else with a for loop.? So yes, it will be slightly slower.
My version will have a 'bug' below 100 Hz.? So the ULF guys will still complain.? This is just hobby stuff for me.? Sometimes longer to write a post than to actually do work.
void formatFreq(long f, char *buff) {
? // tks Jack Purdum W8TEE
? // replaced fsprint commmands by str commands for code size reduction
? // AG5TX
? // resolved issue with format below 1 MHz, there is an issue below 100 Hz but trying to keep code size small and simple
? unsigned int g = strlen(b);
?
? memset(buff, 0, 10);??
? memset(b, 0, sizeof(b)); // b is a global
?
? ultoa(f, b, DEC);
?
? for (unsigned int i = g; i < 8 ; i++){
? ? ?strcat(buff, " ");
? }
?
? strncat(buff, b, g-3);
? strcat(buff, ".");
? strncat(buff, &b[g-3], 2); // set last arg to 2 or 3 for how many digits you want right of the decimal point.
}