/*============================================================================*/ void LCD_16x2_ScreenOut(const char *LCDRow1, const char *LCDRow2, unsigned char clear_screen){ if (clear_screen) LCD_Clear(); LCD_Goto(0,0); LCD_Puts(LCDRow1); LCD_Goto(1,0); LCD_Puts(LCDRow2); }
void drawPauseMode(void){ LCD_DrawFilledRect(boardX,boardY,boardLen,boardLen,BLACK); LCD_SetTextColor(255,255,240); LCD_Goto(25,13); printf("Continue"); LCD_Goto(38,13); printf("Restart"); LCD_DrawRect(144,112,58,16,WHITE); }
inline void inputRepaintF(float value) { //if need, we clear display LCD_Goto(1, 0);//print title LCD_Puts(activeItem->Text); LCD_Goto(2, 1); LCD_Puts("Параметр:"); LCD_Putc(' '); LCD_PutFloat(value);//print value }
void changeHours(struct tm *dt) { unsigned int buttonsState; unsigned int nextState; LCD_Clear(); LCD_Goto(0,1); LCD_WriteString(str1); while(nextState != SET_HOURS) { buttonsState = Button_Read(); nextState = decodeButtons_inHours(buttonsState); //Actualizar o LCD para os novos valores das horas LCD_Goto(0,0); strftime(buffer,16,"%T",dt); LCD_WriteString(buffer); switch(nextState) { case INC_HOURS: LCD_Goto(0,1); incrementHours(dt); break; case DEC_HOURS: LCD_Goto(0,1); decrementHours(dt); break; case INC_MINUTES: incrementMinutes(dt); break; case DEC_MINUTES: decrementMinutes(dt); break; case CHANGE_FIELD: actualPosition = (actualPosition + 1)%LEN_ENUM; break; default: break; } } RTC_SetTime(dt); RTC_SetDate(dt); RTC_SetDays(dt); LCD_Clear(); }
inline void actionRepaint(devstate acState) { //if need, we clear display LCD_Goto(1, 0);//print title LCD_Puts(activeItem->Text); LCD_Goto(2, 2); LCD_Puts("Состояние:"); LCD_Puts(" "); LCD_Goto(12, 2); if(acState == ENABLE_STATE) LCD_Puts("Вкл.");//print value else if(acState == DISABLE_STATE) LCD_Puts("Откл.");//print value }
void turnOnLcdAndWriteTime(){//done LCD_TurnOnDisplay(); LCD_BL_State(1); RTC_GetValue(&dateTime); char time[time_len], date[date_len]; itot(time, dateTime.tm_hour, dateTime.tm_min); itod(date, dateTime.tm_mday, dateTime.tm_mon, dateTime.tm_year); LCD_Goto(3,1); LCD_WriteString(date); LCD_Goto(5,2); LCD_WriteString(time); LCD_Goto(5,3); //if(count>=0)LCD_WriteChar('*'); }
//Point moving void lcdMovePoint(uint8_t pos) { //clear points int i; for(i = 1; i <= 3; i++) { LCD_Goto(1, i); LCD_Putc(' '); } LCD_Goto(1, pos + 1); LCD_Putc('>'); }
void Manutencao(Button bUp, Button bDown, Button bOk){ Manutencao_Init(); LCD_WriteString("MODO DE"); LCD_Goto(1,6); LCD_WriteString("Manutencao"); TMR0_Delay(3000); LCD_Clear(); getSubMenu(); while(1){ if(BUTTON_getState(bUp){ executeAction(MUP); } if(BUTTON_getState(bDown){ executeAction(MDOWN); } if(BUTTON_getState(bOk){ //SAIR DO MODO DE MANUTENCAO if(m.currSubMenu == 6) return; executeAction(MOK); } } }
void getSubMenu(){ char *strl1 = m.subMenus[m.currSubMenu-1].L1, *strl2 = m.subMenus[m.currSubMenu-1].L2; LCD_WriteString(strl1); LCD_Goto(1,0); LCD_WriteString(strl2); }
int main(void){unsigned short score; PLL_Init(); // Set the clocking to run at 80MHz from the PLL. LCD_Init(); // Initialize LCD LCD_Goto(0,0); score =0; long v2; LCD_SetTextColor(255,0,0); // yellow= red+green, no blue printf("score: %d", score); LCD_DrawLine(10,16,310,16,BURNTORANGE); Timer2_Init(4000000); // 20 times a second Timer3_Init(7256); // 11.025 KHz InitEnemy(); InitBunker(); InitPlayer(); InitMissile(); InitLaser(); Random_Init(1); EnableInterrupts(); Fireflag=1; while(1){ if(Semaphore){ DrawBuffer1(); Semaphore = 0; } } }
void Manutencao(){ LCD_Clear(); LCD_On(); pm->sbm.curr = 1; LCD_WriteString("Modo de"); LCD_Goto(1,6); LCD_WriteString("Manutencao"); TMR0_Delay(3000); int buttons; Manager_Print(pm); while(1){ buttons = BUTTONCTRL_GetButtonsEvolution(); //MODO MANUTENCAO if(buttons == OKPRESSED)){ while(!BUTTONCTRL_RELEASE()); if(Manager_Entry(pm, pButs,3)) break; } else if(buttons == UPPRESSED)){ while(!BUTTONCTRL_RELEASE()); } else if(buttons == DOWNPRESSED)){
void showPWM(uint8_t x,uint8_t y,uint16_t value){ LCD_ClearField(x,y,4); LCD_Goto(x,y); LCD_SendNumber(getPercentPwm(),' '); LCD_WriteData('%'); }
void showADC(uint8_t x,uint8_t y,uint16_t value){ LCD_ClearField(x,y,4); LCD_Goto(x,y); if(y==0){ LCD_SendNumber(value,'.'); }else{ LCD_SendNumber(value,' '); } }
void Board_Init(void){int tileLen, row, col, tileX, tileY; // Background Color LCD_DrawFilledRect(0,0,320,240,BLACK); // Sidebar Color LCD_DrawFilledRect(0,0,91,240,RED); LCD_DrawRect(0,0,91,239,BURNTORANGE); // Board Frame LCD_DrawFilledRect(boardX, boardY, boardLen, boardLen, ORANGE); // Title LCD_DrawBMP(Title, 13, 7); // Scoreboard/Credits LCD_DrawFilledRect(6,59,79,175,BLACK); LCD_DrawRect(6,59,79,174,YELLOW); LCD_SetTextColor(255,245,200); LCD_Goto(2,9); printf("Score:"); LCD_Goto(2,15); printf("Highscore:"); LCD_Goto(2,12); printf("Time:"); // Credits LCD_Goto(4,7); LCD_SetTextColor(255,255,240); printf("LAB 10"); LCD_Goto(2,23); printf("Created by:"); LCD_Goto(2,24); printf("Ryan Norton"); LCD_Goto(2,25); printf("Andrew Grado"); // Initialize Tile Position Array and Empty Board tileLen = (boardLen - (5 * tilePadding)) / 4; for (row=0; row<4; row++){ for (col=0; col<4; col++){ // Calculate tile coordinates tileX = row * (tileLen + tilePadding) + tilePadding + boardX; tileY = col * (tileLen + tilePadding) + tilePadding + boardY; // Initialize board with empty tiles // LCD_DrawFilledRect(tileX, tileY, tileLen, tileLen, GREEN); // Initialize tile position array tileCoords[col * 4 + row + 1][0] = tileX; tileCoords[col * 4 + row + 1][1] = tileY - 1; } } }
void lcdRepaintMenu() { LCD_Clear(); /* For first we print the name of parent menu */ if(activeItem->Parent == (void*)&NULL_ENTRY){ LCD_Goto(1, 0); LCD_Puts(MAIN_MENU_TEXT); } else { menuItem *parItem = (void*)activeItem->Parent; LCD_Goto(1, 0); LCD_Puts(parItem->Text); } /*After that we print current item and two others besides it */ menuItem *parItem = (void*)activeItem; //come back to first item in current page int i; if(activeItem->Index <= FIELDS_NUMBER-1) i = activeItem->Index;//if we situated in 1-st page else i = activeItem->Index % FIELDS_NUMBER;//if we situated in the one of others pages for(; i > 0; i--) parItem = (void*)parItem->Previous; //and print points items on display for(i = 0; i < FIELDS_NUMBER; i++) { LCD_Goto(2, i+1); LCD_Puts(parItem->Text); if((void*)parItem->Next != (void*)&NULL_ENTRY) parItem = (void*)parItem->Next; else break; } }
void showTime(uint8_t x,uint8_t y ,uint16_t value){ uint8_t sec=value%60; uint8_t minute=(value%3600)/60; uint8_t hour=value/3600; if(sec==0){ LCD_ClearField(x,y,8); } LCD_Goto(x,y); LCD_SendNumber(hour,' '); LCD_WriteData(':'); LCD_SendNumber(minute,' '); LCD_WriteData(':'); LCD_SendNumber(sec,' '); }
void printLCDMaintenanceMenu(){//done LCD_TurnOnDisplay(); LCD_Goto(0,0);LCD_WriteString("1-Set doorcode"); LCD_Goto(0,1);LCD_WriteString("2-Set admincode"); LCD_Goto(0,2);LCD_WriteString("3-Set clock"); LCD_Goto(0,3);LCD_WriteString("4-Set calendar"); LCD_Goto(0,4);LCD_WriteString("5-View history"); LCD_Goto(0,5);LCD_WriteString("A-Leave "); LCD_ClearLine(7); LCD_BL_State(1); }
int main() { init(); LCD_Init(); _delay_ms(100); LCD_Goto(0, 0); LCD_WriteCom(DISP_ON); LCD_WriteCom(CLR_DISP); _delay_ms(100); LCD_SendString(" --==START==--"); __enable_interrupt(); while(1) { /* if(!(PIN_BUT & B1)) { SEND_CMD(CLR_DISP); SEND_STR("0123456789012345ABCDEFGH"); } if(!(PIN_BUT & B2)){ SEND_CMD(DISP_CUR2); } if(!(PIN_BUT & B3)) { char temp[]="ABCDEFGHabcdefgh!\n\r0123456789\n\r"; //for(uint8_t i=0; i<sizeof(temp); i++) usart1_write(temp[i]); } if(!(PIN_BUT & B4)) { char temp[]="ABCDEFGHabcdefgh!\n0123456789\n"; //usart1_write_str(temp); } */ } }
int main() { //time init structure struct tm ti; struct tm ret; //RTC_SetTime(14,20,00); ti.tm_hour = 14; ti.tm_min = 20; ti.tm_sec = 00; //RTC_SetDate(8,11,2013); ti.tm_mday = 8; ti.tm_mon = 11; ti.tm_year = 2013; //RTC_SetDays(5 ,365); ti.tm_wday = 5; ti.tm_yday = 365; SYSCLK_Init(1000); /* Acertar o clock do TIMER*/ RTC_Init(&ti); LCD_Init(); char buffer [16]; while(1) { RTC_GetValue(&ret); LCD_Goto(0,0); strftime(buffer,16,"%T",&ret); LCD_WriteString(buffer); } return 0; }
void drawGameOver(int score, int time){ LCD_DrawFilledRect(boardX,boardY,boardLen,boardLen,BLACK); LCD_SetTextColor(255,255,240); LCD_Goto(30,5); printf("GAME OVER"); LCD_Goto(23,8); printf("Score:"); LCD_Goto(29,8); LCD_PrintInteger(score); LCD_Goto(23,10); printf("Time:"); LCD_Goto(28,10); LCD_PrintInteger(time); LCD_Goto(29,19); printf("Play Again?"); LCD_DrawRect(170,166,72,16,WHITE); }
void alCleaning() { LCD_Clear(); LCD_Goto(1, 0); LCD_Puts("Cleaning..."); //enable screw ignition enableDev(&screwIgn); startTimerDevice(&ScrewIgnTimer, 15); while(ScrewIgnTimer.CurrentState == ENABLE_TIM);//wait while Screw ign timer working enableDev(&outFireBar); startTimerDevice(&FireBarTimer,15); while(FireBarTimer.CurrentState == ENABLE_TIM);//wait while FireBar timer working // workState = END_WORK; //here will be fan /*enableDev(&outFireBar); startTimerDevice(&FireBarTimer,15); while(FireBarTimer.CurrentState == ENABLE_TIM);//wait while FireBar timer working */ }
void showWinSettings(uint8_t x,uint8_t y ,uint16_t value){ LCD_ClearField(x,y,16); LCD_Goto(x,y); switch(value){ case DISPLAY_P0: LCD_SendStr(" U off"); break; case DISPLAY_P1: LCD_SendStr(" U discharge"); break; case DISPLAY_P2: LCD_SendStr(" I discharge"); break; case DISPLAY_P3: LCD_SendStr(" I charge"); break; case DISPLAY_P4: LCD_SendStr(" Mode A or M"); break; case DISPLAY_P5: LCD_SendStr(" N Disch_Charge"); break; } }
//GAME int main(void){unsigned long i=64,j=0; PLL_Init(); // Set the clocking to run at 80MHz from the PLL. LCD_Init(); // Initialize LCD Piano_Init(); Sound_Init(); ADC_Init(); //initialize ADC ADC_SetChannel(1); //PE2 Missile_Init(); Enemy1_Init(); LCD_Goto(10,0); LCD_SetTextColor(255,0,0); // yellow= red+green, no blue printf("Welcome to Pokemon Capture!"); delay_long(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); while((GPIO_PORTE_DATA_R&0x01)==0){ LCD_Goto(10,0); printf("Press any button to begin..."); delay_blink(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_blink(); } delay_short(); LCD_SetTextColor(255,255,0); LCD_Goto(0,0); printf("Tragedy has struck Pallet Town! Four Pokemon have escaped from their Pokeballs, and it's your job to put them back where they belong."); delay_long(); delay_long(); delay_long(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); LCD_Goto(0,0); printf("Use the slider to aim, and when you think you have a shot, press the button to throw your Pokeball."); delay_long(); delay_long(); delay_long(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_blink(); LCD_Goto(0,0); printf("You only have so many Pokeballs, so be smart where you throw them!"); delay_long(); delay_long(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); LCD_Goto(0,0); printf("Good luck!"); delay_long(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); LCD_SetTextColor(255,0,0); LCD_Goto(0,0); printf("Captured:"); LCD_SetTextColor(0,255,0); LCD_Goto(14,0); printf("Pokeballs Left:"); LCD_SetTextColor(0,0,255); LCD_Goto(35,0); printf("Accuracy:"); LCD_DrawLine(10,16,310,16,BURNTORANGE); Timer2_Init(7256); // 11kHz SysTick_Init(2666667); //30 Hz EnableInterrupts(); Pokeballs = 25; while(1){ if((25-(hits+misses))==0){ if(kill!=4){ DisableInterrupts(); LCD_SetTextColor(255,0,0); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); LCD_Goto(0,0); printf("Sorry, you were not able to catch all the Pokemon."); delay_long(); delay_long(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); LCD_Goto(0,0); printf("Try again."); delay_long(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); while(1){ LCD_Goto(0,0); printf("Press RESET to play again."); delay_blink(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_blink(); } } } if(kill==4){ DisableInterrupts(); LCD_SetTextColor(0,255,255); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); LCD_Goto(0,0); printf("Congratulations! You have captured all the Pokemon!"); delay_long(); delay_long(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); LCD_Goto(0,0); printf("You are now a Pokemon Master!"); delay_long(); delay_long(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_short(); while(1){ LCD_Goto(0,0); printf("Press RESET to play again."); delay_blink(); LCD_DrawFilledRect(0,0,320,80,0x00); delay_blink(); } } if(Semaphore){ LCD_SetTextColor(255,0,0); LCD_Goto(10,0); LCD_PrintInteger(kill); LCD_SetTextColor(0,255,0); LCD_Goto(30,0); LCD_PrintInteger(25-(hits+misses)); if((25-(hits+misses))<10){ LCD_Goto(31,0); printf(" "); } LCD_SetTextColor(0,0,255); LCD_Goto(45,0); LCD_PrintInteger(hits/(hits+misses)); //draw ship if(Ship_Position>288){ Ship_Position=288; } LCD_DrawBMP(PlayerShip,Ship_Position,220); LCD_DrawFilledRect(0,220,Ship_Position,9,0x00); LCD_DrawFilledRect(Ship_Position+32,220,320-(Ship_Position+32),9,0x00); for(j=0;j<1;j++){ if(Missile[j].life==1){ LCD_DrawBMP(Missile[j].image, Missile[j].x, Missile[j].y); } else{ LCD_DrawFilledRect(Missile[j].x,Missile[j].y,16,18,0x00); } if(Missile[j].y<=18){ LCD_DrawFilledRect(Missile[j].x,Missile[j].y,16,18,0x00); Missile[j].life=0; misses++; } } for(i=0;i<4;i++){ if(Enemy1[i].life!=0){ LCD_DrawBMP(Enemy1[i].image,Enemy1[i].x,Enemy1[i].y); } else{ LCD_DrawFilledRect(Enemy1[i].x,Enemy1[i].y,32,32,0x00); } } LCD_DrawFilledRect(0,17,320,4,0x00); Semaphore = 0; } } }
void gameOverHighscore(int score){ LCD_Goto(23,12); printf("NEW HIGHSCORE!"); }
void showCurrentDisplay(uint8_t display){ LCD_Clear(); switch(display){ case DISPLAY_START: LCD_Goto(0,0); LCD_SendStr("V="); LCD_Goto(0,1); LCD_SendStr("I="); LCD_Goto(8,0); LCD_SendStr("M="); break; case DISPLAY_FAST_CHANGE: LCD_Goto(0,0); LCD_SendStr("CHARGE DISCHARGE"); break; case DISPLAY_PROGR: LCD_Goto(0,0); LCD_SendStr("WINDOWS SETTING"); break; case DISPLAY_P0: LCD_Goto(0,1); LCD_SendStr("U Normal"); break; case DISPLAY_P1: LCD_Goto(0,1); LCD_SendStr("U Discharge"); break; case DISPLAY_P2: LCD_Goto(0,0); LCD_SendStr("I Discharge"); break; case DISPLAY_P3: LCD_Goto(0,0); LCD_SendStr("I Сharge"); LCD_Goto(0,1); LCD_SendStr("Norm.I="); break; case DISPLAY_P4: LCD_Goto(0,0); LCD_SendStr("Automat or Manual"); break; case DISPLAY_P5: LCD_Goto(0,0); LCD_SendStr("N DischargeCharg"); break; } }
void eraseTime(void){ LCD_Goto(2,13); LCD_SetTextColor(0,0,0); LCD_PrintInteger(99999999); }
void writeTime(int time){ LCD_Goto(2,13); LCD_SetTextColor(255,255,240); LCD_PrintInteger(time); }
void writeHighscore(int score){ LCD_Goto(2,16); LCD_SetTextColor(255,255,240); LCD_PrintInteger(score); }
void eraseScore(void){ LCD_Goto(2,10); LCD_SetTextColor(0,0,0); LCD_PrintInteger(99999999); }
void showAndSetValue(uint8_t display ,volatile uint16_t *array,volatile uint8_t *array8){ switch(display){ case DISPLAY_START: { volatile uint16_t time=(array8[charge])? chargeTime:dischargeTime; volatile uint8_t index=(array8[charge])? oldChargeTime:oldDischargeTime; if(array[index]!=time){ array[index]=time; showTime(8,1,time); } } if(array[oldCurrentVoltage]!=array[currentVoltage]){ array[oldCurrentVoltage]=array[currentVoltage]; showADC(2,0,array[currentVoltage]); } if(array[oldCurrentAmperage]!=array[currentAmperage]){ array[oldCurrentAmperage]=array[currentAmperage]; LCD_Goto(2,1); volatile uint8_t ch=(array8[charge])? '+':'-'; LCD_WriteData(ch); showADC(3,1,array[currentAmperage]); } if(array[oldCurrentPWM]!=array[currentPWM]){ array[oldCurrentPWM]=array[currentPWM]; showPWM(10,0,array[currentPWM]); setPwm(array[currentPWM]); } if(array8[oldNumDischargeCharge]!=array8[numDischargeCharge]){ array8[oldNumDischargeCharge]=array8[numDischargeCharge]; LCD_Goto(14,0); LCD_SendNumber(array8[numDischargeCharge],' '); } break; case DISPLAY_FAST_CHANGE: if(array8[oldCharge]!=array8[charge]){ array8[oldCharge]=array8[charge]; LCD_ClearField(0,1,9); LCD_Goto(0,1); if(array8[charge]){ LCD_SendStr("Charge"); BM_ClearBit(TCCR1A,COM1A0); SET_CHARGE; }else{ LCD_SendStr("Discharge"); BM_SetBit(TCCR1A,COM1A0); SET_DISCHARGE; } } break; case DISPLAY_PROGR: if(array[oldWindowsSettings]!=array[windowsSettings]){ array[oldWindowsSettings]=array[windowsSettings]; showWinSettings(0,1,DISPLAY_PROGR+array[windowsSettings]); } break; case DISPLAY_P0: if(array[oldNormalVoltage]!=array[normalVoltage]){ array[oldNormalVoltage]=array[normalVoltage]; showADC(0,0,array[normalVoltage]); } break; case DISPLAY_P1: if(array[oldDischargeVoltage]!=array[dischargeVoltage]){ array[oldDischargeVoltage]=array[dischargeVoltage]; showADC(0,0,array[dischargeVoltage]); } break; case DISPLAY_P2: if(array[oldDischargeAmperage]!=array[dischargeAmperage]){ array[oldDischargeAmperage]=array[dischargeAmperage]; showADC(0,1,array[dischargeAmperage]); } break; case DISPLAY_P3: if(array[oldNormalAmperage]!=array[normalAmperage]){ array[oldNormalAmperage]=array[normalAmperage]; showADC(7,1,array[normalAmperage]); } break; case DISPLAY_P4: if(array8[oldAutomatic]!=array8[automatic]){ array8[oldAutomatic]=array8[automatic]; LCD_ClearField(0,1,9); LCD_Goto(0,1); if(array8[automatic]){ LCD_SendStr("Automatic"); } else { LCD_SendStr("Manual"); } } break; case DISPLAY_P5: if(array8[oldNumDischargeCharge]!=array8[numDischargeCharge]){ array8[oldNumDischargeCharge]=array8[numDischargeCharge]; LCD_ClearField(0,1,3); LCD_Goto(0,1); LCD_SendNumber(array8[numDischargeCharge],' '); } break; } }