Hello,
I noticed that the Arduino IDE would issue the following warning when I opened my project containing Adafruit_INA219.cpp:
"Adafruit_INA219.cpp" contains unrecognized characters. If this code was created with an older version of Arduino, you may need to use Tools -> Fix Encoding & Reload to update the sketch to use UTF-8 encoding. If not, you may need to delete the bad characters to get rid of this warning.
The suggested fix did not make a difference (Arudino IDE 1.8.11), so I did some poking around. I wanted to let you know what I found, and then you can decide if you want to make a change or not.
First, I noticed the encoding of the two library files are different (this isn't strictly a problem):
$ file Adafruit_INA219.cpp Adafruit_INA219.h
Adafruit_INA219.cpp: c program text, UTF-8 Unicode text
Adafruit_INA219.h: C++ source text, ASCII text
Next I used iconv
(MacOS 10.14.6, GNU libiconv 1.11) to convert Adafruit_INA219.cpp
to a new ASCII file, discarding unrecognized character(s) in the process:
iconv -c -f UTF8 -t ASCII Adafruit_INA219.cpp > Adafruit_INA219.cpp.fixed
That let me diff the original and .fixed
files to reveal the unrecognized characters. I think it's the character 'mu', used for for micro watts/micro amps. I found 5 instances of the character:
|
* unit of power corresponds to 800�W. Counter overflow occurs at |
|
// MinimumLSB = 0.0000305 (30.5�A per bit) |
|
// MaximumLSB = 0.000244 (244�A per bit) |
|
// CurrentLSB = 0.0000400 (40�A per bit) |
|
// PowerLSB = 0.0008 (800�W per bit) |
There are lots of different types of 'mu' in UTF-8 (https://en.wikipedia.org/wiki/Mu_(letter)#Character_encodings). So in my case, I just replaced these instances with US-ASCII lower case 'u' instead, and Arduino stopped complaining after that:
iconv --unicode-subst=u -f UTF8 -t ASCII Adafruit_INA219.cpp > Adafruit_INA219.cpp.fixed && mv Adafruit_INA219.cpp.fixed Adafruit_INA219.cpp
Fortunately the unrecognized character was in comments only, so the code compiled fine, but that error message could throw off new users.
Thanks for the awesome breakout board and library!