用行矩阵填充 char[] 并遍历所有行
Filling char[] with row matrix and loop over all rows
我想打印我的 Mag
数组。当前 API 我只能使用 ESP_LOGI
按行打印。所以我必须填充一行字符串(char[])并循环显示:
//char s[2 * (w - 2 * window - 1)];
char[200];
char s_tmp[4]; //one element of array string
for(int i=window; i<=w-window;++i){
memset(s, 0, sizeof(s));
memset(s_tmp, 0, sizeof(s_tmp)); // Fill with [=10=] for ESP_LOGI
for(int j=window; j<h-window;++j){
sprintf(s_tmp, "%u", Mag[i + j * w]);
strcat(s, s_tmp);
strcat(s, ".");
}
ESP_LOGI(TAG,"%s", s);
}
}
输出:
使用 VScode platformIO
读取串行输出
尺寸 = (h=28, w=28)
window = 3
I (13793) camera_httpd: 0.0.0.2.1.1.1.0.0.1.0.2.1.0.0.0.1.0.2.0.0.1. m
I (13793) camera_httpd: 0.0.1.0.4.1.1.1.0.1.2.0.2.1.0.0.0.1.0.1.2.0.
I (13793) camera_httpd: 0.0.0.1.1.0.1.1.0.0.1.0.0.0.1.0.0.2.1.1.0.0. [0m
I (13803) camera_htt pd: 0.0.0.0.0.0.0.1.1.1.0.1.0.0.0.1.0.0.2.2.1.1.
I (13813) camera_httpd: 0.0.0.1.0.0.0.1.1.1.0.0.1.0.0.0.0.0.0.2.1.1.
I (13823) camera_httpd: 0.0.0.0.1.0.0.0.0.0.1.1.1. 1.0.0.0.0.1.0.2.2.
I (13823) camera_httpd: 0.0.0.0.2.1.0.0.0.0.0.0.1.0.0.0.1.0.0.1.0.2.
I (13833) camera_httpd: 1.0.0.0.1.0.1.0.0.0.0.0. 0.1.0.0.0.0.0.0.1.0.
I (13843) camera_httpd: 0.1.0.0.0.1.0.0.0.0.0.1.0.0.0.0.1.0.0.0.0.0.
我想知道为什么会显示space。我猜这些来自我的 memset(0)。
他们有更好的方法吗?
这与platformIO extension VScode terminal有关,它不能很好地处理特殊的shell控制字符来改变线条的颜色。
从 PuTTY:
读取的串行输出
I (42273) camera_httpd: 0.0.0.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.
I (42273) camera_httpd: 0.0.0.0.0.1.0.0.1.0.0.0.0.0.0.0.0.0.0.0.1.1.
I (42283) camera_httpd: 0.0.0.0.1.0.1.1.0.1.0.0.1.0.0.0.0.0.0.0.0.1.
I (42293) camera_httpd: 0.0.0.0.4.1.1.1.1.1.1.0.1.0.0.0.0.0.0.1.0.0.
I (42293) camera_httpd: 0.0.0.1.0.1.1.1.1.1.1.1.1.0.0.0.0.0.0.0.0.1.
I (42303) camera_httpd: 0.0.0.0.1.1.1.1.1.1.1.1.1.1.0.1.0.0.1.0.0.1.
I (42313) camera_httpd: 0.0.0.0.3.1.1.1.1.1.1.0.1.1.0.0.0.0.1.0.1.0.
I (42323) camera_httpd: 0.0.0.1.0.1.1.1.1.1.1.1.1.0.1.0.0.0.0.0.1.0.
I (42323) camera_httpd: 0.0.0.0.1.0.1.1.1.1.1.1.1.0.0.1.0.0.0.1.0.1.
I (42333) camera_httpd: 0.5.1.1.3.1.0.1.1.1.1.1.1.1.1.0.0.0.0.0.0.0.
I (42343) camera_httpd: 0.0.0.1.1.0.1.0.0.1.1.0.1.0.0.0.0.0.0.0.0.0.
我想打印我的 Mag
数组。当前 API 我只能使用 ESP_LOGI
按行打印。所以我必须填充一行字符串(char[])并循环显示:
//char s[2 * (w - 2 * window - 1)];
char[200];
char s_tmp[4]; //one element of array string
for(int i=window; i<=w-window;++i){
memset(s, 0, sizeof(s));
memset(s_tmp, 0, sizeof(s_tmp)); // Fill with [=10=] for ESP_LOGI
for(int j=window; j<h-window;++j){
sprintf(s_tmp, "%u", Mag[i + j * w]);
strcat(s, s_tmp);
strcat(s, ".");
}
ESP_LOGI(TAG,"%s", s);
}
}
输出: 使用 VScode platformIO
读取串行输出尺寸 = (h=28, w=28) window = 3
I (13793) camera_httpd: 0.0.0.2.1.1.1.0.0.1.0.2.1.0.0.0.1.0.2.0.0.1. m
I (13793) camera_httpd: 0.0.1.0.4.1.1.1.0.1.2.0.2.1.0.0.0.1.0.1.2.0.
I (13793) camera_httpd: 0.0.0.1.1.0.1.1.0.0.1.0.0.0.1.0.0.2.1.1.0.0. [0m
I (13803) camera_htt pd: 0.0.0.0.0.0.0.1.1.1.0.1.0.0.0.1.0.0.2.2.1.1.
I (13813) camera_httpd: 0.0.0.1.0.0.0.1.1.1.0.0.1.0.0.0.0.0.0.2.1.1.
I (13823) camera_httpd: 0.0.0.0.1.0.0.0.0.0.1.1.1. 1.0.0.0.0.1.0.2.2.
I (13823) camera_httpd: 0.0.0.0.2.1.0.0.0.0.0.0.1.0.0.0.1.0.0.1.0.2.
I (13833) camera_httpd: 1.0.0.0.1.0.1.0.0.0.0.0. 0.1.0.0.0.0.0.0.1.0.
I (13843) camera_httpd: 0.1.0.0.0.1.0.0.0.0.0.1.0.0.0.0.1.0.0.0.0.0.
我想知道为什么会显示space。我猜这些来自我的 memset(0)。 他们有更好的方法吗?
这与platformIO extension VScode terminal有关,它不能很好地处理特殊的shell控制字符来改变线条的颜色。
从 PuTTY:
读取的串行输出I (42273) camera_httpd: 0.0.0.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.
I (42273) camera_httpd: 0.0.0.0.0.1.0.0.1.0.0.0.0.0.0.0.0.0.0.0.1.1.
I (42283) camera_httpd: 0.0.0.0.1.0.1.1.0.1.0.0.1.0.0.0.0.0.0.0.0.1.
I (42293) camera_httpd: 0.0.0.0.4.1.1.1.1.1.1.0.1.0.0.0.0.0.0.1.0.0.
I (42293) camera_httpd: 0.0.0.1.0.1.1.1.1.1.1.1.1.0.0.0.0.0.0.0.0.1.
I (42303) camera_httpd: 0.0.0.0.1.1.1.1.1.1.1.1.1.1.0.1.0.0.1.0.0.1.
I (42313) camera_httpd: 0.0.0.0.3.1.1.1.1.1.1.0.1.1.0.0.0.0.1.0.1.0.
I (42323) camera_httpd: 0.0.0.1.0.1.1.1.1.1.1.1.1.0.1.0.0.0.0.0.1.0.
I (42323) camera_httpd: 0.0.0.0.1.0.1.1.1.1.1.1.1.0.0.1.0.0.0.1.0.1.
I (42333) camera_httpd: 0.5.1.1.3.1.0.1.1.1.1.1.1.1.1.0.0.0.0.0.0.0.
I (42343) camera_httpd: 0.0.0.1.1.0.1.0.0.1.1.0.1.0.0.0.0.0.0.0.0.0.