ui: add statistics

This commit is contained in:
Tobias Mädel 2021-05-23 23:10:47 +02:00
parent c38d98e440
commit 20e9b9180d
No known key found for this signature in database
GPG Key ID: 494E2F56C30460E1
5 changed files with 40 additions and 7 deletions

View File

@ -10,8 +10,8 @@
include project.cfg
# Compiler flags
CFLAGSFX = $(CFLAGS) $(CFLAGS_FX) $(INCLUDE_FX)
CFLAGSCG = $(CFLAGS) $(CFLAGS_CG) $(INCLUDE_CG)
CFLAGSFX = $(CFLAGS) $(CFLAGS_FX) $(INCLUDE_FX) -Wl,--print-memory-usage
CFLAGSCG = $(CFLAGS) $(CFLAGS_CG) $(INCLUDE_CG) -Wl,--print-memory-usage
# Linker flags
LDFLAGSFX := $(LDFLAGS) $(LDFLAGS_FX)

View File

@ -26,13 +26,13 @@ void uip_log(char *msg)
fxip_log(msg);
}
char buffer[128];
char printf_buffer[128];
void fxip_printf(const char * format, ...)
{
va_list args;
va_start (args, format);
vsnprintf (buffer, 128, format, args);
fxip_log (buffer);
vsnprintf (printf_buffer, sizeof(printf_buffer), format, args);
fxip_log (printf_buffer);
va_end (args);
}

View File

@ -8,6 +8,7 @@
#include "ui.h"
#include "log.h"
#include "network.h"
#include "clock-arch.h"
int __Serial_Open (unsigned char *mode);
int __Serial_Close (int mode);
@ -45,6 +46,11 @@ int main(void)
gint_world_switch(GINT_CALL(casioos_Serial_Close));
return 1;
}
if (clock_time() % 10 == 0)
{
ui_update();
}
}
return 1;

View File

@ -1,9 +1,18 @@
#include "ui.h"
#include <gint/display.h>
#include <gint/keyboard.h>
#include <stdarg.h>
#include <gint/std/stdio.h>
#include <gint/std/stdlib.h>
#include <gint/std/string.h>
#include "util.h"
#include "log.h"
#include "uip/uip.h"
extern struct uip_stats uip_stat;
typedef enum {
PAGE_LOGS,
PAGE_STATS,
@ -64,7 +73,14 @@ void ui_update()
}
break;
case PAGE_STATS:
dtext(1, 10, C_BLACK, "Statistik! :D");
ui_printf(0, 0, C_BLACK, "IP RX: %u TX: %u", uip_stat.ip.recv, uip_stat.ip.sent);
ui_printf(20, 10, C_BLACK, "Dropped: %u", uip_stat.ip.drop);
ui_printf(0, 23, C_BLACK, "ICMP RX: %u TX: %u", uip_stat.icmp.recv, uip_stat.icmp.sent);
ui_printf(1, 35, C_BLACK, "TCP:");
ui_printf(10, 45, C_BLACK, "Chksum err: %u", uip_stat.tcp.chkerr);
ui_printf(10, 55, C_BLACK, "Rexmit: %u", uip_stat.tcp.rexmit);
break;
default:
dtext(1, 10, C_BLACK, "Invalid page.");
@ -73,3 +89,12 @@ void ui_update()
dupdate();
}
extern char printf_buffer[128];
void ui_printf(int x, int y, int fg, const char * format, ...)
{
va_list args;
va_start (args, format);
vsnprintf (printf_buffer, sizeof(printf_buffer), format, args);
dtext(x, y, fg, printf_buffer);
va_end (args);
}

View File

@ -2,4 +2,6 @@
int ui_handle_keyboard();
void ui_update();
void ui_update_logs();
void ui_update_logs();
void ui_printf(int x, int y, int fg, const char * format, ...);