Example #1
0
/* 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);
  }
}
Example #2
0
void display_menu(uint8_t currpoint, uint8_t menu, uint8_t refresh)
{
    uint8_t i;
    if(!refresh)
        return;
    
    for(i = 0;i < 4;i++)
    {
        LCD1_Line(i);
        if(i == 0)
            LCD1_WriteString(">");
        else
            LCD1_WriteString(" ");
        LCD1_WriteString(main_menu[(i + currpoint)%7].string);
    }
}
Example #3
0
/*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!!! ***/
Example #4
0
void display_alarm_set_load(uint8_t currpoint, uint8_t alarm)
{
    uint8_t i;
    if((currpoint >= 2)||(alarm > 2))
        return;
    for(i = 0; \
        alarm >= 4 ? i < 4: i < alarm; \
        i++)
    {
        LCD1_Line(i);
        if(i == 0)
            LCD1_WriteString(">");
        else
            LCD1_WriteString(" ");
        LCD1_WriteString(alarm_set_load_array[(i + currpoint)%2].string);
    }
}
Example #5
0
/*
currpoint: vi tri hien tai cua con tro
alarm: so luong alarm
*/
void display_alarm_set(uint8_t currpoint, uint8_t alarm, uint8_t refresh)
{
    uint8_t i;
    if(!refresh)
        return;
    for(i = 0; \
        alarm >= 4 ? i < 4: i < alarm; \
        i++)
    {
        LCD1_Line(i);
        if(i == 0)
            LCD1_WriteString(">");
        else
            LCD1_WriteString(" ");
        LCD1_WriteString("ALARM ");
        LCD1_DisplayInt((i + currpoint) % alarm, 2);
    }
}
Example #6
0
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);
  }
}
Example #7
0
void display_subtime_menu(uint8_t currpoint, uint8_t val, bool only)
{
    uint8_t i;
    uint8_t DataTemp[5];
    uint8_t * cursor[5] = 
    {
        " ^              ",
        "    ^           ",
        "       ^        ",
        "          ^     ",
        "             ^  "
    };
    uint8_t * cursor_info[5] = 
    {
        "1, DAT GIO      ",
        "2, DAT PHUT     ",
        "3, DAT NGAY     ",
        "4, DAT THANG    ",
        "5, DAT NAM      "
    };
    uint8_t * separate_info[5] = 
    {
        ":",
        " ",
        "/",
        "/",
        " "
    };
    uint8_t * time_ptr;
    time_ptr = &systime.Hour;
    for(i = 0;i < 5;i++)
    {
        //time_ptr++;
        if(i == currpoint)
        {
            LCD1_Line(0);
            LCD1_WriteString(cursor_info[i]);
            LCD1_Line(2);
            LCD1_WriteString(cursor[i]);
            DataTemp[i] = val;
        }
        else
            DataTemp[i] = time_ptr[i];
    }
    LCD1_Line(1);
		for(i = 0; i < 5; i++)
		{
			if(only == TRUE)
			{
				if(currpoint == i)
				{
					LCD1_DisplayInt(DataTemp[i], 2);
					LCD1_WriteString(separate_info[i]);
				}
				else
				{
					LCD1_WriteString("  ");
					LCD1_WriteString(separate_info[i]);
				}
			}
			else
			{
				LCD1_DisplayInt(DataTemp[i], 2);
				LCD1_WriteString(separate_info[i]);
			}
		}
}
Example #8
0
void display_alarm_menu(uint8_t currpoint, uint8_t val, bool only)
{
    uint8_t i;
    uint8_t DataTemp[4];
    uint8_t * cursor[4] = 
    {
        " ^              ",
        "    ^           ",
        "         ^      "
    };
    uint8_t * cursor_info[4] = 
    {
        "1, GIO BAT      ",
        "2, PHUT BAT     ",
        "3, THOI GIAN BAT"
    };

    uint8_t * separate_info[4] = 
    {
			":",
			":",
			" "
    };
    uint8_t * time_ptr;
    time_ptr = alarm_data_ptr; // get alarm data pointer
    for(i = 0;i < 3;i++)
    {
			//time_ptr++;
        if(i == currpoint)
        {
            LCD1_Line(0);
            LCD1_WriteString(cursor_info[i]);
            LCD1_Line(2);
            LCD1_WriteString(cursor[i]);
            DataTemp[i] = val;
        }
        else
            DataTemp[i] = time_ptr[i];
    }
    LCD1_Line(1);
    for(i = 0; i < 3; i++)
    {
        if(only == TRUE)
        {
            if(currpoint == i)
            {
                if(i == 2)
                    LCD1_DisplayInt(DataTemp[i], 4);
                else
                    LCD1_DisplayInt(DataTemp[i], 2);
                LCD1_WriteString(separate_info[i]);
            }
            else
            {
                LCD1_WriteString("  ");
                LCD1_WriteString(separate_info[i]);
            }
        }
        else
        {
            if(i == 2)
                LCD1_DisplayInt(DataTemp[i], 4);
            else
                LCD1_DisplayInt(DataTemp[i], 2);
            LCD1_WriteString(separate_info[i]);
        }
    }
}
Example #9
0
/*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!!! ***/