extending the Serial Class? (C++ general que
so in c++, can write code extends class, right? so in theory write serial.print method extends existing code accept new argument types, float or prog_char[] (string in flash)? like? (the c++ wrapper extend class floats, not internal code print float.)
thanks
bill w
thanks
bill w
bill, easy do. class definition in hardwareserial.h , looks this:
to extend class, add new methods in puplic section, have added 1 floats @ bottom.
then write method in hardwareserial.cpp following style of exisiting methods.
void hardwareserial::print(float n)
{
// code here
}
code: [select]
class hardwareserial
{
private:
//uint8_t _uart;
void printnumber(unsigned long, uint8_t);
public:
hardwareserial(uint8_t);
void begin(long);
uint8_t available(void);
int read(void);
void flush(void);
void print(char);
void print(const char[]);
void print(uint8_t);
void print(int);
void print(unsigned int);
void print(long);
void print(unsigned long);
void print(long, int);
void println(void);
void println(char);
void println(const char[]);
void println(uint8_t);
void println(int);
void println(long);
void println(unsigned long);
void println(long, int);
void print(float); // add print method floats
};to extend class, add new methods in puplic section, have added 1 floats @ bottom.
then write method in hardwareserial.cpp following style of exisiting methods.
void hardwareserial::print(float n)
{
// code here
}
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > extending the Serial Class? (C++ general que
arduino
Comments
Post a Comment