Hey guys.
I'm trying to add a function to a library for I2C LCD controller.
Now, there are two functions for writing on LCD: for printing strings and for printing single chars, but none for printing integers or decimal numbers. I know, that I can convert integers with command itoa to strings, but I would like to implement function for printing them directly, if possible.
For printing chars and strings, here is the code from lib:
BV4618.cpp:
// sends char
void BV4618::print(char c){
Wire.beginTransmission(_i2adr);
Wire.send(c);
Wire.endTransmission();
}
// sends string
void BV4618::print(char *s){
char *sp=s;
Wire.beginTransmission(_i2adr);
// send *s as bytes of date
while(*sp)
Wire.send(*(sp++));
Wire.endTransmission();
}
BV4618.h:
void print(char c);
void print(char *s);
For printing integers, I tried to use code from Print.h and changed it a bit
BV4618.cpp:
void BV4618::print(int n){
Wire.beginTransmission(_i2adr);
Wire.send(n);
Wire.endTransmission();
}
BV4618.h:
void print(int n);
but that doesn't work
Any help from more experienced coders would be much appreciated.
Thank you in advance.