/* LCD Demo with an LCD having two E lines (E1 and E2): that makes 2x2 lines */ static void LCD_Demo1(void) { uint8_t cnt; uint8_t buf[5]; LCD1_UseDisplay(1); /* switch to upper/first display */ LCD1_Clear(); LCD1_WriteLineStr(1, "LCD Line 1"); LCD1_WriteLineStr(2, "LCD Line 2"); LCD1_UseDisplay(2); /* switch to second display */ LCD1_Clear(); LCD1_WriteLineStr(1, "Hello LCD 3"); LCD1_WriteLineStr(2, "Hello LCD 4"); cnt = 0; for(;;) { UTIL1_Num16uToStr(buf, sizeof(buf), cnt); LCD1_UseDisplay(1); /* switch to first display */ LCD1_GotoXY(2,1); LCD1_WriteString((char*)buf); LCD1_UseDisplay(2); /* switch to second display */ LCD1_GotoXY(2,1); LCD1_WriteString((char*)buf); cnt++; WAIT1_Waitms(100); } }
/*lint -save -e970 Disable MISRA rule (6.3) checking. */ int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ { /* Write your local variable definition here */ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ /* Write your code here */ /* For example: for(;;) { } */ LCD1_Clear(); WAIT1_Waitms(1000); LCD1_WriteLineStr(1, "Hello FRDM-KL25z"); for(;;) { uint8_t cnt; uint8_t buf[5]; LCD1_GotoXY(2,1); UTIL1_Num16uToStr(buf, sizeof(buf), cnt); LCD1_WriteString((char*)buf); cnt++; WAIT1_Waitms(100); } /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/ #ifdef PEX_RTOS_START PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of RTOS startup code. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
static void LCD_Demo1(void) { uint8_t cnt; uint8_t buf[5]; LCD1_Clear(); LCD1_WriteLineStr(1, "Hello FRDM-KL25Z"); cnt = 0; for(;;) { LCD1_GotoXY(2,1); UTIL1_Num16uToStr(buf, sizeof(buf), cnt); LCD1_WriteString((char*)buf); cnt++; WAIT1_Waitms(100); } }
void BL_Bootloader(void) { S191_FileStatus fileStatus; DisableInterrupts; #if PL_HAS_HW_SOUNDER Beep(1); #endif #if PL_BOOTLOADER_LCD if (JM_ELE_GetVal()!=0) { /* JM_ELE switch is off: the JM128 is controlling the LCD */ LCD1_Init(); LCD1_Clear(); } PrintLCDText(0, "Bootloader mode: waiting for S19 file..."); #endif BLUSB1_InitUSB(); fileStatus = S191_FILE_STATUS_NOT_STARTED; for(;;) { BLUSB1_PollAndProcessUSB(&fileStatus); /* Poll USB device for any input device */ if(fileStatus==S191_FILE_STATUS_READING) { #if PL_BOOTLOADER_LCD PrintLCDText(1, "Loading S19 file..."); #endif BL_flashErased = FALSE; BLUSB1_ReadAndProcessS19(&fileStatus); switch(fileStatus) { case S191_FILE_STATUS_FINISHED: #if PL_BOOTLOADER_LCD PrintLCDText(2, "Loading successful!\nYou can reset the board now."); #endif #if PL_HAS_HW_SOUNDER Beep(1); #endif break; case S191_FILE_ERASE_FAILED: #if PL_BOOTLOADER_LCD PrintLCDText(2, "*** Flash erase error! ***"); #endif #if PL_HAS_HW_SOUNDER Beep(4); #endif break; case S191_FILE_FLASH_FAILED: #if PL_BOOTLOADER_LCD PrintLCDText(2, "*** Flash programming error! ***"); #endif #if PL_HAS_HW_SOUNDER Beep(6); #endif break; default: #if PL_BOOTLOADER_LCD PrintLCDText(2, "*** Error processing file! ***"); #endif #if PL_HAS_HW_SOUNDER Beep(8); #endif break; } /* switch */ } /* if */ } /* for */ }
void APP_Run(void) { int i; FDisp1_PixelDim x, y; LCD1_Init(); LCD1_Clear(); #if 1 GDisp1_DrawFilledBox(0, 0, GDisp1_GetWidth()-1, GDisp1_GetHeight()-1, LCD1_COLOR_WHITE); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, GDisp1_GetWidth()-1, GDisp1_GetHeight()-1, LCD1_COLOR_RED); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, GDisp1_GetWidth()-1, GDisp1_GetHeight()-1, LCD1_COLOR_GREEN); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, GDisp1_GetWidth()-1, GDisp1_GetHeight()-1, LCD1_COLOR_BLUE); GDisp1_UpdateFull(); GDisp1_Clear(); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, 128, 128, LCD1_COLOR_RED); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(0, 0, 50, 10, LCD1_COLOR_YELLOW); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT); GDisp1_DrawFilledBox(0, 0, 100, 20, LCD1_COLOR_YELLOW); GDisp1_UpdateFull(); x = 0; y = 0; FDisp1_WriteString("Portrait", LCD1_COLOR_RED, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE); GDisp1_DrawFilledBox(0, 0, 100, 20, LCD1_COLOR_ORANGE); x = 0; y = 0; FDisp1_WriteString("Landscape", LCD1_COLOR_GREEN, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT180); GDisp1_DrawFilledBox(0, 0, 100, 20, LCD1_COLOR_RED); x = 0; y = 0; FDisp1_WriteString("Portrait180", LCD1_COLOR_BLUE, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE180); GDisp1_DrawFilledBox(0, 0, 100, 20, LCD1_COLOR_BRIGHT_GREEN); x = 0; y = 0; FDisp1_WriteString("Landscape180", LCD1_COLOR_WHITE, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); #if 0 LCD1_OpenWindow(0, 0, (LCD1_PixelDim)(LCD1_GetWidth()-1), (LCD1_PixelDim)(LCD1_GetHeight()-1)); /* window for whole display */ for(i=0;i<500;i++) { LCD1_WriteDataWord(LCD1_COLOR_YELLOW); } LCD1_CloseWindow(); #endif LCD1_Clear(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT); GDisp1_DrawLine(0, 0, 10, 50, LCD1_COLOR_RED); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE); GDisp1_DrawLine(0, 0, 10, 50, LCD1_COLOR_GREEN); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE180); GDisp1_DrawLine(0, 0, 10, 50, LCD1_COLOR_BLUE); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT180); GDisp1_DrawLine(0, 0, 10, 50, LCD1_COLOR_WHITE); LCD1_Clear(); //GDisp1_DrawFilledBox(0, 0, 20, 40, LCD1_COLOR_WHITE); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_PORTRAIT180); GDisp1_DrawFilledBox(0, 0, 20, 40, LCD1_COLOR_RED); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE); GDisp1_DrawFilledBox(0, 0, 20, 40, LCD1_COLOR_GREEN); GDisp1_UpdateFull(); LCD1_SetDisplayOrientation(LCD1_ORIENTATION_LANDSCAPE180); GDisp1_DrawFilledBox(0, 0, 20, 40, LCD1_COLOR_BLUE); GDisp1_UpdateFull(); GDisp1_DrawFilledBox(50, 50, 20, 30, LCD1_COLOR_RED); GDisp1_DrawFilledBox(0, 0, 96, 96, LCD1_COLOR_BLUE); GDisp1_DrawBox(0, 0, GDisp1_GetWidth(), GDisp1_GetHeight(), 1, LCD1_COLOR_GREEN); x = 0; y = 0; FDisp1_WriteString("Hello", LCD1_COLOR_GREEN, &x, &y, Helv14_GetFont()); GDisp1_UpdateFull(); float f = sin(f+1); EYES_Init(); for(;;) { EYES_Run(); // SpeedTest(); LED1_Neg(); WAIT1_Waitms(100); LED2_Neg(); WAIT1_Waitms(100); LED3_Neg(); WAIT1_Waitms(100); } #endif }
/*lint -save -e970 Disable MISRA rule (6.3) checking. */ int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ { /* Write your local variable definition here */ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ //printf("HOLA MUNDO"); /* Write your code here */ /* For example: for(;;) { } */ byte MPU_PWR=0x6B; int16_t AcX,AcY,AcZ,GcX,GcY,GcZ,temp; char buffer[15]; uint8_t aux[15]; //Inicializando la comunicacion I2C GI2C1_Init(); GI2C1_SelectSlave(MPU); GI2C1_WriteByteAddress8(MPU,MPU_PWR,0); //Inicializando la comunicacion LCD LCD1_UseDisplay(1); LCD1_Clear(); for(;;) { //Lectura de los Valores del Acelerometro GI2C1_ReadByteAddress8(MPU,0x3B,&buffer[1]); mywait_Waitms(2); GI2C1_ReadByteAddress8(MPU,0x3C,&buffer[2]); mywait_Waitms(2); AcX=buffer[1]; AcX=AcX<<8; AcX=AcX | buffer[2]; GI2C1_ReadByteAddress8(MPU,0x3D,&buffer[3]); mywait_Waitms(2); GI2C1_ReadByteAddress8(MPU,0x3E,&buffer[4]); mywait_Waitms(2); AcY=buffer[3]; AcY=AcY<<8; AcY=AcY | buffer[4]; GI2C1_ReadByteAddress8(MPU,0x3F,&buffer[5]); mywait_Waitms(2); GI2C1_ReadByteAddress8(MPU,0x40,&buffer[6]); mywait_Waitms(2); AcZ=buffer[5]; AcZ=AcZ<<8; AcZ=AcZ | buffer[6]; printf("Acelerometro\nX=%d\tY=%d\tZ=%d\n", AcX,AcY,AcZ); LCD1_WriteLineStr(1,"Acelerometro: "); UTIL1_Num16sToStr(aux, sizeof(aux), AcX); LCD1_WriteLineStr(2," "); LCD1_GotoXY(2,1); LCD1_WriteString("X="); LCD1_GotoXY(2,4); LCD1_WriteString((char*)aux); mywait_Waitms(2000); UTIL1_Num16sToStr(aux, sizeof(aux), AcY); LCD1_WriteLineStr(2," "); LCD1_GotoXY(2,1); LCD1_WriteString("Y="); LCD1_GotoXY(2,4); LCD1_WriteString((char*)aux); mywait_Waitms(2000); UTIL1_Num16sToStr(aux, sizeof(aux), AcZ); LCD1_WriteLineStr(2," "); LCD1_GotoXY(2,1); LCD1_WriteString("Z="); LCD1_GotoXY(2,4); LCD1_WriteString((char*)aux); mywait_Waitms(2000); //Capturando los valores del Giroscopio GI2C1_ReadByteAddress8(MPU,0x43,&buffer[7]); mywait_Waitms(10); GI2C1_ReadByteAddress8(MPU,0x44,&buffer[8]); mywait_Waitms(10); GcX=buffer[7]; GcX=GcX<<8; GcX=GcX | buffer[8]; GI2C1_ReadByteAddress8(MPU,0x45,&buffer[9]); mywait_Waitms(10); GI2C1_ReadByteAddress8(MPU,0x46,&buffer[10]); mywait_Waitms(10); GcY=buffer[9]; GcY=GcY<<8; GcY=GcY | buffer[10]; GI2C1_ReadByteAddress8(MPU,0x47,&buffer[11]); mywait_Waitms(10); GI2C1_ReadByteAddress8(MPU,0x48,&buffer[12]); mywait_Waitms(10); GcZ=buffer[11]; GcZ=GcZ<<8; GcZ=GcZ | buffer[12]; printf("Giroscopio\nGX=%d\tGY=%d\tGZ=%d\n", GcX,GcY,GcZ); LCD1_WriteLineStr(1,"Giroscopio: "); UTIL1_Num16sToStr(aux, sizeof(aux), GcX); LCD1_WriteLineStr(2," "); LCD1_GotoXY(2,1); LCD1_WriteString("Gx="); LCD1_GotoXY(2,5); LCD1_WriteString((char*)aux); mywait_Waitms(2000); UTIL1_Num16sToStr(aux, sizeof(aux), GcY); LCD1_WriteLineStr(2," "); LCD1_GotoXY(2,1); LCD1_WriteString("Gy="); LCD1_GotoXY(2,5); LCD1_WriteString((char*)aux); mywait_Waitms(2000); UTIL1_Num16sToStr(aux, sizeof(aux), GcZ); LCD1_WriteLineStr(2," "); LCD1_GotoXY(2,1); LCD1_WriteString("Gz="); LCD1_GotoXY(2,5); LCD1_WriteString((char*)aux); mywait_Waitms(2000); //Capturando los valores de temperatura GI2C1_ReadByteAddress8(MPU,0x41,&buffer[13]); mywait_Waitms(10); GI2C1_ReadByteAddress8(MPU,0x42,&buffer[14]); mywait_Waitms(10); temp=buffer[13]; temp=temp<<8; temp=temp | buffer[14]; temp=(temp/340)+37; printf("Temperatura = %d\n", temp); LCD1_WriteLineStr(1,"Temperatura: "); UTIL1_Num16sToStr(aux, sizeof(aux), temp); LCD1_WriteLineStr(2," "); LCD1_GotoXY(2,5); LCD1_WriteString((char*)aux); mywait_Waitms(2000); //Recibiendo los datos de GPS del Bluetooth myserial_RecvBlock(btbuffer,sizeof(btbuffer),&rx); strcpy(auxbuffer, btbuffer); char *token; token = strtok(auxbuffer, ","); int i = 0; while(token != NULL) { if(i==0) { if(token==99) { token = NULL; } } if(i == 2){ printf( "Latitud: %s\n", token ); LCD1_WriteLineStr(1,"Latitud: "); LCD1_WriteLineStr(2," "); LCD1_WriteLineStr(2,token); mywait_Waitms(2000); } if(i == 3){ printf( "Longitud: %s\n", token ); LCD1_WriteLineStr(1,"Longitud: "); LCD1_WriteLineStr(2," "); LCD1_WriteLineStr(2,token); mywait_Waitms(2000); } if(i == 4){ token=strtok(token,">"); printf( "Altura: %s\n", token ); LCD1_WriteLineStr(1,"Altura: "); LCD1_WriteLineStr(2," "); LCD1_WriteLineStr(2,token); mywait_Waitms(2000); } token = strtok(NULL, ","); i++; } WAIT1_Waitms(1000); } /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/ #ifdef PEX_RTOS_START PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of RTOS startup code. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/