I could not get this working, but while doing a bit more of a dig through the LCD libary, I found the following files...
print.h and print.cpp
How can I implement them as they have all the hard work done of detecting if it is a float, or a int or whatever?
I know I have to use
include print.h
but how can I tie that into a function for now, and then into a libary?
The section of the LCD libary I can find that does this is as below:
class LiquidCrystal : public Print {
public:
LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
LiquidCrystal(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
void clear();
void home();
void noDisplay();
void display();
void noBlink();
void blink();
void noCursor();
void cursor();
void scrollDisplayLeft();
void scrollDisplayRight();
void leftToRight();
void rightToLeft();
void autoscroll();
void noAutoscroll();
void createChar(uint8_t, uint8_t[]);
void setCursor(uint8_t, uint8_t);
virtual size_t write(uint8_t);
void command(uint8_t);
using Print::write;
private:
void send(uint8_t, uint8_t);
void write4bits(uint8_t);
void write8bits(uint8_t);
void pulseEnable();
uint8_t _rs_pin; // LOW: command. HIGH: character.
uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD.
uint8_t _enable_pin; // activated by a HIGH pulse.
uint8_t _data_pins[8];
uint8_t _displayfunction;
uint8_t _displaycontrol;
uint8_t _displaymode;
uint8_t _initialized;
uint8_t _numlines,_currline;
};
I just dont get how I can make this / the stuff in print.h and print.cpp take what is given to it and format it to an 8 char string to display
in essance I wnat to be able to do this
//pins to use
//a0 - temp pin
//a4 a5 - I2C bus
//d3 - mode button
int tempPin = A0;
int modeBtn = 3;
void setup() {
//pinmodes
pinMode(tempPin, INPUT);
pinMode(modeBtn, INPUT);
//perform i2c Max6955 initilsation here
}
void loop() {
float temp = temp();
maxPrint(temp);
delay(1000);
}
void temp() {
//get the temp from tmp36
float temp = 13.42;
return temp;
}
void maxPrint(any_var_type, what_to_print) {
//collect to string
//now parse the string to seperate into chars
//and store in variables
//and finally send over i2c bus
}
but what I wnat to send may be floats, strings, or other var types.
I can do it on LCDs so I know it is possible, but not sure how to implement it.
Any help is aprechiated.
Jimmy