ming.py
ESP32 字量極限字庫
| ESP32
| MicroPython
PaoyungJun 15, 2022
ℳ𝒾𝒸𝓇ℴ𝒫𝓎𝓉𝒽ℴ𝓃 隨手記Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
相關主題 👉 微控制器上字庫的選擇
在玩轉了幾回陳大 ming.py
後,突然想起之前的某個 POC 要顯示台灣 368 個行政區名稱和郵遞區號,本來打算要用 SSD1306 來顯示中文,但因為不想把手上僅剩不多的字庫 IC 給出去,索性將其換成 LCD1602,中文就轉成拼音(pinyin)。而現在有了字庫檔,於是重新思考該如何將其應用在類似的需求上了。
使用字庫時需留意其授權之使用範圍,並依規定使用。
明體中文字庫前情提要: 陳大的 ming.py 試玩筆記 | 陳大的 ming.py 試完筆記
首先要考量的是台灣 368 行政區加上郵遞區號會用上多少字呢? 出乎意料的只有 326 個字,加上額外的英文、數字及符號也才 388 個 ,於是馬上做出字庫檔來試試看。
載入字檔 OK、上網也正常,這結果真是令人興奮,即代表之前的 POC 使用這個字庫檔是可以勝任的。但同時也再萌生了另一個想法,即 ESP32 可以載入的字量極限是多少呢?
為方便測試可達字量,除了上述的台灣 368 字檔外,另外製作了不同字量的字庫檔以利測試,字檔內容以台灣 368 為基底,再從教育部 4808 常用字中隨機抽取以補足至設定之字量。測試程序如下:
使用 ESP32 + MicroPython v1.18。
輸出之字庫檔有經過再處理,請參閱 陳大的 ming.py 試玩筆記。
功能正常Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
失敗Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
未測Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
字量 | 載入字庫 | 連上 WiFi | 網站A | 網站B | SSD1306 |
---|---|---|---|---|---|
台灣368 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
500 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
1000 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
1500 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
此回合的重點在於找出大概的區間,於 1500 字時載入即以記憶體不足之錯誤訊息作收。而在 1000 字時尚能瀏覽少量資料的網站,但當訪問到環保署 OpenData 之類較多資料的網站時也已招架不住,故下回合要往下做調整。
字量 | 載入字庫 | 連上 WiFi | 網站A | 網站B | SSD1306 |
---|---|---|---|---|---|
950 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
960 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
975 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
第二回合 600 至 900 的區段皆通過測試,直至 950 左右才出現分岐點,最後測得安全的字量落在 950~960 左右,代表若有較多記憶體的需求,則需酙酌字數的調整,但整體來說,已能滿足一般的應用。
常見的ESP32
ESP32 with SPIRAM
由上可輕易的看出兩者之間記憶體有明顯的差別,而這回合要試探具備 SPIRAM 的 ESP32 能承受的字量又是多少呢?
字量 | 載入字庫 | 連上 WiFi | 網站A | 網站B | SSD1306 |
---|---|---|---|---|---|
1000 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
2000 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
3000 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
4000 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
4903 |
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
Image Not Showing
Possible Reasons
|
字量 4903 字庫為教育部 4808 常用字加上英數字符號 95 個集合所成。
看起來很完美吧!至此已經達到非常驚人的字數量
字庫檔 | 台灣368 | 1000 | 2000 | 3000 | 4000 | 4903 |
---|---|---|---|---|---|---|
秒數 | 0.8 | 2.4 | 6.4 | 11.7 | 18.3 | 25.5 |
秒數為手按碼表測得之數據,非精確數值,僅供參考。
對於擁有大容量的 ESP32 來說,字庫檔不失為一個在有限字量需求下解決中文顯示的好方法,雖然 WROVER 版本的 ESP32 能夠承載更多的字量,但執行速度的損耗使其並不具備絕對的優勢,亦或使用字庫 IC 更能取得平衡而達到較好的使用者體驗,希望本篇內容對有字庫需求的同好在進行評估時能有一些幫助。
使用字庫時需留意其授權之使用範圍,並依規定使用。