#include "core/cmd/cmd.h"
#endif
+#include "fahrplan.h"
#include "init.h"
+#include "ui/browser.h"
#include "ui/display.h"
-#include "ui/sprite.h"
#include "ui/event.h"
+#include "ui/font.h"
+#include "ui/menu.h"
+#include "ui/sprite.h"
+#include "ui/vanity.h"
#include "util/util.h"
#include "jumpnrun/jumpnrun.h"
#include "drivers/fatfs/ff.h"
+#include "badge/pinconfig.h"
+#include <funk/nrf24l01p.h>
+
#ifdef R0KET
#include "r0ketports.h"
{ RB_HB1 , &RB_HB1_IO , gpioPullupMode_PullUp },
{ RB_PWR_CHRG, &RB_PWR_CHRG_IO, gpioPullupMode_PullUp }
};
-
+
for(int i = 0; i < ARRAY_SIZE(input_pins); ++i) {
gpioSetDir(input_pins[i].port, input_pins[i].pin, gpioDirection_Input);
gpioSetPullup(input_pins[i].reg, input_pins[i].mode);
#endif
-/**************************************************************************/
-/*!
- Main program entry point. After reset, normal code execution will
- begin here.
+static void usbmode(void) {
+ badge_event_stop();
+
+ badge_framebuffer fb = { { { 0 } } };
+ badge_framebuffer_render_text(&fb, 22, 20, "USB-Modus");
+// badge_framebuffer_render_text(&fb, 10, 35, "Reset to exit");
+ badge_framebuffer_render_text(&fb, 16, 35, "Zurück mit");
+ badge_framebuffer_render_text(&fb, 32, 45, "Reset");
+/*
+ badge_framebuffer_render_number(&fb, 23, 50, sizeof(jumpnrun_tile));
+ badge_framebuffer_render_number(&fb, 33, 50, sizeof(jumpnrun_item));
+ badge_framebuffer_render_number(&fb, 48, 50, sizeof(jumpnrun_enemy));
*/
-/**************************************************************************/
+ badge_framebuffer_flush(&fb);
+
+ usbMSCInit();
+
+ for(;;) {
+ pmuSleep();
+ }
+}
+
+uint8_t main_menu_show(uint8_t selected) {
+ // first_visible = 0, weil das Menü so kurz ist. Sollte es
+ // größer werden: Parameter aus main_menu empfangen und merken.
+ uint8_t first_visible = 0;
+ char const *const menu[] = {
+ "Titelbild",
+ "Super Hackio",
+ "Fahrplan",
+ "USB-Modus"
+ };
+
+ f_chdir("/");
+ return (uint8_t) badge_menu(menu, ARRAY_SIZE(menu), &first_visible, selected);
+}
+
+void main_menu(void) {
+ uint8_t selected = 0;
+
+ for(;;) {
+ selected = main_menu_show(selected);
+ switch(selected) {
+ case 0: badge_vanity_show(); break;
+ case 1: jumpnrun_play (); break;
+ case 2: badge_fahrplan (); break;
+ case 3: usbmode (); break;
+ }
+ }
+}
+
int main(void)
{
- // Configure cpu and mandatory peripherals
- //systemInit();
-
cpuInit();
systickInit(CFG_SYSTICK_DELAY_IN_MS);
- // pmuInit();
+ pmuInit();
// adcInit();
#ifdef R0KET
rbInit();
badge_init();
#endif
- {
- // f_mkfs(0, 1, 0);
- badge_framebuffer fb;
- int res = 0;
- FATFS fatvol;
-
- while(FR_OK != f_mount(0, &fatvol)) {
- f_mkfs(0, 1, 0);
- }
-
- FIL fil;
- if(FR_OK == (res = f_open(&fil, "sshot.dat", FA_OPEN_EXISTING | FA_READ))) {
- UINT readbytes;
-
- if(FR_OK != f_read(&fil, &fb, sizeof(fb), &readbytes)) {
- }
+ FATFS fs;
+ f_mount(0, &fs);
- f_close(&fil);
- }
-
- badge_framebuffer_flush(&fb);
+#ifdef USBONLY
+ if(badge_input_raw() & BADGE_EVENT_KEY_LEFT) {
+ gpioSetValue(HOB_PORT(HOB_LED_LEFT), HOB_PIN(HOB_LED_LEFT) , 1);
+ }
+ if(badge_input_raw() & BADGE_EVENT_KEY_RIGHT) {
+ gpioSetValue(HOB_PORT(HOB_LED_RIGHT), HOB_PIN(HOB_LED_RIGHT) , 1);
}
+ for(;;) usbmode();
+#else
if(badge_input_raw() & BADGE_EVENT_KEY_DOWN) {
- usbMSCInit();
- for(;;);
+ usbmode();
}
badge_event_start();
-
- for(;;) {
- if(JUMPNRUN_ERROR == jumpnrun_play("smb.lvl")) {
- break;
- }
- }
-
- uint8_t buttons = 0;
-
- for(uint8_t i = 0; ; ++i) {
- badge_event_t event = badge_event_wait();
-
- switch(badge_event_type(event)) {
- case BADGE_EVENT_USER_INPUT: {
- buttons = badge_event_current_input_state();
- break;
- }
- case BADGE_EVENT_GAME_TICK: {
- badge_sprite const sp = { 4, 4, (uint8_t const *) "\xff\xff" };
- badge_framebuffer fb = { { { 0x80 } } };
-
- if(buttons & BADGE_EVENT_KEY_UP) { badge_framebuffer_blt(&fb, 30, 10, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_DOWN) { badge_framebuffer_blt(&fb, 30, 50, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_LEFT) { badge_framebuffer_blt(&fb, 10, 30, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_RIGHT) { badge_framebuffer_blt(&fb, 50, 30, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_CENTER){ badge_framebuffer_blt(&fb, 30, 30, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_BTN_A) { badge_framebuffer_blt(&fb, 70, 10, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_BTN_B) { badge_framebuffer_blt(&fb, 70, 50, &sp, 0); }
-
- badge_framebuffer_flush(&fb);
- break;
- }
- }
- }
+ badge_vanity_show();
+ main_menu();
+#endif
return 0;
}