#include <U8g2lib.h>
#include <stdio.h>
#include <Wire.h>
#include "ArduinoJson.h"
#include "u8g2_wqy.h"
#define READ 2
#define BTN0 4
#define BTN1 5
#define BTN2 18
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* clock=*/ 22, /* data=*/ 21); // ESP32 Thing, pure SW emulated I2C
void setup() {
Serial.begin(115200);
//Wire.begin(21,22,400000);
pinMode(BTN0, INPUT_PULLUP);
pinMode(BTN1, INPUT_PULLUP);
pinMode(BTN2, INPUT_PULLUP);
u8g2.setBusClock(800000);
u8g2.begin();
u8g2.setFont(chinese_gb2312);
u8g2.enableUTF8Print(); // 开启UTF8字符功能
u8g2.setContrast(10);
u8g2.clearBuffer();
DynamicJsonDocument doc_summary(2048);
for(int i=0;i<50;i++){
JsonArray arr_summary = doc_summary.to<JsonArray>();
JsonObject tmp;
tmp = arr_summary.createNestedObject();
tmp["N"] = "<<返回";
tmp["V"] = "<<返回";
tmp = arr_summary.createNestedObject();
tmp["N"] = "全部";
tmp["V"] = "符数组字符串更难以使用您可能需要编存";
tmp = arr_summary.createNestedObject();
tmp["N"] = "未分类";
tmp["V"] = "未分类[123]";
tmp = arr_summary.createNestedObject();
tmp["N"] = "邮件";
tmp["V"] = "邮件[123]邮件[123]邮件[123]邮件[123]邮件[123]邮件[123]";
tmp = arr_summary.createNestedObject();
tmp["N"] = "银行";
tmp["V"] = "银行[123]";
tmp = arr_summary.createNestedObject();
tmp["N"] = "门户网站";
tmp["V"] = "门户网站[123]";
tmp = arr_summary.createNestedObject();
tmp["N"] = "通讯工具";
tmp["V"] = "通讯工具[123]";
int width=u8g2.getUTF8Width(doc_summary.as<JsonArray>()[1]["V"]);
Serial.println(width);
// String str = "";
// for(int i=1;i<50;i++){
// str+="中";
// Serial.print(i);
// Serial.print(" 字符 ");
// Serial.println(u8g2.getUTF8Width(str.c_str()));
// }
}
u8g2.sendBuffer();
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}