Sample codes does not work with other sample code
viktak opened this issue · 5 comments
Describe the bug
when I combine sample code from https://wiki.seeedstudio.com/Wio-Terminal-LCD-Linecharts/ with other sample code (i.e. Checking the the RTL8720 Firmware Version in the Arduino Code - bottom of page), the chart stops displaying. This happens with any code that includes some of the WiFi related header files, such as rpcWiFi.h
.
To Reproduce
Steps to reproduce the behavior:
Combine the sample code at https://wiki.seeedstudio.com/Wio-Terminal-LCD-Linecharts/#complete-code with any code that includes rpcWiFi.h
.
Expected behavior
Both WiFi finctionality and LineChart functionality should work independently.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Windows 11 Pro 64
- Browser [not relevant]
- Version [not relevant]
- Editor VS Code with PlatformIO
Additional context
Here is a sample "combined" code I created:
//#include "includes.h"
#include <seeed_line_chart.h>
#include <rpcWiFi.h>
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() {
Serial.begin(115200);
while(!Serial); // wait till Serial is opened
Serial.printf("RTL8720 Firmware Version: %s", rpc_system_version());
tft.begin();
tft.setRotation(1);
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);
}
The problem in this case is caused by this line:
Serial.printf("RTL8720 Firmware Version: %s", rpc_system_version());
The problem goes away if you replace that line with this:
Serial.printf("Hello World!");
This suggests that Seeed_Arduino_Linechart
dies when a function is called in rpcWiFi.h
.
Any Updates? Same issue. When you try to use rpcWiFi.h the screen doesn't work. Just displays a grey screen with lines.
If you use the example "line chart" unmodified it works as expected. Just by adding #include <rpcWiFi.h>
to the top makes it not work/crash when it tries to run on the Wio Term.
How to replicate:
Open example line chart example
Add #include <rpcWiFi.h> to header
Compile & upload
I read in a forum (I can't recall where), that these libraries (linechart and wifi) are so large they don't fit the program memory at the same time. So I don't expect a quick solution for this... But I haven't given up hope yet.
Hello,
I also tried it and faced the same issues. The line charts do not work even with adding #include <rpcWiFi.h> only. Viktak is right. Seems like it should be fixed from the library itself.
@LynnL4 please help to look into this matter further.
Thank you.
Hi,
I've updated the library, using the cache is now optional, so it works with rpcWiFi, but it may display a little worse than using the cache, if you have any good ideas, feel free to submit pull rquest
Thank you @LynnL4
I have tested the latest example on my Wio Terminal with the addition of rpcWiFi library, and it works well now.
https://github.com/Seeed-Studio/Seeed_Arduino_Linechart/blob/dba04088587234e8ed46f180a94ed3ee97061838/examples/basic/basic.ino
I will close this issue for now. Anyone can reopen if further discussions are needed.