I have one error with linker
I try compile and link a new library, Three files .cpp. .h and .ino.......but I have a liker error.
I dont understand why if the next code link ok
Code: [Select]
void setup() {
// put your setup code here, to run once:
}
int i;
float j;
unsigned long tiempo_old;
void loop() {
// put your main code here, to run repeatedly:
dato(i,2000);
i++;
dato(j,1000);
}
template <typename tipo>
void dato(tipo& dat, int tiempo)
{
if (millis() > (tiempo_old + tiempo))
{
Serial.print(dat);
tiempo_old = millis();
}
}
This one compile and link ok
But if I try compile next code, in three files, one .cpp, .h and .ino, because is a part of a new library...
This is .cpp
Code: [Select]
template <typename tipo>
void V_DATOS::dato(tipo& dat, int tiempo)
{
if (millis() > (tiempo_old + tiempo))
{
Serial.print(dat);
tiempo_old = millis();
}
}
Tis is .h
Code: [Select]
class V_DATOS
{
public:
V_DATOS(MCUFRIEND_kbv* prtTFT, TouchScreen* TouchScreen,TECLADO* Teclado);
void ventana(int x, int y, int tipo_variable,int num_digitos,int tipo_marco, uint16_t f_col, uint16_t t_col);
template <typename tipo>
void dato(tipo& dat, int tiempo);
float introducir_dato(float dat);
int introducir_dato(int dat);
private:
int pos_x;
int pos_y;
int pixel_x;
int pixel_y;
int tamano_x, tamano_y;
int tamano_letra;
uint16_t f_color, t_color;
int tip_var;
int digitos;
unsigned long tiempo_old;
bool teclado_on;
bool Touch_getXY(void);
protected:
MCUFRIEND_kbv* _tft; // nuevo denominacion del puntero para esta libreria
TouchScreen* _ts; // denminacion de puntero para la tactil
TECLADO* _teclado;
};
I have the next link error
[color=#222222]ERROR[/color]
[color=#222222]Compiling 'Ejemplo_Ventana_Datos_MCUFRIEND' for 'ATmega2560 (Mega 2560) (Arduino Mega)'[/color]
[color=#222222]cc6kmpQU.ltrans0.ltrans.o*: In function main[/color]
[color=#222222]Error linking for board ATmega2560 (Mega 2560) (Arduino Mega)[/color]
[color=#222222]Build failed for project 'Ejemplo_Ventana_Datos_MCUFRIEND'[/color]
[color=#222222](.text.startup+0xc08): undefined reference to void V_DATOS::dato<float>(float&, int)[/color]
[color=#222222]collect2.exe*: error: ld returned 1 exit status[/color]
.ino
vent_datos_2.dato(dato_f,500);
If I write the code and declare like float and not template types the compiler make it good
The function in .ino do anything, is only a trial....
Excuse my bad english....How can I link this good? Where is my mistake?
Thank you so much