smalldesktopdisplay-team / smalldesktopdisplay Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU Affero General Public License v3.0
License: GNU Affero General Public License v3.0
我在使用该项目扩展编程的过程中遇到问题是这样的,初始heap区域(RAM除去.bss与.data)有40KB左右可使用,但是我在继续添加我的代码发现总是重启。
跟着代码跑了一遍并使用`system_get_free_heap_size`打印heap,发现有个函数会导致heap区域枯竭,并且随后的字体加载程序会使用`malloc`函数获取内存,且该`malloc`操作不做任何检查空指针,随机使用空指针去赋值,导致控制在操作错误。
SmallDesktopDisplay.cpp->void setup()->getCityWeater()->:
if (httpCode == HTTP_CODE_OK)
{
....
weaterData(&jsonCityDZ, &jsonDataSK, &jsonFC);
....
}
weaterData()->clk.loadFont(ZdyLwFont_20)->loadFont("", false);->loadMetrics();->gxAdvance[gNum] = (uint8_t)readInt32(); // xAdvance - to move x cursor
由于上面代码:gxAdvance = (uint8_t*)malloc( gFont.gCount ); // xAdvance - to move x cursor
这里并没有申请成功,使得 &gxAdvance = NULL。那么就是NULL被赋值,导致错误。
// 获取城市天气
void getCityWeater()
{
heapa=23920
// String URL = "http://d1.weather.com.cn/dingzhi/" + cityCode + ".html?_="+String(now());//新
String URL = "http://d1.weather.com.cn/weather_index/" + cityCode + ".html?_=" + String(now()); //原来
//创建 HTTPClient 对象
HTTPClient httpClient;
heapa=23808
...............
//如果服务器响应OK则从服务器获取响应体信息并通过串口输出
if (httpCode == HTTP_CODE_OK)
{
heapa=22856
String str = httpClient.getString();
int indexStart = str.indexOf("weatherinfo\":");
int indexEnd = str.indexOf("};var alarmDZ");
heapa=5424
.....
heapa=4568
Serial.printf( "heapa size:%u\r\n", system_get_free_heap_size());
weaterData(&jsonCityDZ, &jsonDataSK, &jsonFC);
Serial.println("获取成功");
}
...............
}
可以看到由于str变量获取的网页回应导致大量的heap被占用,且未被释放就进入了下一个高内存消耗的函数weaterData
.
这里建议:str.~String();
放在weaterData(&jsonCityDZ, &jsonDataSK, &jsonFC);
前
设定时间到达后并没有调用天气更新api
你好,我最近在复刻该项目,但是遇到了字库缺字的问题,具体是我所在的城市名称不在字库中。我注意到了《如何制作字库》这个教程,但是用GB2312的3000多个常用字生成的字库编译出来要占2M flash。我先是尝试修改linkscript,让程序正常编译和链接,最后生成的2M bin文件下载到设备上后无法执行。后来了解到ESP8266的程序执行空间IROM在内存的映射中只有1M,也就是说,程序最大只能1M我该链接脚本也无济于事。
最后回到了如何在现有字库上增加少量特殊字的问题,所以想咨询你一下,代码中的ZdyLwFont_20字库是基于那些字生成的,如果可以的话,希望得到你这份字库的所有字符。非常感谢!
我在
SmallDesktopDisplay
这个仓库中也提交了同样的请求,但是我不知道你们这个项目组和这个人的关系。
1737 reflash_openWifi.onRun(refresh_AnimatedImage); 改为 reflash_Animate.onRun(refresh_AnimatedImage); 即可
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.