badge/jumpnrun/starter.c \\r
badge/jumpnrun/stats.c \\r
badge/jumpnrun/tiles.c \\r
+ badge/ui/browser.c \\r
badge/ui/display.c \\r
badge/ui/event.c \\r
badge/ui/font.c \\r
}
void scrolltest(void) {
- char menu_buf[][15] = {
- "foo",
- "bar",
- "baz",
- "qux",
- "foo",
- "bar",
- "baz",
- "qux",
- "foo",
- "bar",
- "baz",
- "qux",
- "foo",
- "bar",
- "baz",
- "qux",
- };
-
- char const * menu_index[] = {
- menu_buf[0],
- menu_buf[1],
- menu_buf[2],
- menu_buf[3],
- menu_buf[4],
- menu_buf[5],
- menu_buf[6],
- menu_buf[7],
- menu_buf[8],
- menu_buf[9],
- menu_buf[10],
- menu_buf[11],
- menu_buf[12],
- menu_buf[13],
- menu_buf[14],
- menu_buf[15]
- };
-
- badge_scroll_text(menu_index, 16);
+ badge_browse_textfile("/fahrplan/test.txt");
}
int main(void)
#include "browser.h"
#include "menu.h"
-void badge_browse_textfile(char const *fname) {
+#include <drivers/fatfs/ff.h>
+
+enum {
+ LINE_LENGTH = 16
+};
+
+static void badge_browse_textfile_fd(FIL *fd) {
+ unsigned linecount = 0;
+
+ {
+ char buf[LINE_LENGTH];
+ while(f_gets(buf, LINE_LENGTH, fd)) {
+ ++linecount;
+ }
+ }
+
+ if(FR_OK != f_lseek(fd, 0)) {
+ return;
+ }
+ char lines_buf[linecount][LINE_LENGTH];
+ char const *lines[linecount];
+ unsigned i;
+
+ for(i = 0; i < linecount && f_gets(lines_buf[i], LINE_LENGTH, fd); ++i) {
+ lines[i] = lines_buf[i];
+ }
+
+ badge_scroll_text(lines, i);
+}
+
+void badge_browse_textfile(char const *fname) {
+ FIL fd;
+ if(FR_OK == f_open(&fd, fname, FA_OPEN_EXISTING | FA_READ)) {
+ badge_browse_textfile_fd(&fd);
+ f_close(&fd);
+ }
}