in apps/mesh_badge/src/reel_board.c [264:335]
static void show_statistics(void)
{
int top[4] = { -1, -1, -1, -1 };
int len, i, line = 0;
struct stat *stat;
char str[32];
cfb_framebuffer_clear(epd_dev, false);
len = snprintk(str, sizeof(str),
"Own Address: 0x%04x", mesh_get_addr());
print_line(FONT_SMALL, line++, str, len, false);
len = snprintk(str, sizeof(str),
"Node Count: %lu", stat_count + 1);
print_line(FONT_SMALL, line++, str, len, false);
/* Find the top sender */
for (i = 0; i < ARRAY_SIZE(stats); i++) {
int j;
stat = &stats[i];
if (!stat->addr) {
break;
}
if (!stat->hello_count) {
continue;
}
for (j = 0; j < ARRAY_SIZE(top); j++) {
if (top[j] < 0) {
top[j] = i;
break;
}
if (stat->hello_count <= stats[top[j]].hello_count) {
continue;
}
/* Move other elements down the list */
if (j < ARRAY_SIZE(top) - 1) {
memmove(&top[j + 1], &top[j],
((ARRAY_SIZE(top) - j - 1) *
sizeof(top[j])));
}
top[j] = i;
break;
}
}
if (stat_count >= 0) {
len = snprintk(str, sizeof(str), "Most messages from:");
print_line(FONT_SMALL, line++, str, len, false);
for (i = 0; i < ARRAY_SIZE(top); i++) {
if (top[i] < 0) {
break;
}
stat = &stats[top[i]];
len = snprintk(str, sizeof(str), "%-3u 0x%04x %s",
stat->hello_count, stat->addr,
stat->name);
print_line(FONT_SMALL, line++, str, len, false);
}
}
cfb_framebuffer_finalize(epd_dev);
}