コード例 #1
0
/*====================================================================================================*/
void WaveForm_Init( void )
{
	WaveForm.Channel = 3;
	WaveForm.WindowColor = WHITE;
	WaveForm.BackColor = BLACK;
	WaveForm.Data[0] = 0;
	WaveForm.Data[1] = 0;
	WaveForm.Data[2] = 0;
	WaveForm.Scale[0] = 100;
	WaveForm.Scale[1] = 100;
	WaveForm.Scale[2] = 100;
	WaveForm.PointColor[0] = RED;
	WaveForm.PointColor[1] = GREEN;
	WaveForm.PointColor[2] = BLUE;

  LCD_Clear(BLACK);

  LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*0,  (u8*)"------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*2,  (u8*)" SINE ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*4,  (u8*)" DEMO ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*6,  (u8*)"------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*9,  (u8*)"Axis-X", ASCII1608, RED,   BLACK);
  LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*14, (u8*)"Axis-Y", ASCII1608, GREEN, BLACK);
  LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*19, (u8*)"Axis-Z", ASCII1608, BLUE,  BLACK);
  LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*24, (u8*)"------", ASCII1608, WHITE, BLACK);
}
コード例 #2
0
ファイル: tad_LCD.c プロジェクト: xiamin/TA_D
void lcd1602_DispProcessing(uint8_t percent)
{
    uint8_t i, BlockNum = 0;
    uint8_t abyString[17];

    rt_err_t rtResult;
    //while (1)
    {
        BlockNum = ((uint32_t)percent * 16) / 99;
        for (i = 0; i < 16; i++)
        {
            if (i < BlockNum)
            {
                abyString [i] = '#';
            }
            else
            {
                abyString [i] = ' ';
            }
        }
        abyString[16] = 0;
        rtResult = rt_mutex_take(LcdMutex, RT_WAITING_FOREVER);
        if (rtResult == RT_EOK)
        {
            LCD_PutStr(abyString, 16, 16);
            rt_mutex_release(LcdMutex);
        }
    }
}
コード例 #3
0
ファイル: aviator.c プロジェクト: Rodobmx/Aviator
__interrupt void Timer_A (void) // Fonction d'interruption sur le timer
{ 
  static int ticks_meteore=0;

  if(vie > 0)
  {
    //décalage du joueur
    JOYSTICK_POS pos;  
    pos = GetJoystickPosition();
    decaler_avion(pos);

    //calcul des positions
    avanceMeteore();
    avanceMissile();
    avanceBalles();

    ticks_meteore++;
    if (ticks_meteore >= DELAY_NOUVEAU_METEOR)
    {
      addMeteore();
      ticks_meteore = 0;
    }
    
    checkCollision();
    
    afficher_meteore();
    afficherMissile();
    afficherBalles();
    
    afficher_avion();
    
    // ajustement de la difficulte
    CCR0 = VITESSE_JEUX_BASE - (Difficulte*MULTIPLICATEUR_DIFFICULTE);
  }
  else // plus de vie
  {
    itoa(score_tab, score, (SCORE_LENGTH+1),10); // base 10
    LCD_PutStr("GAME OVER !" , 20, 20, 2, YELLOW, BLACK); // position 20*20
    LCD_PutStr(score_tab,50,20, 2,YELLOW,BLACK);          // position 50*50
    while((P1IN & BIT6) != 0);
    init_aviator();
  }
}
コード例 #4
0
ファイル: Settings.c プロジェクト: abcminiuser/buttload
/*
 NAME:      | SET_SetAutoSleepTimeOut (static)
 PURPOSE:   | Changes the length of time of inactivity before entering sleep mode to the user's preference
 ARGUMENTS: | None
 RETURNS:   | None
*/
void SET_SetAutoSleepTimeOut(void)
{
	uint8_t SleepVal = eeprom_read_byte(&EEPROMVars.AutoSleepValIndex);
	char    SleepTxtBuffer[8];

	if (SleepVal > ARRAY_UPPERBOUND(AutoSleepTOValues))
	  SleepVal = ARRAY_UPPERBOUND(AutoSleepTOValues);

	strcpy_P(SleepTxtBuffer, PSTR("    SEC"));
	
	JoyStatus = JOY_INVALID;                     // Use an invalid joystick value to force the program to write the
	                                             // name of the default command onto the LCD
	for (;;)
	{
		if (JoyStatus)
		{
			if (JoyStatus & JOY_UP)
			{
				(SleepVal == 0)? SleepVal = ARRAY_UPPERBOUND(AutoSleepTOValues) : SleepVal--;
			}
			if (JoyStatus & JOY_DOWN)
			{
				(SleepVal == ARRAY_UPPERBOUND(AutoSleepTOValues))? SleepVal = 0 : SleepVal++;
			}
			else if (JoyStatus & JOY_LEFT)
			{
				eeprom_write_byte(&EEPROMVars.AutoSleepValIndex, SleepVal);
				TOUT_SetupSleepTimer();
				return;
			}

			if (!(SleepVal))
			{
				LCD_PutStr_f(OffText);
			}
			else
			{
				MAIN_IntToStr(pgm_read_byte(&AutoSleepTOValues[SleepVal]), SleepTxtBuffer);
				SleepTxtBuffer[3] = ' ';         // Remove the auto-string termination from the buffer that was added by MAIN_IntToStr
				LCD_PutStr(SleepTxtBuffer);
			}

			MAIN_WaitForJoyRelease();
		}

		MAIN_MenuSleep();
	}	
}
コード例 #5
0
ファイル: Settings.c プロジェクト: abcminiuser/buttload
/*
 NAME:      | SET_SetToneVol (static)
 PURPOSE:   | Changes the tone volume to the user's preference
 ARGUMENTS: | None
 RETURNS:   | None
*/
void SET_SetToneVol(void)
{
	char VolBuffer[5];

	VolBuffer[0] = 'V';
	
	JoyStatus = JOY_INVALID;                     // Use an invalid joystick value to force the program to write the
	                                             // name of the default command onto the LCD
	for (;;)
	{
		if (JoyStatus)
		{
			uint8_t ToneVolLcl = ToneVol;        // Copy the global to a local variable to save code space

			if (JoyStatus & JOY_UP)
			{
				ToneVolLcl = ((ToneVolLcl == 80)? 0 : (ToneVolLcl + 8));
			}
			else if (JoyStatus & JOY_DOWN)
			{
				ToneVolLcl = ((ToneVolLcl == 0)? 80 : (ToneVolLcl - 8));
			}
			else if (JoyStatus & JOY_LEFT)
			{
				eeprom_write_byte(&EEPROMVars.ToneVolume, ToneVolLcl);
				return;
			}

			ToneVol = ToneVolLcl;                // Copy the local value back into the global

			if (!(ToneVolLcl))
			{
				LCD_PutStr_f(OffText);
			}
			else
			{
				TG_PlayToneSeq(TONEGEN_SEQ_VOLTEST);
				MAIN_IntToStr((ToneVol >> 3), &VolBuffer[1]);
				LCD_PutStr(VolBuffer);				
			}

			MAIN_WaitForJoyRelease();
		}

		MAIN_MenuSleep();
	}	
}
コード例 #6
0
/*=====================================================================================================*/
void EVENT_FIFO( uc8 *newStr )
{
  u8 i=0,j=0;
  static u8 Line[13][50]={0};
  
  for(i=12;i>0;i--){
    for(j=0;j<50;j++){
      Line[i][j] = Line[i-1][j];
    }
  }
  for(j=0;j<50;j++){
      Line[0][j] = newStr[j];
  }
  for(i=0;i<13;i++){
    LCD_PutStr( 2,  16*i+2,  Line[i], ASCII1608,  WHITE,  BLACK);
  }
}
コード例 #7
0
ファイル: tad_LCD.c プロジェクト: xiamin/TA_D
void lcd1602_FileNameRoll(void *parameter)
{
    uint8_t i, Index, StartIndex = 0;
    uint8_t tmpStr[17];
    rt_err_t rtResult;

    while (1)
    {
        while (!(LcdUserData.CurCmd == DispConnecting || LcdUserData.CurCmd == DispProcessing))
        {
            rt_thread_delay(100);	//(lcd_thread_filename);
        }
        memset (tmpDispStr, 0, 17);
        Index = LcdUserData.CurStartIndex;
        for (i = 0; i < 16; i++)
        {
            tmpDispStr[i] = LcdUserData.DispBuffer[Index];
            Index++;
            if (Index >= LcdUserData.StrSize)
            {
                Index = 0;
            }
        }
        tmpDispStr[16] = 0;
        rtResult = rt_mutex_take(LcdMutex, RT_WAITING_FOREVER);
        if (rtResult == RT_EOK)
        {
            LCD_PutStr(tmpDispStr, 0, 16);

            rt_mutex_release(LcdMutex);
        }
        if (LcdUserData.CurCmd == DispProcessing)
        {
            lcd1602_DispProcessing(LcdUserData.Percent);
        }
        rt_thread_delay(500);
        LcdUserData.CurStartIndex++;
        if (LcdUserData.CurStartIndex >= LcdUserData.StrSize)
        {
            LcdUserData.CurStartIndex = 0;
        }
    }
}
コード例 #8
0
ファイル: Settings.c プロジェクト: abcminiuser/buttload
/*
 NAME:      | SET_SetFirmMinorVer (static)
 PURPOSE:   | Changes the returned firmware revision number to the user's preference
 ARGUMENTS: | None
 RETURNS:   | None
*/
void SET_SetFirmMinorVer(void)
{
	uint8_t VerMinor = eeprom_read_byte(&EEPROMVars.FirmVerMinor);
	char    VerBuffer[5];

	if (VerMinor > 19)
	  VerMinor = V2P_SW_VERSION_MINOR_DEFAULT;
	
	VerBuffer[0] = 'V';
	VerBuffer[1] = '2';

	JoyStatus = JOY_INVALID;                     // Use an invalid joystick value to force the program to write the
	                                             // name of the default command onto the LCD
	for (;;)
	{
		if (JoyStatus)
		{
			if (JoyStatus & JOY_UP)
			{
				if (VerMinor < 20)
				  VerMinor++;
			}
			else if (JoyStatus & JOY_DOWN)
			{
				if (VerMinor)
				  VerMinor--;
			}
			else if (JoyStatus & JOY_LEFT)
			{
				eeprom_write_byte(&EEPROMVars.FirmVerMinor, VerMinor);
				return;
			}
			
			MAIN_IntToStr(VerMinor, &VerBuffer[2]);
			VerBuffer[2] = '-';
			LCD_PutStr(VerBuffer);

			MAIN_WaitForJoyRelease();
		}

		MAIN_MenuSleep();
	}	
}
コード例 #9
0
ファイル: Settings.c プロジェクト: abcminiuser/buttload
/*
 NAME:      | SET_SetContrast (static)
 PURPOSE:   | Changes the LCD's contrast to the user's preference
 ARGUMENTS: | None
 RETURNS:   | None
*/
void SET_SetContrast(void)
{
	uint8_t Contrast = (eeprom_read_byte(&EEPROMVars.LCDContrast) & 0x0F); // Ranges from 0-15 so mask retuns 15 (darkest) on blank EEPROM (0xFF)
	char Buffer[6];
	
	JoyStatus = JOY_INVALID;                     // Use an invalid joystick value to force the program to write the
	                                             // name of the default command onto the LCD
	for (;;)
	{
		if (JoyStatus)
		{
			if (JoyStatus & JOY_UP)
			{
				if (Contrast < 15)
				  Contrast++;
			}
			else if (JoyStatus & JOY_DOWN)
			{
				if (Contrast > 1)                // Zero is non-visible, so 1 is the minimum
				  Contrast--;
			}
			else if (JoyStatus & JOY_LEFT)
			{
				eeprom_write_byte(&EEPROMVars.LCDContrast, Contrast);
				return;
			}
					
			Buffer[0] = 'C';
			Buffer[1] = 'T';
			Buffer[2] = ' ';

			MAIN_IntToStr((uint16_t)Contrast, &Buffer[3]);
			LCD_PutStr(Buffer);

			LCD_CONTRAST_LEVEL(Contrast);

			MAIN_WaitForJoyRelease();
		}

		MAIN_MenuSleep();
	}
}
コード例 #10
0
ファイル: tad_LCD.c プロジェクト: xiamin/TA_D
static rt_size_t rt_lcd1602_write (rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
{
    uint32_t i, num;
    uint8_t *pBuf;
    pBuf = (uint8_t *)buffer;
    num = size;
    LCD_PutStr((unsigned char *)buffer, pos, size);
    for (i = 0; i < 64; i++)
    {
        if (*pBuf != 0)
        {
            LcdUserData.DispBuffer[i] = *(const uint8_t *)pBuf;
            pBuf++;
        }
        else
        {
            break;
        }
        num--;
        if (!num)
        {
            break;
        }
    }
    for (num = 0; num < 3; num++)
    {
        LcdUserData.DispBuffer[i] = ' ';
        i++;
        if (i >= 64)
        {
            break;
        }
    }
    LcdUserData.StrSize = i;
    return 0;
}
コード例 #11
0
int main( void )
{
  u32 i = 0;
  u8 FileNum = 0;
  u8 ReadBuf[128] = {0};
  u8 WriteData[50] = "ABCDEFG";

  SystemInit();
  GPIO_Config();
  RS232_Config();
  R61581_Config();
  R61581_Init();

  LED_R = 1;
  LED_G = 1;
  LED_B = 1;
  LED_Y = 1;

  LED_R = 0;
  LCD_Clear(BLACK);

  // SD Card Init Info
  #define Axis_X 10
  #define Axis_Y 0
  LCD_PutStr(Axis_X, Axis_Y+16*0, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*1, (u8*)" SDIO SD Fatfs demo",     ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*2, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*3, (u8*)" SD Init ... ", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)" \r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)" SDIO SD FatFs demo\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n\r\n");
  RS232_SendStr(USART2, (u8*)" SD Init ... ");
  while(SD_Init() != SD_OK) {
    LCD_PutStr(Axis_X+8*13, Axis_Y+16*3, (u8*)"Failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"Failed!!\r\n");
    while(1) {
      LED_R = ~LED_R;
      Delay_100ms(2);
    }
  }
  LCD_PutStr(Axis_X+8*13, Axis_Y+16*3, (u8*)"OK!!", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)"OK!!\r\n\r\n");

  LCD_PutStr(Axis_X,      Axis_Y+16*5,  (u8*)"---- SD Init Info -----", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*6,  (u8*)" Capacity : ", ASCII1608, WHITE, BLACK);
  LCD_PutNum(Axis_X+8*12, Axis_Y+16*6,  Type_D, 5, SDCardInfo.CardCapacity>>20, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*17, Axis_Y+16*6,  (u8*)" MB", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*7,  (u8*)" CardBlockSize : ", ASCII1608, WHITE, BLACK);
  LCD_PutNum(Axis_X+8*17, Axis_Y+16*7,  Type_D, 5, SDCardInfo.CardBlockSize, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*22, Axis_Y+16*7,  (u8*)" ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*8,  (u8*)" CardType : ", ASCII1608, WHITE, BLACK);
  LCD_PutNum(Axis_X+8*12, Axis_Y+16*8,  Type_D, 5, SDCardInfo.CardType, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*17, Axis_Y+16*8,  (u8*)" ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*9,  (u8*)" RCA : ", ASCII1608, WHITE, BLACK);
  LCD_PutNum(Axis_X+8*7,  Axis_Y+16*9,  Type_D, 5, SDCardInfo.RCA, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*12, Axis_Y+16*9,  (u8*)" ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*10, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)"-----SD Init Info-----\r\n");
  RS232_SendStr(USART2, (u8*)" Capacity : ");
  RS232_SendNum(USART2, Type_D, 5, SDCardInfo.CardCapacity>>20);
  RS232_SendStr(USART2, (u8*)" MB\r\n");
  RS232_SendStr(USART2, (u8*)" CardBlockSize : ");
  RS232_SendNum(USART2, Type_D, 5, SDCardInfo.CardBlockSize);
  RS232_SendStr(USART2, (u8*)"\r\n");
  RS232_SendStr(USART2, (u8*)" CardType : ");
  RS232_SendNum(USART2, Type_D, 5, SDCardInfo.CardType);
  RS232_SendStr(USART2, (u8*)"\r\n");
  RS232_SendStr(USART2, (u8*)" RCA : ");
  RS232_SendNum(USART2, Type_D, 5, SDCardInfo.RCA);
  RS232_SendStr(USART2, (u8*)"\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)"\r\n");

  Delay_100ms(1);
  //////////////////// Wait
  while(KEY_S2 != 1){
    LED_G = ~LED_G;
    Delay_100ms(5);
  }
  LED_G = 0;
  LCD_Clear(BLACK);

  // Read Directory File
  LCD_PutStr(Axis_X, Axis_Y+16*0, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*1, (u8*)" SD_Card Read Directory", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*2, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)" SD_Card Read Directory File\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n\r\n");

  res = f_mount(&FatFs, "", 1);
  res = f_opendir(&dirs, "0:/");
  res = f_readdir(&dirs, &finfo);
  while(res!= FR_OK) {
    LCD_PutStr(Axis_X, Axis_Y+16*3, (u8*)" Fatfs failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)" FatFs failed!!\r\n");
    while(1) {
      LED_R = ~LED_R;
      Delay_100ms(2);
    }
  }
  LCD_PutStr(Axis_X, Axis_Y+16*3, (u8*)" File name : ", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)" File name : \r\n");

  while(finfo.fname[0]) {
    f_readdir(&dirs, &finfo);
    if(!finfo.fname[0])
      break;
    if(FileNum<11) {
      LCD_PutStr(Axis_X,     Axis_Y+16*(3+FileNum), (u8*)" ... ", ASCII1608, WHITE, BLACK);
      LCD_PutStr(Axis_X+8*5, Axis_Y+16*(3+FileNum), (u8*)finfo.fname, ASCII1608, WHITE, BLACK);
    }
    else if((FileNum>=11) && (FileNum<22)) {
      LCD_PutStr(Axis_X+200,     Axis_Y+16*(3+FileNum-11), (u8*)" ... ", ASCII1608, WHITE, BLACK);
      LCD_PutStr(Axis_X+8*5+200, Axis_Y+16*(3+FileNum-11), (u8*)finfo.fname, ASCII1608, WHITE, BLACK);
    }
    else {
      FileNum = 0;
      break;
    }
    FileNum++;
    RS232_SendStr(USART2, (u8*)" ... ");
    RS232_SendStr(USART2, (u8*)finfo.fname);
    RS232_SendStr(USART2, (u8*)"\r\n");
  }

  Delay_100ms(1);
  //////////////////// Wait
  while(KEY_S2 != 1){
    LED_B = ~LED_B;
    Delay_100ms(5);
  }
  LED_B = 0;
  LCD_Clear(BLACK);

  // Write File
  LCD_PutStr(Axis_X, Axis_Y+16*0, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*1, (u8*)" SD_Card Write Data",     ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*2, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)"-----------------------\r\n");
  RS232_SendStr(USART2, (u8*)" SD_Card Write Data File\r\n");
  RS232_SendStr(USART2, (u8*)"-----------------------\r\n\r\n");

  LCD_PutStr(Axis_X, Axis_Y+16*3, (u8*)" f_open ... ", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)" f_open ... ");
  res = f_open(&file,"SDCard_K.txt", FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
  if(res==FR_OK) {
    LCD_PutStr(Axis_X+8*12, Axis_Y+16*3, (u8*)"OK!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"OK!!\r\n");
  }
  else {
    LCD_PutStr(Axis_X+8*12, Axis_Y+16*3, (u8*)"failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"failed!!\r\n");
  }

  LCD_PutStr(Axis_X, Axis_Y+16*4, (u8*)" f_write ... ", ASCII1608, WHITE, BLACK);

  RS232_SendStr(USART2, (u8*)" f_write ... ");
  res = f_write(&file, WriteData, 20, &i); 
  if(res==FR_OK) {
    LCD_PutStr(Axis_X+8*13, Axis_Y+16*4, (u8*)"OK!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"OK!!\r\n");
  }
  else {
    LCD_PutStr(Axis_X+8*13, Axis_Y+16*4, (u8*)"failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"failed!!\r\n");
  }

  file.fptr = 0;

  LCD_PutStr(Axis_X, Axis_Y+16*5, (u8*)" f_read ... ", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)" f_read ... ");
  res = f_read(&file, ReadBuf, 100, &i);
  if(res==FR_OK) {
    LCD_PutStr(Axis_X+8*12, Axis_Y+16*5, (u8*)"OK!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"OK!!\r\n");
  }
  else {
    LCD_PutStr(Axis_X+8*12, Axis_Y+16*5, (u8*)"failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"failed!!\r\n");
  }

  f_close(&file);

  LCD_PutStr(Axis_X, Axis_Y+16*7, (u8*)" Read String : ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*1, Axis_Y+16*8, (u8*)ReadBuf, ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, ReadBuf);

  while(1) {
    LED_Y = ~LED_Y;
    Delay_100ms(2);
  }
}
コード例 #12
0
void Windows_SelMenu( u8 menuType )
{
  u16 StartCoordi = SelMenu_1+2;
  static u16 last_Coordi = SelMenu_1+2;
  
  switch(menuType){
    case Menu_INIT:
      StartCoordi = SelMenu_1+2;
      break;
    case Menu_SDCARD:
      StartCoordi = SelMenu_2+2;
      break;
    case Menu_WAVE:
      StartCoordi = SelMenu_3+2;
      break;
    case Menu_INFO:
      StartCoordi = SelMenu_4+2;
      break;
  }

  //Redraw last line
  LCD_DrawLineX(last_Coordi,Frame_H-1, ButMenu_W-3, WHITE);
	LCD_DrawLineX(last_Coordi,Frame_H-2, ButMenu_W-3, WHITE);
  LCD_DrawLineX(last_Coordi,Frame_H+2, ButMenu_W-3, WHITE);
  LCD_DrawLineX(last_Coordi,Frame_H+3, ButMenu_W-3, WHITE);
  
  //Clear line segment to black
  LCD_DrawLineX(StartCoordi,Frame_H-1, ButMenu_W-3, BLACK);
	LCD_DrawLineX(StartCoordi,Frame_H-2, ButMenu_W-3, BLACK);
  LCD_DrawLineX(StartCoordi,Frame_H+2, ButMenu_W-3, BLACK);
  LCD_DrawLineX(StartCoordi,Frame_H+3, ButMenu_W-3, BLACK);
  
  LCD_DrawLineY(last_Coordi-2,Frame_H, 2, BLACK);
	LCD_DrawLineY(last_Coordi-1,Frame_H, 2, BLACK);
  LCD_DrawLineY(last_Coordi-2+ButMenu_W,Frame_H, 2, BLACK);
  LCD_DrawLineY(last_Coordi-2+ButMenu_W-1,Frame_H, 2, BLACK);
  
  LCD_DrawLineY(StartCoordi-2,Frame_H, 2, WHITE);
	LCD_DrawLineY(StartCoordi-1,Frame_H, 2, WHITE);
  LCD_DrawLineY(StartCoordi-2+ButMenu_W,Frame_H, 2, WHITE);
  LCD_DrawLineY(StartCoordi-2+ButMenu_W-1,Frame_H, 2, WHITE);

  //store the current Coordi
  last_Coordi = StartCoordi;
  
  switch(menuType){

/************************** FSM CONF **************************************/
		case Menu_INIT:
      LCD_DrawRectangleFull(2, 2, RealFrame_L, RealFrame_H, BLACK);
			break;
    
/************************** FSM EVENT **************************************/
		case Menu_SDCARD:
			LCD_DrawRectangleFull(2, 2, RealFrame_L, RealFrame_H, BLACK);
			break;
    
/************************** FSM INFO **************************************/
		case Menu_WAVE:
      LCD_DrawRectangleFull(2, 2, RealFrame_L, RealFrame_H, BLACK);
      LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*0,  (u8*)"------", ASCII1608, WHITE, BLACK);
      LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*2,  (u8*)" SINE ", ASCII1608, WHITE, BLACK);
      LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*4,  (u8*)"------", ASCII1608, WHITE, BLACK);
      LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*7,  (u8*)"Axis-X", ASCII1608, RED, BLACK);
      LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*12, (u8*)"Axis-Y", ASCII1608, GREEN, BLACK);
      LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*17, (u8*)"Axis-Z", ASCII1608, BLUE, BLACK);
      LCD_PutStr(WaveFromNum_X, WaveFromNum_Y+8*22, (u8*)"------", ASCII1608, WHITE, BLACK);
			break;
    
/************************** FSM CTRL *************************************/
		case Menu_INFO:
			LCD_DrawRectangleFull(2, 2, RealFrame_L, RealFrame_H, BLACK);
			break;
	}
}
コード例 #13
0
ファイル: tad_LCD.c プロジェクト: xiamin/TA_D
void lcd1602_ConnectDispThread(void *parameter)
{
    uint8_t tmpStr[17];
    uint8_t i, j, k;
    rt_err_t rtResult;
    uint8_t str[16] = {'U', 'p', 'd', 'a', 't', 'i', 'n', 'g','.', '.', '.', '.', ' ', ' ', ' ', '%'};
    uint8_t connect[16] ={'C', 'o', 'n', 'n', 'e', 'c', 't', 'i', 'n', 'g', '.', '.', '.', ' ', ' ', ' '};
    uint8_t percent[3] = {0};
    while(1)
    {
        if (rt_sem_take(&lcd_writesem, RT_WAITING_FOREVER) != RT_EOK) continue;
        switch(LcdUserData.CurCmd)
        {
        case DispProcessing:
            if(rt_mutex_take(LcdMutex, RT_WAITING_FOREVER) == RT_EOK)
            {
	            pLcd1602->write(pLcd1602, 16,str, 16);
	            sprintf(percent, "%d", LcdUserData.Percent);
	            pLcd1602->write(pLcd1602, 28, percent, 3);
                    rt_mutex_release(LcdMutex);
            }
            break;
        case DispConnecting:
            pLcd1602->write(pLcd1602, 16, connect, 16);
            break;
        case DispEnd:
            break;
        default:
            break;
        }
    }
#if 0
    while (1)
    {
        tmpStr[16] = 0;
        k = 19;
        for (i = 0; i < 16; i++)
        {
            for (j = 0; j < 16; j++)
            {
                tmpStr[j] = ConForwardStr[k + j];
            }
            k--;
            rtResult = rt_mutex_take(LcdMutex, RT_WAITING_FOREVER);
            if (rtResult == RT_EOK)
            {
                LCD_PutStr(tmpStr, 16, 16);
                rt_mutex_release(LcdMutex);
            }
            if (LcdUserData.CurCmd != DispConnecting)
            {
                while (LcdUserData.CurCmd != DispConnecting)
                {
                    rt_thread_delay(100);
                }
            }
            rt_thread_delay (400);
        }
        k = 0;
        for (i = 0; i < 16; i++)
        {
            for (j = 0; j < 16; j++)
            {
                tmpStr[j] = ConRevStr[k + j];
            }
            k++;
            rtResult = rt_mutex_take(LcdMutex, RT_WAITING_FOREVER);
            if (rtResult == RT_EOK)
            {
                LCD_PutStr(tmpStr, 16, 16);
                rt_mutex_release(LcdMutex);
            }
            if (LcdUserData.CurCmd != DispConnecting)
            {
                while (LcdUserData.CurCmd != DispConnecting)
                {
                    rt_thread_delay(100);
                }
            }
            rt_thread_delay (400);
        }

    }
#endif
}
コード例 #14
0
ファイル: lcd-robostix.c プロジェクト: JonHylands/projects
int main(void)
{
    int     i;
    int     led = 0;
    FILE   *u0;

    InitHardware();

    // The first handle opened for read goes to stdin, and the first handle
    // opened for write goes to stdout. So u0 is stdin, stdout, and stderr

#if defined( __AVR_LIBC_VERSION__ )
    u0 = fdevopen( UART0_PutCharStdio, UART0_GetCharStdio );
#else
    u0 = fdevopen( UART0_PutCharStdio, UART0_GetCharStdio, 0 );
#endif

    printf( "*****\n" );
    printf( "***** LCD-Test program\n" );
    printf( "*****\n" );

    LCD_Init( 4, 20 );

    LCD_PutStr( "**** R/C Input ****\n" );
    LCD_PutStr( "LCD Test Line 6 1234\n" );
    LCD_PutStr( "LCD Test Line 7 1234\n" );
    LCD_PutStr( "LCD Test Line 8 1234\n" );

    while( 1 )
    {
        // Turn all of the LEDs off

        LED_OFF( RED );
        LED_OFF( BLUE );
        LED_OFF( YELLOW );

        switch ( led )
        {
            case    0:  LED_ON( RED );      printf( "R " );      break;
            case    1:  LED_ON( BLUE );     printf( "B " );     break;
            case    2:  LED_ON( YELLOW );   printf( "Y " );   break;
        }

        if ( ++led > 2 )
        {
            led = 0;
        }

        // Tick rate is 100/sec so waiting for 100 waits for 1 sec

        for ( i = 0; i < 100; i++ ) 
        {
            WaitForTimer0Rollover();

            if ( UART0_IsCharAvailable() )
            {
                char    ch = getchar();

                printf( "Read: '%c'\n", ch );

                if ( ch == ' ' )
                {
                    printf( "*** Press a key to continue\n" );
                    ch = getchar();
                    printf( "*** Continuing...\n" );
                }
            }
        }
    }

    return 0;
}
コード例 #15
0
ファイル: lcd-test.c プロジェクト: alshorin/projects
int main(void)
{
    InitTimer();
    InitUART();

    LED_DDR |= LED_MASK;

    LCD_Init( CFG_LCD_NUM_LINES, CFG_LCD_NUM_COLUMNS );

    LCD_PutStr( "LCD Test\n" );
    LCD_PutStr( ">Line 2<\n" );

    fdevopen( UART0_PutCharStdio, UART0_GetCharStdio );
    printf( "*****\n" );
    printf( "***** LCD Test program\n" );
    printf( "*****\n" );

    DDRB &= ~SW_ALL;
    PORTB |= SW_ALL;

    while( 1 )
    {
        LED_PORT |=  LED_MASK;

        ms_spin( 100 );

        LED_PORT &= ~LED_MASK;

        ms_spin( 100 );

        LED_PORT |=  LED_MASK;

        ms_spin( 100 );

        LED_PORT &= ~LED_MASK;

        ms_spin( 700 );

        LCD_MoveTo(0,1);
        uint8_t pinb = PINB;
        if ( pinb & SW_A )
        {
            printf("A is high ");
            LCD_PutChar('a');
        }
        else
        {
            printf("A is low ");
            LCD_PutChar('A');
        }
        if ( pinb & SW_B )
        {
            printf("B is high ");
            LCD_PutChar('b');
        }
        else
        {
            printf("B is low ");
            LCD_PutChar('B');
        }
        if ( pinb & SW_C )
        {
            printf("C is high\n");
            LCD_PutChar('c');
        }
        else
        {
            printf("C is low\n");
            LCD_PutChar('C');
        }
    }

    return 0;
}
コード例 #16
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */  
	SystemInit();
       
  /* System clocks configuration ---------------------------------------------*/
  RCC_Configuration();

  /* GPIO configuration ------------------------------------------------------*/
  GPIO_Configuration();
	
	/* DMA1 channel1 configuration ----------------------------------------------*/
  DMA_DeInit(DMA1_Channel1);
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR;
  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)ADCConvertedValue;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
  DMA_InitStructure.DMA_BufferSize = 2;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  DMA_Init(DMA1_Channel1, &DMA_InitStructure);
	
	/* Enable DMA1 channel1 */
  DMA_Cmd(DMA1_Channel1, ENABLE);
	
	/* ADC1 configuration ------------------------------------------------------*/
  ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
  ADC_InitStructure.ADC_ScanConvMode = ENABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfChannel = 2;
  ADC_Init(ADC1, &ADC_InitStructure);

  /* ADC1 regular channel0 configuration */ 
  ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 1, ADC_SampleTime_55Cycles5);
	ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 2, ADC_SampleTime_55Cycles5);
  /* Enable ADC1 DMA */
  ADC_DMACmd(ADC1, ENABLE);
  
  /* Enable ADC1 */
  ADC_Cmd(ADC1, ENABLE);

  /* Enable ADC1 reset calibration register */   
  ADC_ResetCalibration(ADC1);
  /* Check the end of ADC1 reset calibration register */
  while(ADC_GetResetCalibrationStatus(ADC1));

  /* Start ADC1 calibration */
  ADC_StartCalibration(ADC1);
  /* Check the end of ADC1 calibration */
  while(ADC_GetCalibrationStatus(ADC1));
     
  /* Start ADC1 Software Conversion */ 
  ADC_SoftwareStartConvCmd(ADC1, ENABLE);

  /* To achieve GPIO toggling maximum frequency, the following  sequence is mandatory. 
     You can monitor PD0 or PD2 on the scope to measure the output signal. 
     If you need to fine tune this frequency, you can add more GPIO set/reset 
     cycles to minimize more the infinite loop timing.
     This code needs to be compiled with high speed optimization option.  */
	/*Init LCD*/
	LCD_Init();
  while (1)
  {
		/* Start ADC1 Software Conversion */ 
		ADC_SoftwareStartConvCmd(ADC1, ENABLE);
		sprintf(LCD_Buffer,"ADC1=%d ",ADCConvertedValue[0]);
		LCD_GotoXY(0,0);
		LCD_PutStr(LCD_Buffer);
		sprintf(LCD_Buffer,"ADC2=%d ",ADCConvertedValue[1]);
		LCD_GotoXY(0,1);
		LCD_PutStr(LCD_Buffer);
		delay_ms(1000);
  }
}