void verifySDownConditions(void) { if(sDown_filtered < SDown_Threshold) { if(sd_printing) { initPause(); config.status = 9; write_config(); sd_printing = false; queue_flush(); reset_current_block(); home_z(); } else if(printerPause) { config.status = 9; write_config(); sd_printing = false; queue_flush(); reset_current_block(); home_z(); } } }
void verifyBatteryLevels(void) { //Power Supply Disconnected if(!ps_ext_state) { charge_time = 0; //Printing if(sd_printing || sd_pause) { //If not in Battery Mode operation if(!batteryMode) { batt_time = 0; batteryMode = true; charging = false; } //If printing in Battery Mode else { //Printing time exceeded... Start Pause Procedure if(batt_time > (config.batteryPrintTime * 1000) && sd_pause == false) { initPause(); write_config(); sd_printing = false; sd_pause = true; sd_resume = false; printerPause = false; } } } //Transfering /* else if(transfer_mode) { } */ if(!sd_printing && batteryMode) { //Printer Paused... Enter Shutdown if(batt_time > (config.batteryPrintTime * 1000) && printerPause) { printerShutdown = false; enter_power_saving = false; config.battery_ShutDown = 1; enterShutDown(); } //Printer In Shutdown... Enter Power Saving else if(batt_time > (config.batteryPrintTime * 1000) && printerShutdown && !in_power_saving) { if(!enter_power_saving) { in_power_saving = false; powerSavingDelay = 5000; enter_power_saving = true; rest_time = 0; } } //Printer in Shutdown and Power Saving else if(batt_time > (config.batteryPrintTime * 1000) && in_power_saving && printerShutdown) { //If standby exceeded or Low Battery charge turn off pritner if(batt_time > (config.standByTime * 1000) || batt_filtered < 2460){ BATT_uC_disable(); } } } //Not Currently Printing and Not entered battery mode else if(!sd_printing && !batteryMode) { if(!printerPause || !printerShutdown || !sd_pause || !sd_resume || !enter_power_saving || !in_power_saving) { //home(); //BATT_uC_disable(); } } } //Power Supply Connected else { //If power supply just connected if(batteryMode && charge_time < 60000) { STEP_uC_disable(); } //If 1 minute passed since last power failure else if(batteryMode && charge_time >= 60000 && in_power_saving) { reinit_system(); } else if(batteryMode && charge_time >= 60000 && !in_power_saving) { batteryMode = false; } //If not longer in battery mode, charge battery and resume print if(!batteryMode) { //If Auto-resume enabled resume print if(config.status == 9 && config.autoResume == 1 && sd_resume == false && config.battery_ShutDown == 1) { temp_set(config.startpoint_temperature, EXTRUDER_0); enqueue_wait_temp(); config.battery_ShutDown = 0; write_config(); sd_resume = true; } //Charge battery if(current_temp_r2c2 > 0 && current_temp_r2c2 < 45) { STEP_uC_enable(); } else { STEP_uC_disable(); } } } }
void initGame(void) { lcdMainOnTop(); int oldv=getMemFree(); NOGBA("mem free : %dko (%do)",getMemFree()/1024,getMemFree()); NOGBA("initializing..."); videoSetMode(MODE_5_3D | DISPLAY_BG3_ACTIVE); videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); glInit(); vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_LCD,VRAM_D_MAIN_BG_0x06000000); vramSetBankH(VRAM_H_SUB_BG); vramSetBankI(VRAM_I_SUB_BG_0x06208000); glEnable(GL_TEXTURE_2D); // glEnable(GL_ANTIALIAS); glDisable(GL_ANTIALIAS); glEnable(GL_BLEND); glEnable(GL_OUTLINE); glSetOutlineColor(0,RGB15(0,0,0)); //TEMP? glSetOutlineColor(1,RGB15(0,0,0)); //TEMP? glSetOutlineColor(7,RGB15(31,0,0)); //TEMP? glSetToonTableRange(0, 15, RGB15(8,8,8)); //TEMP? glSetToonTableRange(16, 31, RGB15(24,24,24)); //TEMP? glClearColor(31,31,0,31); glClearPolyID(63); glClearDepth(0x7FFF); glViewport(0,0,255,191); // initVramBanks(1); initVramBanks(2); initTextures(); initSound(); initCamera(NULL); initPlayer(NULL); initLights(); initParticles(); initMaterials(); loadMaterialSlices("slices.ini"); loadMaterials("materials.ini"); loadControlConfiguration("config.ini"); initElevators(); initWallDoors(); initTurrets(); initBigButtons(); initTimedButtons(); initEnergyBalls(); initPlatforms(); initCubes(); initEmancipation(); initDoors(); initSludge(); initPause(); initText(); NOGBA("lalala"); getPlayer()->currentRoom=&gameRoom; currentBuffer=false; getVramStatus(); fadeIn(); mainBG=bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); bgSetPriority(mainBG, 0); REG_BG0CNT=BG_PRIORITY(3); #ifdef DEBUG_GAME consoleInit(&bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 16, 0, false, true); consoleSelect(&bottomScreen); #endif // glSetToonTableRange(0, 14, RGB15(16,16,16)); // glSetToonTableRange(15, 31, RGB15(26,26,26)); initPortals(); //PHYSICS initPI9(); strcpy(&mapFilePath[strlen(mapFilePath)-3], "map"); newReadMap(mapFilePath, NULL, 255); transferRectangles(&gameRoom); makeGrid(); generateRoomGrid(&gameRoom); gameRoom.displayList=generateRoomDisplayList(&gameRoom, vect(0,0,0), vect(0,0,0), false); getVramStatus(); startPI(); NOGBA("START mem free : %dko (%do)",getMemFree()/1024,getMemFree()); NOGBA("vs mem free : %dko (%do)",oldv/1024,oldv); levelInfoCounter=60; }