Looking a little like a VFO

Debugging the format of the frequency display.  Nano + I2C 20x4 LCD + encoder

Debugging the format of the frequency display.  Nano + I2C 20x4 LCD + encoder

It took me a while to figure it out. I was having a hard time trying to convert a long unsigned integer (10000000) into something that looked like a typical frequency display (10,000,000).  Since I am not a C/C++ guru it took me a while to figure it out.

I came up with four potential approaches. Ultimately it came down to figuring out how to make the sprintf command work properly on the Arduino. It is a very powerful command assuming that you understand the arguments that you need to use. There are lots of references for standard PC platforms but not all of that is implemented in the library for the Arduino. I did most of my reading and experimenting saturday night and then came back at it with a fresh mind and point of view Sunday afternoon once my errands were complete for the day.

With a fresh mind it only took me about 10 minutes to bang out some code that worked. The only real challenge was the argument for the data type conversion. As time permits I will need to come back to this and trim down the code as I think that I can make it a bit more lean.

  char buf2[10];
  sprintf(buf2,"%1c%1c,%1c%1c%1c,%1c%1c%1c", buf1[0], buf1[1], buf1[2], buf1[3], buf1[4], buf1[5], buf1[6], buf1[7], buf1[8]);

It is not glamorous but it works.  This is a pretty basic and important part of the VFO so it was an important step for me. I have a couple more items that I want to add to this and then I can move to the DDS code.

73 de NG0R