Пример #1
0
void ram(void){
	bool again = true;
    FIL file;
	menuflags|=(MENU_JUSTONCE|MENU_BIG);
	screen_intro();
	while (again) {
        color_set = false;

        if( f_open(&file, "yell0w", FA_OPEN_EXISTING|FA_READ) == 0 ){
            yellow();
            color_set = true;
        }

        if( f_open(&file, "green", FA_OPEN_EXISTING|FA_READ) == 0 ){
            yellow();
            color_set = true;
        }

		while (!color_set) {	
			handleMenu(&submenu_color);
		}

		privacy_set = false;
		while (!privacy_set) {	
			handleMenu(&submenu_privacy);
		}

    	input("Nickname?", GLOBAL(nickname), 32, 127, MAXNICK-1);
		getInputWaitRelease();
		again = screen_overview();
	}
	menuflags&= (~(MENU_JUSTONCE|MENU_BIG));
	writeFile("nick.cfg",GLOBAL(nickname),strlen(GLOBAL(nickname)));
	saveConfig();
}
Пример #2
0
void main_final(void) {
    init_nick();
	if(GLOBAL(privacy)>2){ //firstboot
        if(execute_file("1boot.int",0,0)){
            lcdPrintln("Badge SETUP");
            lcdPrintln("error.");
            lcdPrintln("Features may");
            lcdPrintln("be broken.");
            lcdRefresh();
            getInputWait();
            getInputWaitRelease();
            GLOBAL(privacy)=0;
        }else{
            saveConfig();
        };
    };
    //checkFirstBoot();
    init_final();
    menuflags|=MENU_TIMEOUT;

    while(1){
#ifndef FINAL
        if(getInputRaw()==BTN_LEFT)
            ISPandReset();
#endif
        if(getInput()){
            handleMenu(&mainmenu);
            getInputWaitRelease();
            init_nick();
        };
        work_queue();
        fancyNickname();
    };
};
Пример #3
0
int main(void) {
	cpuClockInit(); /* CPU Clock is now 104 MHz */
	ssp_clock_init();
	systickInit();

//	cpu_clock_set(204);

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);
	SETUPgout(MIC_AMP_DIS);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);

	inputInit();
	lcdInit();
	fsInit(); 
	lcdFill(0xff);
	readConfig();

	generated_init();

	while(1) {
        handleMenu(&menu_main);
        getInputWaitRelease();
	}
	return 0;
}
Пример #4
0
void System::handleEvent(MAEvent &event) {
  switch (event.type) {
  case EVENT_TYPE_OPTIONS_BOX_BUTTON_CLICKED:
    if (_systemMenu != NULL) {
      handleMenu(event);
    } else if (isRunning()) {
      if (!form_ui::optionSelected(event.optionsBoxButtonIndex)) {
        dev_clrkb();
        dev_pushkey(event.optionsBoxButtonIndex);
      }
    }
    break;
  case EVENT_TYPE_SCREEN_CHANGED:
    resize();
    break;
  case EVENT_TYPE_POINTER_PRESSED:
    _touchX = _touchCurX = event.point.x;
    _touchY = _touchCurY = event.point.y;
    if (_output->overMenu(_touchX, _touchY)) {
      showMenu();
    } else {
      dev_pushkey(SB_KEY_MK_PUSH);
      _buttonPressed = _output->pointerTouchEvent(event);
      showCursor(get_focus_edit() != NULL ? kIBeam : kHand);
    }
    break;
  case EVENT_TYPE_POINTER_DRAGGED:
    _touchCurX = event.point.x;
    _touchCurY = event.point.y;
    _output->pointerMoveEvent(event);
    if (_output->hasHover() ||
        _output->overMenu(_touchCurX, _touchCurY)) {
      showCursor(kHand);
    } else if (_output->hasMenu()) {
      showCursor(kArrow);
    } else if (get_focus_edit()) {
      showCursor(kIBeam);
    } else {
      showCursor(kArrow);
    }
    break;
  case EVENT_TYPE_POINTER_RELEASED:
    _buttonPressed = false;
    _touchX = _touchY = _touchCurX = _touchCurY = -1;
    _output->pointerReleaseEvent(event);
    showCursor(get_focus_edit() != NULL ? kIBeam : kArrow);
    break;
  default:
    // no event
    _output->flush(false);
    break;
  }
}
Пример #5
0
int main(uint32_t startloc) {
	cpu_clock_init();
	ssp_clock_init();
	systickInit();

//	cpu_clock_set(204);

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);
	SETUPgout(MIC_AMP_DIS);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);
	inputInit();
	flashInit();

	lcdInit();
	fsInit();
	lcdFill(0xff); /* Display BL Image here */

	sli=startloc;

	if (startloc != (uintptr_t)&_app_start){ /* not booted via DFU, do autoboot */ 
        char filename[FLEN];
        switch(getInputRaw()){
            case BTN_LEFT:
                getInputWaitRelease();
                doRealExec(1);
                break;
            case BTN_UP:
                doMSC();
            default:
            case BTN_NONE:
                readTextFile(BOOTCFG, filename, FLEN);
                lcdPrintln("Booting:");
                lcdPrintln(filename);
                bootFile(filename);
                break;
		};
	};
	static const struct MENU main={ "Bootloader", {
		{ "Exec Firmware", &doExec},
		{ "MSC", &doMSC},
		{ "Flash Boot Ldr", &doFlash},
		{ "Info", &doInfo},
		{NULL,NULL}
	}};
	do {
		handleMenu(&main);
	}while(1);
}
Пример #6
0
int main(void)
{
	cpu_clock_init();
	ssp_clock_init();

	inputInit();

    lcdInit();
    lcdFill(0xff);
	OFF(MIXER_EN);

	static const struct MENU main={ "img test", {
		{ "LCD", &doLCD},
		{NULL,NULL}
	}};
	handleMenu(&main);
	return 0;
}
Пример #7
0
int main(uint32_t startloc) {
	cpu_clock_init();
	ssp_clock_init();
	systick_set_reload(208000);
	systick_set_clocksource(0);
	systick_interrupt_enable();
	systick_counter_enable();

//	cpu_clock_pll1_max_speed();

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);
	inputInit();
	flashInit();

    lcdInit();
	fsInit();
    lcdFill(0xff); /* Display BL Image here */

	sli=startloc;

	if (startloc != (uintptr_t)&_app_start){ /* not booted via DFU, do autoboot */ 
		if (getInputRaw()!=BTN_LEFT){
			char filename[FLEN];
			readTextFile(BOOTCFG, filename, FLEN);
			lcdPrintln("Fname");
			lcdPrintln(filename);
			bootFile(filename,0);
		};
	};
	static const struct MENU main={ "Bootloader", {
		{ "Info", &doInfo},
		{ "Exec", &doExec},
		{ "Flash", &doFlash},
		{NULL,NULL}
	}};
	handleMenu(&main);
	return 0;
}
Пример #8
0
MODE_T updateGame(void)
{
    switch (state) {
    case STATE_PLAYING:
        updateGamePlaying();
        break;
    case STATE_OVER:
        updateGameOver();
        break;
    case STATE_ISSUES:
        updateGameIssues();
        break;
    case STATE_MENU:
    case STATE_RESULT:
        handleMenu();
        break;
    }
    return (state == STATE_LEAVE) ? MODE_TITLE : MODE_GAME;
}
Пример #9
0
int main(void) {
	cpu_clock_init_();
	ssp_clock_init();

	systickInit();

//	cpu_clock_pll1_max_speed();

	SETUPgout(EN_VDD);
	SETUPgout(MIXER_EN);

	SETUPgout(LED1);
	SETUPgout(LED2);
	SETUPgout(LED3);
	SETUPgout(LED4);

	inputInit();
	feldInit();

    lcdInit();
	fsInit(); 
    lcdFill(0xff);

	static const struct MENU main={ "main 1", {
		{ "FS", &doFS},
		{ "MSC", &doMSC},
		{ "flash", &doFlash},
		{ "LCD", &doLCD},
		{ "speed", &doSpeed},
		{ "ADC", &doADC},
		{ "feld", &doFeld},
		{ "chrg", &doChrg},
		{NULL,NULL}
	}};
	handleMenu(&main);
	return 0;
}
Пример #10
0
int main(void)
{
	MCUCSR = (1<<JTD); // Disable JTAG
	MCUCSR = (1<<JTD); // Disable JTAG (yes, 2 are required)

	// Configure serial
	UBRRH = (uint8_t)(UBRR>>8);
	UBRRL = (uint8_t)(UBRR);
	UCSRB |= (1<<TXEN) | (1<<RXEN) | (1<<RXCIE);
	UCSRC |= (1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0);

	// Set up buttons
	DDRB &= ~(1<<ENTER | 1<<CANCEL | 1<<UP | 1<<DN);
	PORTB |= 0xF; // Configure ports 0-3 as inputs with pull-ups

	// Timer interrupt, 1mS
	TCCR1B |= (1<<CS12) | (1<<WGM12);
	OCR1A = 625; // 100Hz (10mS) with div by 256
	TIMSK |= 1<<OCIE1A;
	sei();

	DDRD |= (1<<PIND7 | 1<<PIND3 | 1<<PIND4);

    //DDRA |= (1<<PINA0 | 1<<PINA1);
    //PORTA &= ~(1<<PORTA0 | 1<<PORTA1);
    //_delay_ms(10);
	LCDInit();

	while(1)
	{
		_delay_ms(200);
		if (rxflag)
		{
			LCDSetPos(0,15);
			LCDSendChar(c);
		}
		if (LEDFlag)
		{
			LEDFlag = 0;
    		PORTD |= 1<<PORTD7;
            _delay_ms(100);
    		PORTD &= ~(1<<PORTD7);
		}

		/*
         switch(btnpressed){
			case(BTN_ENTER):
				serialSendText("Enter\n\r");
				break;
			case(BTN_CANCEL):
				serialSendText("Cancel\n\r");
				break;
			case(BTN_UP):
				serialSendText("Up\n\r");
				break;
			case(BTN_DOWN):
				serialSendText("Down\n\r");
				break;
			default:
				serialSendText("None\n\r");
		}
        */
		runstate = handleMenu(btnpressed);

        if (runstate == RS_RUN){
			serialSendText("RUN\n\r");
		}
		else{
			serialSendText("STOP\n\r");
		}

        if ((trigger == 1) && (runstate == RS_RUN)){
            triggerhalf();
            _delay_ms(100);
            triggerfull();
            _delay_ms(100);
            triggernone();
            trigger = 0;
        }

		btnpressed = BTN_NONE;

		if (lcdchanged == 1){
			LCDSetPos(0,0);
			LCDSendText("Delay time: ");
			itoa(time, buffer, 10);
			LCDSendText(buffer);
            LCDSendText("    ");
			LCDSetPos(1,0);
			LCDSendText("Frames: ");
			itoa(counter, buffer, 10);
			LCDSendText(buffer);
            LCDSendText("      ");
			LCDSetPos(2,0);
			if (runstate == RS_RUN){
				LCDSendText("Running");
			}
			else{
				LCDSendText("Stopped");
			}
			lcdchanged = 0;
		}
	}
}
Пример #11
0
void Game::mainLoop() {
	if (_nextState != _state) {
		// fini
		switch (_state) {
		case kStateGame:
			break;
		case kStateDialogue:
			finiDialogue();
			break;
		case kStateMenu1:
		case kStateMenu2:
			finiMenu();
			break;
		}
		_state = _nextState;
		// init
		switch (_state) {
		case kStateGame:
			break;
		case kStateDialogue:
			initDialogue();
			break;
		case kStateBitmap:
			displayTitleBitmap();
			break;
		case kStateMenu1:
		case kStateMenu2:
			initMenu(1 + _state - kStateMenu1);
			break;
		}
	}
	switch (_state) {
	case kStateGame:
		while (_switchScene) {
			_switchScene = false;
			if (stringEndsWith(_tempTextBuffer, "SCN")) {
				win16_sndPlaySound(6);
				debug(DBG_GAME, "switch to scene '%s'", _tempTextBuffer);
				if (strcmp(_tempTextBuffer, "PIC4.SCN") == 0) {
					debug(DBG_INFO, "End of game");
					break;
				}
				strcpy(_currentSceneScn, _tempTextBuffer);
				parseSCN(_tempTextBuffer);
			} else {
				debug(DBG_GAME, "load mov '%s'", _tempTextBuffer);
				loadMOV(_tempTextBuffer);
			}
			if (_loadState) {
				_loadState = false;
				if (_currentSceneSav[0]) {
					FileHolder fh(_fs, _currentSceneSav);
					if (!fh._fp) {
						warning("Unable to load game state from file '%s'", _tempTextBuffer);
					} else {
						warning("Loading game state from '%s'", _currentSceneSav);
						loadState(fh._fp, kDemoSavSlot, false);
						loadKBR(_currentSceneSav);
					}
				} else {
					char filePath[MAXPATHLEN];
					snprintf(filePath, sizeof(filePath), kGameStateFileNameFormat, _savePath, _stateSlot);
					File f;
					if (!f.open(filePath, "rb")) {
						warning("Unable to load game state from file '%s'", filePath);
					} else {
						loadState(&f, _stateSlot, false);
					}
				}
				playMusic(_musicName);
				memset(_keysPressed, 0, sizeof(_keysPressed));
			}
			assert(_sceneObjectsCount != 0);
			if (_currentBagObject == -1) {
				_currentBagObject = _bagObjectsCount - 1;
				if (_currentBagObject > 0) {
					_currentBagObject = 0;
				}
			}
			if (_loadDataState != 0) {
				_stub->setPalette(_bitmapBuffer0 + kOffsetBitmapPalette, 256);
				_stub->copyRectWidescreen(kGameScreenWidth, kGameScreenHeight, _bitmapBuffer1.bits, _bitmapBuffer1.pitch);
			}
			_gameOver = false;
			_workaroundRaftFlySceneBug = strncmp(_currentSceneScn, "FLY", 3) == 0;
		}
		updateKeysPressedTable();
		updateMouseButtonsPressed();
		runObjectsScript();
		if (_startDialogue) {
			_startDialogue = false;
			_nextState = kStateDialogue;
		}
		break;
	case kStateBag:
		handleBagMenu();
		break;
	case kStateDialogue:
		handleDialogue();
		if (_dialogueEndedFlag) {
			_nextState = kStateGame;
		}
		break;
	case kStateBitmap:
		if (_stub->_pi.enter) {
			_stub->_pi.enter = false;
			playVideo("DATA/INTRO.AVI");
			_nextState = kStateGame;
		}
		break;
	case kStateMenu1:
		handleMenu();
		switch (_menuOption) {
		case kMenuOptionNewGame:
			restart();
			_nextState = kStateGame;
			break;
		case kMenuOptionLoadGame:
			_stub->_pi.load = true;
			_nextState = kStateGame;
			break;
		case kMenuOptionSaveGame:
			_stub->_pi.save = true;
			_nextState = kStateGame;
			break;
		case kMenuOptionQuitGame:
			_nextState = kStateMenu2;
			break;
		}
		if (_stub->_pi.escape) {
			_stub->_pi.escape = false;
			_nextState = kStateGame;
		}
		break;
	case kStateMenu2:
		handleMenu();
		switch (_menuOption) {
		case kMenuOptionExitGame:
			_stub->_quit = true;
			break;
		case kMenuOptionReturnGame:
			_nextState = kStateGame;
			break;
		}
		if (_stub->_pi.escape) {
			_stub->_pi.escape = false;
			_nextState = kStateGame;
		}
		break;
	}
	_stub->updateScreen();
}
Пример #12
0
// process events on the system event queue
MAEvent Controller::processEvents(int ms, int untilType) {
  MAEvent event;
  MAExtent screenSize;
  int loadPathSize = _loadPath.length();

  if (ms < 0 && untilType != -1) {
    // flush the display before pausing for target event
    if (isRunning()) {
      _output->flush(true);
    }
    maWait(ms);
    ms = EVENT_WAIT_NONE;
  }

  while (!isBreak() && maGetEvent(&event)) {
    switch (event.type) {
    case EVENT_TYPE_OPTIONS_BOX_BUTTON_CLICKED:
      if (_systemMenu) {
        handleMenu(event.optionsBoxButtonIndex);
        ms = EVENT_WAIT_NONE;
      } else if (isRunning()) {
        if (!_output->optionSelected(event.optionsBoxButtonIndex)) {
          dev_pushkey(event.optionsBoxButtonIndex);
        }
      }
      break;
    case EVENT_TYPE_SCREEN_CHANGED:
      screenSize = maGetScrSize();
      _output->resize(EXTENT_X(screenSize), EXTENT_Y(screenSize));
      os_graf_mx = _output->getWidth();
      os_graf_my = _output->getHeight();
      handleKey(SB_PKEY_SIZE_CHG);
      break;
    case EVENT_TYPE_POINTER_PRESSED:
      _touchX = _touchCurX = event.point.x;
      _touchY = _touchCurY = event.point.y;
      handleKey(SB_KEY_MK_PUSH);
      _output->pointerTouchEvent(event);
      break;
    case EVENT_TYPE_POINTER_DRAGGED:
      _touchCurX = event.point.x;
      _touchCurY = event.point.y;
      _output->pointerMoveEvent(event);
      break;
    case EVENT_TYPE_POINTER_RELEASED:
      _touchX = _touchY = _touchCurX = _touchCurY = -1;
      handleKey(SB_KEY_MK_RELEASE);
      _output->pointerReleaseEvent(event);
      break;
    case EVENT_TYPE_CLOSE:
      setExit(true);
      break;
    case EVENT_TYPE_KEY_PRESSED:
      handleKey(event.key);
      break;
    }
    if (untilType == EVENT_TYPE_EXIT_ANY ||
        untilType == event.type ||
        loadPathSize != _loadPath.length()) {
      // skip next maWait() - found target event or loadPath changed
      ms = EVENT_WAIT_NONE;
      break;
    }
  }

  if (ms != EVENT_WAIT_NONE) {
    maWait(ms);
  }
  return event;
}
Пример #13
0
void eventLoop()
{
	EventRecord 	event;
	WindowPtr		window;
	short			clickArea;
	Rect 			screenRect;
	long			sleep = 30;
	Point			point;
	
	for (;;)
	{		
		if (WaitNextEvent( everyEvent, &event, sleep, (RgnHandle)nil ))
		{
			if (event.what == mouseDown)
			{
				clickArea = FindWindow( event.where, &window );
				
				if (clickArea == inDrag)
				{
					//screenRect = (**GetGrayRgn()).rgnBBox;
					GetRegionBounds(GetGrayRgn(), &screenRect);
					DragWindow(window, event.where, &screenRect );
				}
				else if (clickArea == inGoAway)
				{
					if (TrackGoAway( window , event.where ))
						ExitToShell();
				}
				else if (clickArea == inMenuBar)
				{
					adjustMenus();
					handleMenu( MenuSelect( event.where ) );
				}
				else if (clickArea == inContent)
				{
					if (window != FrontWindow())
						SelectWindow( window );
					else
					{
						point = event.where;
						GlobalToLocal( &point );
						handleMouseDown( point );
					}
				}
			}
			else if (event.what == updateEvt)
			{
				window = (WindowPtr)event.message;
				//SetPort( window );
				SetPortWindowPort( window );
				
				BeginUpdate( window );
				updateWindow();
				EndUpdate( window );
			}
			else if (event.what ==  keyDown || event.what == autoKey)
			{
				if ((event.modifiers & cmdKey) != 0)
				{
					adjustMenus();
					handleMenu( MenuKey( (char)(event.message & charCodeMask) ) );
				}
			}
		}
	}
}
Пример #14
0
int my_traverseCDKScreen (CDKSCREEN *screen)
{
    CDKOBJS *curobj = NULL;

    // Get the focus
    curobj = getCDKFocusCurrent(screen);

    // If we didn't have one, or it was invalid, pick first one.
    if (!curobj)
        curobj = switchFocus (setCDKFocusNext (screen), 0);

    // Still no focus, bail.
    if (curobj == 0)
        return 0;

    refreshDataCDKScreen (screen);

    screen->exitStatus = CDKSCREEN_NOEXIT;



    while ((curobj != 0) && (screen->exitStatus == CDKSCREEN_NOEXIT))
    {
        int key;


        /* I want ASYNC, but for some reason you can't set this
         * globally */
        // PreProcess can change Focus, we need to detect this
        if (getCDKFocusCurrent(screen) != curobj) {
            curobj = getCDKFocusCurrent(screen);
            if (!curobj) break;
        }

        wtimeout(curobj->inputWindow, 350);
        key = getcCDKObject (curobj);

        switch (key)
        {
        case KEY_BTAB:
        {
            curobj = switchFocus (setCDKFocusPrevious (screen), curobj);
            break;
        }
        case KEY_TAB:
        {
            curobj = switchFocus (setCDKFocusNext (screen), curobj);
            break;
        }
        case KEY_F(10):
        {
            /* save data and exit */
            exitOKCDKScreen (screen);
            break;
        }
        case CTRL('X'):
        {
            exitCancelCDKScreen (screen);
            break;
        }
        case CTRL('R'):
        {
            /* reset data to defaults */
            resetCDKScreen (screen);
            setFocus (curobj);
            break;
        }
        case CDK_REFRESH:
        {
            /* redraw screen */
            refreshCDKScreen (screen);
            setFocus (curobj);
            break;
        }
        case KEY_ESC:
        {
            /* find and enable drop down menu */
            int j;

            for (j = 0; j < screen->objectCount; ++j)
                if (ObjTypeOf (screen->object[j]) == vMENU)
                {
                    curobj = handleMenu (screen, screen->object[j], curobj);
                    break;
                }
            break;
        }


        /* wgetch() returns ERR if we timedout */
        case ERR:
            return -1;
            break;

        default:
        {
            InjectObj (curobj, key);
            break;
        }
        }

    }

    if (screen->exitStatus == CDKSCREEN_EXITOK)
    {
        saveDataCDKScreen (screen);
        return 1;
    }
    else
        return 0;
}