Seeed-Studio / Seeed_Arduino_Linechart

This library is a very lightweight library which can help you with the linechart graph you need.
MIT License
6 stars 7 forks source link

GET ERROR: no matching function for call to 'text::font_height()' #12

Closed johncaipa closed 2 years ago

johncaipa commented 2 years ago

Describe the bug Hi, i get this error when compile the example code: no matching function for call to 'text::font_height()', what i can do?

To Reproduce WIO Terminal D51R Arduino IDE 1.8.13 WIN 10

johncaipa commented 2 years ago

Sorry, I found the problem,

here the original code of the Seed Wiki:



#include"seeed_line_chart.h" //include the library
TFT_eSPI tft;
 
#define max_size 50 //maximum size of data
doubles data; //Initilising a doubles type to store data
TFT_eSprite spr = TFT_eSprite(&tft);  // Sprite
 
void setup() {
tft.begin();
tft.setRotation(3);
spr.createSprite(TFT_HEIGHT,TFT_WIDTH);
}
 
void loop() {
spr.fillSprite(TFT_WHITE);
if (data.size() == max_size) {
data.pop();//this is used to remove the first read variable
}
data.push(0.01 * random(1, 10)); //read variables and store in data
 
//Settings for the line graph title
auto header =  text(0, 0)
.value("test")
.align(center)
.valign(vcenter)
.width(tft.width())
.thickness(3);
 
header.height(header.font_height() * 2);
header.draw(); //Header height is the twice the height of the font
 
//Settings for the line graph
auto content = line_chart(20, header.height()); //(x,y) where the line graph begins
content
.height(tft.height() - header.height() * 1.5) //actual height of the line chart
.width(tft.width() - content.x() * 2) //actual width of the line chart
.based_on(0.0) //Starting point of y-axis, must be a float
.show_circle(false) //drawing a cirle at each point, default is on.
.value(data) //passing through the data to line graph
.color(TFT_PURPLE) //Setting the color for the line
.draw();
 
spr.pushSprite(0, 0);
delay(50);
}

and the code that modified:


#include"seeed_line_chart.h" //include the library
TFT_eSPI tft;

#define MAX_SIZE 50 //maximum size of data
doubles data; //Initilising a doubles type to store data
TFT_eSprite spr = TFT_eSprite(&tft);  // Sprite 

void setup() {
    tft.begin();
    tft.setRotation(3);
    spr.createSprite(TFT_HEIGHT,TFT_WIDTH);
    spr.setRotation(3);
}

void loop() {
    spr.fillSprite(TFT_WHITE);
    if (data.size() > MAX_SIZE) {
        data.pop();//this is used to remove the first read variable
    }
    data.push(0.01 * random(1, 10)); //read variables and store in data

    //Settings for the line graph title
    auto header =  text(0, 0)
                .value("test")
                .align(center)
                .valign(vcenter)
                .width(tft.width())
                .thickness(3);

    header.height(header.font_height(&spr) * 2);
    header.draw(&spr); //Header height is the twice the height of the font

  //Settings for the line graph
    auto content = line_chart(20, header.height()); //(x,y) where the line graph begins
         content
                .height(tft.height() - header.height() * 1.5) //actual height of the line chart
                .width(tft.width() - content.x() * 2) //actual width of the line chart
                .based_on(0.0) //Starting point of y-axis, must be a float
                .show_circle(false) //drawing a cirle at each point, default is on.
                .value(data) //passing through the data to line graph
                .max_size(MAX_SIZE)
                .color(TFT_RED) //Setting the color for the line
                .backgroud(TFT_WHITE)
                .draw(&spr);

    spr.pushSprite(0, 0);
    delay(50);
}
lakshanthad commented 2 years ago

Hello,

I will update the codes on the wiki accordingly. Please follow the codes available on GitHub always, because GitHub codes will be updated at first and then the wiki will be synced according to that.

Thank you.

hanscees commented 1 year ago

I really dont understand this. It is now december 2022 I get the same error when using github here: https://github.com/lakshanthad/Wio_Terminal_Classroom_Arduino/blob/main/Classroom%205/Line_Charts/Line_Charts.ino

why?

hanscees commented 1 year ago

Error is still in the github library today here: https://github.com/lakshanthad/Wio_Terminal_Classroom_Arduino/blob/main/Classroom%205/Line_Charts/Line_Charts.ino

ujur007 commented 1 year ago

Still, the wiki is not updated fortunately, I found the error solution.