int main(void){ TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz Random_Init(1); Nokia5110_Init(); Nokia5110_ClearBuffer(); Nokia5110_DisplayBuffer(); // draw buffer Nokia5110_PrintBMP(32, 47, PlayerShip0, 0); // player ship middle bottom Nokia5110_PrintBMP(33, 47 - PLAYERH, Bunker0, 0); Nokia5110_PrintBMP(0, ENEMY10H - 1, SmallEnemy10PointA, 0); Nokia5110_PrintBMP(16, ENEMY10H - 1, SmallEnemy20PointA, 0); Nokia5110_PrintBMP(32, ENEMY10H - 1, SmallEnemy20PointA, 0); Nokia5110_PrintBMP(48, ENEMY10H - 1, SmallEnemy30PointA, 0); Nokia5110_PrintBMP(64, ENEMY10H - 1, SmallEnemy30PointA, 0); Nokia5110_DisplayBuffer(); // draw buffer Delay100ms(50); // delay 5 sec at 50 MHz Nokia5110_Clear(); Nokia5110_SetCursor(1, 1); Nokia5110_OutString("GAME OVER"); Nokia5110_SetCursor(1, 2); Nokia5110_OutString("Nice try,"); Nokia5110_SetCursor(1, 3); Nokia5110_OutString("Earthling!"); Nokia5110_SetCursor(2, 4); Nokia5110_OutUDec(1234); while(1){ } }
int main(void){ volatile unsigned long delay; //TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_NoScope); TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_Scope); ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 Nokia5110_Init(); // initialize Nokia5110 LCD SysTick_Init(1999999); // initialize SysTick for 40 Hz interrupts // initialize profiling on PF1 (optional) // wait for clock to stabilize SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF; // activate port F delay = SYSCTL_RCGC2_R; GPIO_PORTF_DIR_R |= 0x04; // make PF2 out (built-in LED) GPIO_PORTF_AFSEL_R &= ~0x04; // disable alt funct on PF2 GPIO_PORTF_DEN_R |= 0x04; // enable digital I/O on PF2 // configure PF2 as GPIO GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF)+0x00000000; GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PF EnableInterrupts(); Nokia5110_Clear(); Nokia5110_OutString((unsigned char *)"UT.6.01x Lab 14 Start"); while(1){ if(Flag) { UART_ConvertDistance(Distance); Nokia5110_SetCursor(0, 3); Nokia5110_OutString(String); Flag = 0; } } }
//********Nokia5110_DrawFullImage***************** // Fill the whole screen by drawing a 48x84 bitmap image. // inputs: ptr pointer to 504 byte bitmap // outputs: none // assumes: LCD is in default horizontal addressing mode (V = 0) void Nokia5110_DrawFullImage(const char *ptr){ int i; Nokia5110_SetCursor(0, 0); for(i=0; i<(MAX_X*MAX_Y/8); i=i+1){ lcdwrite(DATA, ptr[i]); } }
//********Nokia5110_Clear***************** // Clear the LCD by writing zeros to the entire screen and // reset the cursor to (0,0) (top left corner of screen). // inputs: none // outputs: none void Nokia5110_Clear(void){ int i; for(i=0; i<(MAX_X*MAX_Y/8); i=i+1){ lcdwrite(DATA, 0x00); } Nokia5110_SetCursor(0, 0); }
int main(void){ uint32_t count = 0; PLL_Init(); // set system clock to 50 MHz Nokia5110_Init(); Nokia5110_Clear(); for(count=0; count<1; count=count+1){ Nokia5110_DrawFullImage(Longhorn); Delay(16666667); // delay ~1 sec at 50 MHz Nokia5110_DrawFullImage(Longhorn2); Delay(16666667); // delay ~1 sec at 50 MHz } // count = 0; Nokia5110_Clear(); // Nokia5110_OutString("************* LCD Test *************Letter: Num:------- ---- "); //Nokia5110_OutChar(127); // print UT sign while(1){ Nokia5110_SetCursor(0,0); Nokia5110_OutString("Hello World"); Nokia5110_OutString(" bright future"); Delay(8333333); // delay ~0.5 sec at 50 MHz //count = count + 1; } }
// once the ADC and convert to distance functions are operational, // you should use this main to build the final solution with interrupts and mailbox int main(void){ TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_Scope); //ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 Nokia5110_Init(); // initialize Nokia5110 LCD (optional) //SysTick_Init(1999999); // initialize SysTick for 40 Hz interrupts Flag = 0; EnableInterrupts(); // print a welcome message (optional) //Nokia5110_Clear(); //Nokia5110_OutString((unsigned char *)"UT.6.01x Lab 14 Start"); Nokia5110_Clear(); Nokia5110_SetCursor(0, 0); Nokia5110_OutString("Tekstiseina"); while(1){ // read mailbox //if (Flag == 1) { //Flag = 0; //ADCdata = ADC0_In(); //Distance = Convert(ADCdata) + 1; //UART_ConvertDistance(Distance); // from Lab 11 //Nokia5110_Clear(); //Nokia5110_SetCursor(0, 0); //Nokia5110_OutString(String); // output to Nokia5110 LCD (optional) //UART_OutString(String); //UART_OutString("\n"); //} } }
//********Nokia5110_DrawFullImage***************** // Fill the whole screen by drawing a 48x84 bitmap image. // inputs: ptr pointer to 504 byte bitmap // outputs: none // assumes: LCD is in default horizontal addressing mode (V = 0) void Nokia5110_DrawFullImage(const uint8_t *ptr){ int i; Nokia5110_SetCursor(0, 0); for(i=0; i<(MAX_X*MAX_Y/8); i=i+1){ lcddatawrite(ptr[i]); } }
int main(void){ int AnyLife = 1; int i; TExaS_Init(NoLCD_NoScope); // set system clock to 80 MHz // you cannot use both the Scope and the virtual Nokia (both need UART0) Random_Init(1); Nokia5110_Init(); EnableInterrupts(); // virtual Nokia uses UART0 interrupts Nokia5110_ClearBuffer(); Nokia5110_DisplayBuffer(); // draw buffer Nokia5110_PrintBMP(32, 47, PlayerShip0, 0); // player ship middle bottom Nokia5110_PrintBMP(33, 47 - PLAYERH, Bunker0, 0); Nokia5110_PrintBMP(0, ENEMY10H - 1, SmallEnemy10PointA, 0); Nokia5110_PrintBMP(16, ENEMY10H - 1, SmallEnemy20PointA, 0); Nokia5110_PrintBMP(32, ENEMY10H - 1, SmallEnemy20PointA, 0); Nokia5110_PrintBMP(48, ENEMY10H - 1, SmallEnemy30PointA, 0); Nokia5110_PrintBMP(64, ENEMY10H - 1, SmallEnemy30PointA, 0); Nokia5110_DisplayBuffer(); // draw buffer Delay100ms(50); // delay 5 sec at 80 MHz Init(); Timer2_Init(80000000/30); // 30 Hz while(AnyLife){ while(Semaphore == 0){}; Semaphore = 0; // runs at 30 Hz AnyLife = 0; for(i=0; i<4 ; i++){ AnyLife |= Enemy[i].life; } Draw(); } Nokia5110_Clear(); Nokia5110_SetCursor(1, 1); Nokia5110_OutString("GAME OVER"); Nokia5110_SetCursor(1, 2); Nokia5110_OutString("Nice try,"); Nokia5110_SetCursor(1, 3); Nokia5110_OutString("Earthling!"); Nokia5110_SetCursor(2, 4); Nokia5110_OutUDec(1234); Nokia5110_SetCursor(0, 0); // renders screen while(1){ } }
// Clear the LCD by writing zeros to the entire screen and // reset the cursor to (0,0). void Nokia5110_Clear(void) { uint32_t i; for(i = 0; i < NUMBER_OF_OCTETS; i++) { writeData(0x00); } Nokia5110_SetCursor(0, 0); }
// Fill the whole screen by drawing a 48x84 bitmap image (504 bytes in total). void Nokia5110_WriteFullScreen(const uint8_t *ptr) { Nokia5110_SetCursor(0, 0); uint32_t i; for(i = 0; i < NUMBER_OF_OCTETS; i++) { writeData(ptr[i]); } }
void Nokia5110_Clear(void) { long i; // Write 0s in all pixels for(i= 0; i < NO_OF_PIXELS; ++i) { Nokia5110_Write(data, 0x00); } Nokia5110_SetCursor(0, 0); // reset the Cursor }
void Nokia5110_DrawImage(unsigned char *pSTR) { long i; Nokia5110_SetCursor(0, 0); for(i= 0; i < NO_OF_PIXELS; ++i) { Nokia5110_Write(data, pSTR[i]); } }
// once the ADC is operational, you can use main2 to debug the convert to distance int main2(void){ TExaS_Init(ADC0_AIN1_PIN_PE2, UART0_Emulate_Nokia5110_NoScope); ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 Nokia5110_Init(); // initialize Nokia5110 LCD EnableInterrupts(); while(1){ ADCdata = ADC0_In(); Nokia5110_SetCursor(0, 0); Distance = Convert(ADCdata); UART_ConvertDistance(Distance); // from Lab 11 Nokia5110_OutString(String); // output to Nokia5110 LCD (optional) } }
int main2(void){ // Modular testing fucntion for Convert() & UART_ConvertDistance() TExaS_Init(ADC0_AIN1_PIN_PE2, SSI0_Real_Nokia5110_NoScope); ADC0_Init(); // initialize ADC0, channel 1, sequencer 3 Nokia5110_Init(); // initialize Nokia5110 LCD EnableInterrupts(); while(1){ ADCdata = ADC0_In(); Nokia5110_SetCursor(0, 0); Distance = Convert(ADCdata); UART_ConvertDistance(Distance); // from Lab 11 Nokia5110_OutString(String); } }
void ADC0Seq3_Handler(void) { ADC0_ISC_R= 0x00000008; // ack INT SS3 Temp= 147.5 - ((75 * ADC0_SSFIFO3_R * 3.3) / 4096); // datasheet equation Nokia5110_SetCursor(0, 0); Nokia5110_PrintString("Temp:"); Nokia5110_PrintNum(POSITIVENUM, Temp); Nokia5110_PrintString("C"); if(Temp >= 35) GPIO_PORTF_DATA_R= 0x02; // red else if(Temp >= 20 && Temp <=30) GPIO_PORTF_DATA_R= 0x08; // green else if(Temp < 20) GPIO_PORTF_DATA_R= 0x4; }
int main(void){ unsigned short count = 0; PLL_Init(); // set system clock to 50 MHz Nokia5110_Init(); for(count=0; count<2; count=count+1){ Nokia5110_DrawFullImage(Longhorn); Delay(1066666); // delay ~1 sec at 50 MHz Nokia5110_DrawFullImage(Longhorn2); Delay(1066666); // delay ~1 sec at 50 MHz } count = 0; Nokia5110_Clear(); Nokia5110_OutString("************ THRILLDO ********** presents * *** The *** MaStUrBm8 ********************** "); ///("************* THRILLDO *************Letter: Num:------- ---- "); Nokia5110_OutChar(127); // while(1){ Nokia5110_SetCursor(5, 5); // five leading spaces, bottom row Nokia5110_OutChar((count%26)+'A'); Nokia5110_OutChar(' '); Nokia5110_OutUDec(count); Delay(8333333); // delay ~0.5 sec at 50 MHz count = count + 1; } }
int main(void) { int delay; float fTemperature, fPressure, fAltitude, fK_Altitude, fAltitude_sum,fK_Altitude_sum; int count,i; // static float f_meas[VAR_COUNT], fAlt_Mean, fAlt_Var; unsigned short sw1_count, sw2_count; unsigned char sw1_was_cleared = 0, sw2_was_cleared = 0; // Set the clocking to run directly from the external crystal/oscillator. MAP_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | WRFL_XTAL); //init ports and peripherals PlatformInit(); Nokia5110_Init(); Nokia5110_Clear(); Nokia5110_DrawFullImage(gears_logo); for(delay=0; delay<1000000; delay=delay+1); Nokia5110_Clear(); Nokia5110_SetCursor(3, 1); Nokia5110_OutString("WRFL"); Nokia5110_SetCursor(1, 2); Nokia5110_OutString("Prototype"); Nokia5110_SetCursor(2, 4); Nokia5110_OutString("VER 0.1"); Nokia5110_SetCursor(0, 5); Nokia5110_OutString("NightMecanic"); for(delay=0; delay<1000000; delay=delay+1); Nokia5110_Clear(); // // Enable interrupts to the processor. // MAP_IntMasterEnable(); // // Initialize I2C1 peripheral. // I2CMInit(&g_sI2CInst, BMP180_I2C_BASE, BMP180_I2C_INT, 0xff, 0xff, MAP_SysCtlClockGet()); // // Initialize the BMP180 // BMP180Init(&g_sBMP180Inst, &g_sI2CInst, BMP180_I2C_ADDRESS, BMP180AppCallback, &g_sBMP180Inst); // // Wait for initialization callback to indicate reset request is complete. // while(g_vui8DataFlag == 0) { // // Wait for I2C Transactions to complete. // } // // Reset the data ready flag // g_vui8DataFlag = 0; //set oversampling to 8x g_sBMP180Inst.ui8Mode = 0xC0; //Initialize the Kalman filter Kalman_Init(&Alt_KState, 0.0f, 1.0f, ALT_KALMAN_R, ALT_KALMAN_Q); // // Enable the system ticks at 10 hz. // MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / (40 * 3)); MAP_SysTickIntEnable(); MAP_SysTickEnable(); Nokia5110_SetCursor(0, 0); Nokia5110_OutString("SW1:"); Nokia5110_SetCursor(0, 2); Nokia5110_OutString("SW2:"); //config done count = 0; // // Begin the data collection and printing. Loop Forever. // while(1) { // SW1 if (sw_state & SW1){ if (sw1_was_cleared){ sw1_was_cleared = 0; sw1_count++; Nokia5110_SetCursor(5, 0); Nokia5110_OutUDec(sw1_count); } }else sw1_was_cleared = 1; //SW2 if (sw_state & SW2){ if (sw2_was_cleared){ sw2_was_cleared = 0; sw2_count++; Nokia5110_SetCursor(5, 2); Nokia5110_OutUDec(sw2_count); } }else sw2_was_cleared = 1; // handle BMP180 data (display average every 50 samples) if (g_vui8DataFlag ){ // // Reset the data ready flag. // g_vui8DataFlag = 0; // // Get a local copy of the latest temperature data in float format. // BMP180DataTemperatureGetFloat(&g_sBMP180Inst, &fTemperature); // // Print temperature with three digits of decimal precision. // //Nokia5110_SetCursor(0, 0); //Nokia5110_OutString("Temp:"); //Nokia5110_OutFloatp3(fTemperature); // // Get a local copy of the latest air pressure data in float format. // BMP180DataPressureGetFloat(&g_sBMP180Inst, &fPressure); // // Print Pressure with three digits of decimal precision. // //Nokia5110_SetCursor(0, 1); // Nokia5110_OutString("Pres:"); //Nokia5110_SetCursor(0, 2); //display in hPa //Nokia5110_OutFloatp3((fPressure / 100.0f)); // // Calculate the altitude. // //fAltitude = 44330.0f * (1.0f - powf(fPressure / 101325.0f, // 1.0f / 5.255f)); //corrected: fAltitude = 44330.0f * (1.0f - powf(fPressure / LOC_ALT_P0, 1.0f / 5.255f)); // Kalman filtered altitude Kalman_Update (&Alt_KState, fAltitude); fK_Altitude = Alt_KState.X; fAltitude_sum += fAltitude; fK_Altitude_sum += fK_Altitude; count++; if (count>=50){ Nokia5110_SetCursor(0, 3); Nokia5110_OutString("Alt:"); Nokia5110_OutFloatp3(fAltitude_sum/50.0); Nokia5110_SetCursor(0, 5); Nokia5110_OutString("KAlt:"); Nokia5110_OutFloatp3(fK_Altitude_sum/50.0); fAltitude_sum = 0; fK_Altitude_sum = 0; count = 0; } /* //calculate variance f_meas[count]=fK_Altitude; count++; if (count>=VAR_COUNT){ fAlt_Mean = 0.0f; fAlt_Var = 0.0f; // calculate mean for(i=0; i<VAR_COUNT; i++){ fAlt_Mean = fAlt_Mean +f_meas[i]; } fAlt_Mean = fAlt_Mean/((float) VAR_COUNT); // Calculate Var for(i=0; i<VAR_COUNT; i++){ fAlt_Var = fAlt_Var + powf((f_meas[i] - fAlt_Mean),2.0f); } fAlt_Var = fAlt_Var/((float) VAR_COUNT); // // Print altitude with three digits of decimal precision. // Nokia5110_SetCursor(0, 4); Nokia5110_OutString("Var:"); Nokia5110_OutFloatp3(fAlt_Var); count = 0; } */ // // Delay to keep printing speed reasonable. About 100msec. // //MAP_SysCtlDelay(MAP_SysCtlClockGet() / (10 * 3)); } }//while end }
int main(void){ int32_t retVal = 0; char *pConfig = NULL; retVal = initializeAppVariables(); stopWDT(); // Stop WDT initClk(); // PLL 50 MHz LCD_Init(); LED_Init(); // initialize LaunchPad I/O // LCD_OutString("Weather App\n"); LCD_OutString("Lab 16 IoT\n"); /* * Following function configures the device to default state by cleaning * the persistent settings stored in NVMEM (viz. connection profiles & * policies, power policy etc) * * Applications may choose to skip this step if the developer is sure * that the device is in its default state at start of application * * Note that all profiles and persistent settings that were done on the * device will be lost */ retVal = configureSimpleLinkToDefaultState(pConfig); if(retVal < 0){ if(DEVICE_NOT_IN_STATION_MODE == retVal){ LCD_OutString(" Failed to configure the device in its default state \r\n"); Crash(4000000); } } /* * Assumption is that the device is configured in station mode already * and it is in its default state */ retVal = sl_Start(0, pConfig, 0); if((retVal < 0) || (ROLE_STA != retVal) ){ LCD_OutString(" Failed to start the device \r\n"); Crash(8000000); } WlanConnect(); LCD_OutString("Connected\n"); /* Get weather report */ while(1){ Nokia5110_SetCursor(0,2); // retVal = getWeather(); retVal = Lab16(); if(retVal == 0){ // valid LED_GreenOn(); UARTprintf("\r\n\r\n"); UARToutString(appData.Recvbuff); UARTprintf("\r\n"); // LCD_OutString(City); LCD_OutString("\n"); // LCD_OutString(Temperature); LCD_OutString(" C\n"); // LCD_OutString(Weather); LCD_OutString(Id); LCD_OutString("\n"); LCD_OutString(Score); LCD_OutString("\n"); LCD_OutString(Edxpost); } while(Board_Input()==0){}; // wait for touch LED_GreenOff(); } }
void Timer2A_Handler(void){ ST enemy; TIMER2_ICR_R = 0x00000001; // acknowledge timer2A timeout q++; d=(Random())%4; k=(Random())%4; s=(d+k)%4; if(q<10){ enemy.x=Enemy[s].x; enemy.y=Enemy[s].y; enemy.life=1; enemy.b=0; enemy.image[0]=Black; enemy.image[1]=Dead; } else { enemy.x=Enemy[s].x; enemy.y=Enemy[s].y; enemy.life=1; enemy.image[0]=bomp; enemy.image[1]=bomp; enemy.b=1; q=0; } for(i=0;i<30;i++) { if(vector[i].fl==0) { vector[i]=enemy; vector[i].fl=1; vector[i].life=1; o++; break; } } Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(LFish.x, LFish.y, LFish.image[0], 0); for(p=0;p<30;p++){ if(vector[p].fl==1 && vector[p].life==1){ if(vector[p].x >0){ vector[p].x -= 10; if(((((LFish.y-16)<vector[p].y) && (vector[p].y<=(LFish.y)))||((vector[p].y-16)<LFish.y && (vector[p].y-16)<LFish.y))&& (vector[p].x<=17) && (vector[p].b==0 )) { Score+=10; vector[p].life=0; Nokia5110_PrintBMP(vector[p].x, vector[p].y,vector[p].image[1], 0); o--; } else if((((LFish.y-16)<vector[p].y)&& (vector[p].y<=(LFish.y+4))) &&(vector[p].x<=17) && vector[p].b==1){ Nokia5110_ClearBuffer(); Nokia5110_DisplayBuffer(); Nokia5110_SetCursor(1, 1); Nokia5110_OutString("GAME OVER"); Nokia5110_SetCursor(1, 2); Nokia5110_OutString("Nice try,"); Nokia5110_SetCursor(1, 4); Nokia5110_OutString("Score: "); Nokia5110_SetCursor(6, 4); Nokia5110_OutUDec(Score); Delay100ms(50); exit(0); } else Nokia5110_PrintBMP(vector[p].x, vector[p].y,vector[p].image[0], 0); } else if (vector[p].x==0){ vector[p].fl=0; vector[p].life=0; o--; } } if(p>=o)break; } Nokia5110_DisplayBuffer(); }