Exemplo n.º 1
0
void UpdateMenuSkin()
{
	ClearLCD();
		LCDPrint(7,2,"Select a Program");
		LCDLineH(0,10,30); // head line
//	LCDPrint(14,27,"          ");

		LCDPrint(1,20,"Main menu");
		LCDPrint(15,20,"Acne");
		LCDPrint(15,35,"Rejuvenation");
		LCDPrint(15,50,"NAIL FUNGUS");

	switch(currentProgramNumberSkin)
	{
	case 1:
		LCDBox(0,18, 14, 29);
		break;
	case 2:
		LCDBox(14,18, 20, 29);
		break;
	case 3:
		LCDBox(14,33, 28, 43);
		break;
	case 4:
		LCDBox(14,48, 29, 58);
		break;
	}
}
Exemplo n.º 2
0
void DrawAcne()
{

	ClearLCD();

	LCDPrint(6,2,"Acne Treatment");
	LCDLineH(0,10,30); // head line
	LCDPrint(6,12,"use Acne handle");


	UpdateAcne();

}
Exemplo n.º 3
0
void DrawRejuvenation()
{

	ClearLCD();
	printf("\r\DrawRejuvenation\r\n");

	LCDPrint(4,2,"Rejuvenation  treatment");
	LCDLineH(0,10,30); // head line
	LCDPrint(4,12,"use Rejuvenation handle");


	UpdateRejuvenation();

}
Exemplo n.º 4
0
void DrawSkin()
{

	ClearLCD();
	printf("\r\DrawSkin\r\n");

	LCDPrint(8,2,"Skin Treatment");
	LCDLineH(0,10,30); // head line
	LCDPrint(3,12,"use Skin Treatment handle");


	UpdateSkin();

}
Exemplo n.º 5
0
Arquivo: lcd.c Projeto: sshakuf/mdop
void LCDPrintNum2Char(UCHAR inX, UCHAR inY, UCHAR inNum)
{
//	_XDATA char str[4];
	char str[4];
	_itoa(inNum, &str[0], 10);
	if (inNum < 10)
	{
		LCDPutNum(inX, inY, 0);
		LCDPrint(inX+1, inY, str);
	}
	else
	{
		LCDPrint(inX, inY, str);
	}
}
Exemplo n.º 6
0
Arquivo: lcd.c Projeto: sshakuf/mdop
void LCDPrintNum(UCHAR inX, UCHAR inY, UCHAR inNum)
{
//	_XDATA char str[4];
	char str[4];
	_itoa(inNum, &str[0], 10);
	LCDPrint(inX, inY, str);
}
Exemplo n.º 7
0
void UpdateSelectProgram()
{
	ClearLCD();
		LCDPrint(7,2,"Select a Program");
		LCDLineH(0,10,30); // head line
//	LCDPrint(14,27,"          ");

		LCDPrint(1,20,"HAIR REMOVAL");
		LCDPrint(1,35,"TWINLIGHT BI");
		LCDPrint(1,50,"MONOPOLAR RF");
		LCDPrint(15,20,"Acne");
		LCDPrint(15,35,"Rejuvenation");
		LCDPrint(15,50,"Skin Treatment");
	switch(currentProgramNumber)
	{
	case SCREENFASTPULSE:
		LCDBox(0,18, 14, 29);
		break;
	case SCREENTWINLIGHT:
		LCDBox(0,33, 14, 43);
		break;
	case SCREENRFMONOPOLAR:
		LCDBox(0,48, 14, 58);
		break;
	case SCREENACNE:
		LCDBox(14,18, 20, 29);
		break;
	case SCREENREJUVENATION:
		LCDBox(14,33, 28, 43);
		break;
	case SCREENSKIN:
		LCDBox(14,48, 29, 58);
		break;
	}
}
Exemplo n.º 8
0
void DrawCouperose()
{
#ifndef NOCOUPEROSESCREEN
	ClearLCD();
	printf("\r\DrawCouperose\r\n");

	LCDPrint(10,2,"Couperose");
	LCDLineH(0,10,30); // head line

	LCDLineH(12,12,5); // under flash line
	
	//LCDPrint(2,30,"laser: ");

	LCDPrint(22,50,"power");

	UpdateCouperose();
#endif
}
Exemplo n.º 9
0
void printMessage(unsigned int sid, unsigned char data, unsigned char dlc)
{
	char buffer[32];

	// Print frame information on LCD
	for(j = 0; j < dlc; j++)
	{
		sprintf(buffer, "%c", data);
		LCDPrint(buffer);
	}
}
Exemplo n.º 10
0
void UpdateSelectProgram()
{
	ClearLCD();
		LCDPrint(9,2,"Select Program");
		LCDLineH(0,10,30); // head line
//	LCDPrint(14,27,"          ");

		LCDPrint(1,20,"BI POLAR");
		LCDPrint(1,35,"MONO POLAR");
		LCDPrint(1,50,"Twinlight");
		LCDPrint(19,20,"COUPEROSE");
		LCDPrint(19,35,"EPILATION");

	switch(currentProgramNumber)
	{
	case SCREENRFBIPOLAR:
		LCDBox(0,18, 10, 28);
		break;
	case SCREENRFMONOPOLAR:
		LCDBox(0,33, 12, 43);
		break;
	case SCREENTWINLIGHT:
		LCDBox(0,48, 11, 58);
		break;
	case SCREENCOUPEROSE:
		LCDBox(18,18, 29, 28);
		break;
	case SCREENEPILATION:
		LCDBox(19,33, 29, 43);
		break;
	}
}
Exemplo n.º 11
0
void UpdateRejuvenation()
{
//	printf("\r\UpdateRejuvenation\r\n");
	
	if (gFastPulse < REJU_MID)
	{
		LCDPrint(14,50,"Mid");
		LCDPrint(24,50,"Hi");
		LCDDrawIcon(1, 35, LCD_ICON_BIG_L);
		LCDDrawIcon(1+3, 35, LCD_ICON_BIG_O);
		LCDDrawIcon(1+6, 35, LCD_ICON_BIG_W);
	}
	else if (gFastPulse == REJU_MID)
	{
		LCDPrint(2,50,"low");
		LCDPrint(24,50,"Hi");
		LCDDrawIcon(11, 35, LCD_ICON_BIG_M);
		LCDDrawIcon(11+3, 35, LCD_ICON_BIG_I);
		LCDDrawIcon(11+6, 35, LCD_ICON_BIG_D);
	}
	else
	{
		LCDPrint(2,50,"low");
		LCDPrint(14,50,"mid");
		LCDDrawIcon(22, 35, LCD_ICON_BIG_H);
		LCDDrawIcon(22+3, 35, LCD_ICON_BIG_I);

	}


}
Exemplo n.º 12
0
void DrawFastPulse()
{

	ClearLCD();
	printf("\r\DrawFastPulse\r\n");

	LCDPrint(6,2,"FAST HAIR REMOVAL");
	LCDLineH(0,10,30); // head line
	LCDLineH(0,55,30); // bottom line


	UpdateFastPulse();

}
Exemplo n.º 13
0
void UpdateFastPulse()
{
	int i;
	LCDPrintNumBig(11,25,(gFastPulseSCR+1) * 10);
	LCDPrint(0,25,"        ");
	if (showcounter)
	{
			LCDPrintNum(0,25, gPulseCounterCount5);
			LCDPrintNum(1,25, gPulseCounterCount4);
			LCDPrintNum(2,25, gPulseCounterCount3);
			LCDPrintNum(3,25, gPulseCounterCount2);
			LCDPrintNum(4,25, gPulseCounterCount1);
			LCDPrintNum(5,25, gPulseCounterCount0);
	}
	
}
Exemplo n.º 14
0
int main()
{

  int i;
  char buf[128];

  LCDPrint("hello world\n");

  LCDPrint("start of out_test\n");
  Wait(SEC_1);

  // initialize
  if (!OutputInit())
    LCDPrint("output init returned false\n");

  ResetAllTachoCounts(OUT_ABCD);

//  OutputSetType(OUT_A, DEVICE_TYPE_TACHO);
//  OutputSetType(OUT_B, DEVICE_TYPE_TACHO);
//  OutputSetType(OUT_C, DEVICE_TYPE_MINITACHO);
//  OutputSetTypes(DEVICE_TYPE_TACHO, DEVICE_TYPE_TACHO, DEVICE_TYPE_TACHO, DEVICE_TYPE_TACHO);

  SetPower(OUT_A, 90);
  SetSpeed(OUT_B, 40);
  SetPower(OUT_C, 60);
  SetPower(OUT_D, -60);
  On(OUT_ALL);

  bool isBusy = false;
  for(i=0; i < 10; i++)
  {
    sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
    LCDPrint(buf);
    sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
    LCDPrint(buf);
    sprintf(buf, "OUT_C: %d %d %d\n", MotorRotationCount(OUT_C), MotorTachoCount(OUT_C), MotorActualSpeed(OUT_C));
    LCDPrint(buf);
    sprintf(buf, "OUT_D: %d %d %d\n", MotorRotationCount(OUT_D), MotorTachoCount(OUT_D), MotorActualSpeed(OUT_D));
    LCDPrint(buf);
    Wait(SEC_1);

    isBusy = MotorBusy(OUT_ALL);
    sprintf(buf, "Any output isBusy = %d\n", (byte)isBusy);
    LCDPrint(buf);
  }
//  Wait(SEC_5);

  LCDPrint("Float(OUT_ALL)\n");
  Float(OUT_ALL);

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  LCDPrint("ResetAllTachoCounts(OUT_ALL)\n");
  ResetAllTachoCounts(OUT_ALL);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);
  sprintf(buf, "OUT_C: %d %d %d\n", MotorRotationCount(OUT_C), MotorTachoCount(OUT_C), MotorActualSpeed(OUT_C));
  LCDPrint(buf);
  sprintf(buf, "OUT_D: %d %d %d\n", MotorRotationCount(OUT_D), MotorTachoCount(OUT_D), MotorActualSpeed(OUT_D));
  LCDPrint(buf);

  LCDPrint("Wait(SEC_1)\n");
  Wait(SEC_1);

  LCDPrint("RotateMotorNoWait(OUT_AB, 75, 7200)\n");
  RotateMotorNoWait(OUT_AB, 75, 7200);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  isBusy = MotorBusy(OUT_AB);
  sprintf(buf, "A or B isBusy = %d\n", (byte)isBusy);
  LCDPrint(buf);

  LCDPrint("Wait(SEC_20)\n");
  Wait(SEC_20);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("resetting all tacho counters\n");
  ResetAllTachoCounts(OUT_ALL);

  LCDPrint("Wait(SEC_1)\n");
  Wait(SEC_1);

  LCDPrint("OnForSync(OUT_AB, SEC_10, 75)\n");
  OnForSync(OUT_AB, SEC_10, 75);

  for(i=0; i < 10; i++)
  {
    sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
    LCDPrint(buf);
    sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
    LCDPrint(buf);

    isBusy = MotorBusy(OUT_AB);
    sprintf(buf, "A or B isBusy = %d\n", (byte)isBusy);
    LCDPrint(buf);

    isBusy = MotorBusy(OUT_CD);
    sprintf(buf, "C or D isBusy = %d\n", (byte)isBusy);
    LCDPrint(buf);

    Wait(SEC_1);
  }

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  // synchronized motor movement without tacho or time limitation
  LCDPrint("OnFwdSync(OUT_AB, 75)\n");
  OnFwdSync(OUT_AB, 75);

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("Off(OUT_AB)\n");
  Off(OUT_AB); // stop with braking

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("Wait(SEC_1)\n");
  Wait(SEC_1);

/*
 *  Turn ratio is how tight you turn and to what direction you turn
 *   - 0 value is moving straight forward
 *   - Negative values turns to the left
 *   - Positive values turns to the right
 *   - Value -100 stops the left motor
 *   - Value +100 stops the right motor
 *   - Values less than -100 makes the left motor run the opposite
 *     direction of the right motor (Spin)
 *   - Values greater than +100 makes the right motor run the opposite
 *     direction of the left motor (Spin)
 */

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("OnFwdSyncEx(OUT_AB, 75, -20, RESET_NONE)\n");
  OnFwdSyncEx(OUT_AB, 75, -20, RESET_NONE);

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("OnFwdSync(OUT_AB, 50, -50, RESET_NONE)");
  OnFwdSyncEx(OUT_AB, 50, -50, RESET_NONE);

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("OnFwdSync(OUT_AB, 20, -100, RESET_NONE)\n");
  OnFwdSyncEx(OUT_AB, 20, -100, RESET_NONE);

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("OnFwdSync(OUT_AB, 80, -150, RESET_NONE)\n");
  OnFwdSyncEx(OUT_AB, 80, -150, RESET_NONE);

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("OnFwdSync(OUT_AB, 30, -200, RESET_NONE)\n");
  OnFwdSyncEx(OUT_AB, 30, -200, RESET_NONE);

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("Off(OUT_AB)\n");
  Off(OUT_AB);

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  LCDPrint("ResetAllTachoCounts(OUT_AB)\n");
  ResetAllTachoCounts(OUT_AB);

  LCDPrint("Wait(SEC_2)\n");
  Wait(SEC_2);

  sprintf(buf, "OUT_A: %d %d %d\n", MotorRotationCount(OUT_A), MotorTachoCount(OUT_A), MotorActualSpeed(OUT_A));
  LCDPrint(buf);
  sprintf(buf, "OUT_B: %d %d %d\n", MotorRotationCount(OUT_B), MotorTachoCount(OUT_B), MotorActualSpeed(OUT_B));
  LCDPrint(buf);

  // a blocking version of RotateMotor (function call does not return
  // until the motor rotation is complete)
  LCDPrint("RotateMotor(OUT_AB, 75, 1800)");
  RotateMotor(OUT_AB, 75, 1800); // 5 rotations

  // by the time the function above returns the motors are no longer busy
  isBusy = MotorBusy(OUT_AB);
  LCDPrint("A or B isBusy = %d\n", isBusy);

  // this call starts the motors running Forward without regulation or
  // synchronization and the function call does not return until the
  // specified amount of time has elapsed.
  // at the end of the elapsed time the motors are stopped with braking.
  LCDPrint("OnFor(OUT_AB, SEC_3)\n");
  OnFor(OUT_AB, SEC_3);

  LCDPrint("Off(OUT_AB)\n");
  Off(OUT_AB);

  LCDPrint("Wait(SEC_5)\n");
  Wait(SEC_5);

  OutputClose();
  OutputExit();
  LCDPrint("end of out_test\n");

  return 0;
}
Exemplo n.º 15
0
void main()
{
#if 0
	extern void DebugAdc();
	DebugAdc();
#endif

	//////////////////////////////////////////////////////////////////////////
	//                       局部变量或结构体                               //
	//////////////////////////////////////////////////////////////////////////
	SpeedForline = FreecaleConfig.Config.Motor.Speed.LineSpeed;
	//////////////////////////////////////////////////////////////////////////
	//                       位置提示                                       //
	//////////////////////////////////////////////////////////////////////////
	/************************************************************************/
	/* 开中断                                                               */
	/************************************************************************/

	set_vector_handler(UART0_VECTORn, UartHandler);   // 设置中断服务函数到中断向量表里
	uart_rx_irq_en(UART0);//串口中断
	FLKeyIrqEnable();
	//wdog_init (1000);//初始化看门狗
	//wdog_enable ();
	//////////////////////////////////////////////////////////////////////////
	//                       用户操作                                       //
	//////////////////////////////////////////////////////////////////////////
#if UseEndLine
	switch (FreecaleConfig.Config.CarState)
	{
	case CarStandby:
#endif//UseEndLine
		printf("start");
#if UseAdcNormalizingInit
		AdcNormalizingInit();//初始化归一化变量
#else//UseAdcNormalizingInit
		LCDPrint(0, 0, "Car Ready!");


		AdcInit();
		if (FreecaleConfig.Config.Mode.NrfStartCar == On)
		{
			if (FreecaleConfig.Config.CarThis == MyCar1)
			{
				uint8 exitfunc = false;
				LCDPrint(0, LcdLine2, "Press the");
				LCDPrint(LcdLocal2, LcdLine3, "start!");
				LCDPrint(LcdLocal1, LcdLine4, "Nrf Mode");

				while (!exitfunc)
				{
					switch (KeyScanWithoutIrq())//按键检测
					{
					case FLKeyAdcNorExit:
						LcdCls();
						LCDPrint(LcdLocal1, LcdLine1, "Findind Car2!");
						while (NrfSendStr("$", 1) != Nrf_AllGreen)
						{
							led(LED1, LED_ON);
							DELAY_MS(1);
						};
						led(LED1, LED_OFF);
						exitfunc = TRUE;//退出
						break;

					default:
						break;
					}
				}
			}
			else
			{
				LCDPrint(0, LcdLine2, "Wait Command!");
				uint8 strTemp[10];
				while (true)
				{
					if (NrfRecStrCheck(strTemp, 5) != 0)
					{
						if (strTemp)
						{
							break;
						}
					}

					led(LED1, LED_ON);
					DELAY_MS(1);
				} led(LED1, LED_OFF);
			}
#endif//UseAdcNormalizingInit
		}
		else
		{
			uint8 exitfunc = false;
			LCDPrint(0, LcdLine2, "Press the");
			LCDPrint(LcdLocal2, LcdLine3, "start!");
			LCDPrint(LcdLocal1, LcdLine4, "Manual Mode");

			while (!exitfunc)
			{
				switch (KeyScanWithoutIrq())//按键检测
				{
				case FLKeyAdcNorExit:
					exitfunc = TRUE;//退出
					break;

				default:
					break;
				}
			}
		}
#if UsePowerOnDelay
		DELAY_MS(2000);
#else
		if (FreecaleConfig.Config.CarDelay > 0)
		{
			LcdCls();
			LCDPrint(0, 0, "wait TimeOut!");
			DELAY_MS(FreecaleConfig.Config.CarDelay * 10);
		}
		LcdCls();
#endif//UsePowerOnDelay

		//////////////////////////////////////////////////////////////////////////
		//终点线
#if UseEndLine
		break;

	case CarRunning:
		break;

	case CarFinish:
		LCDPrint(0, 0, "Finish!");
		break;

	default:
		break;
	}
#endif//UseEndLine




	//uint16 spwm = SteerCenterDuty;
	Speed.Expect = SpeedForline;
	enable_irq(PIT_IRQn);								  //使能PIT0中断
	//程序循环
	while (1)
	{
		//////////////////////////////////////////////////////////////////////////
		//舵机控制
		SteerCtrl();

#if 1

#else
		///lcd show

		NumShow16(Speed.Expect, LcdLocal1, LcdLine1);
		NumShow16(Speed.Acturally, LcdLocal1, LcdLine2);

		NumShow3(MotorPid.P, LcdLocal1, LcdLine3);
		NumShow3(MotorPid.I, LcdLocal2, LcdLine3);
		NumShow3(MotorPid.D, LcdLocal3, LcdLine3);

#endif
		if (FreecaleConfig.Config.Mode.Ultrasonic == On)
		{
			NumShow4(CarDistance, LcdLocal1, LcdLine2);
		}
		

		SpeedCtrl();


		//////////////////////////////////////////////////////////////////////////
		//nrf
		if (FreecaleConfig.Config.Mode.NrfSendDistance)
		{
		//NrfErrorType_e nrfErr;
			if (FreecaleConfig.Config.CarThis)
			{
				if (NrfRecStrCheck(NrfBuff, 3))
				{
					if (FreecaleConfig.Config.Mode.NrfSendDistance)
					{
						if (NrfBuff[0] == '$')//超声波识别符
						{
							uint8 i = 0;
							while (NrfBuff[i + 1] != '#')//求字符串长度
							{
								if (NrfBuff[i + 1] == '\0')//error
								{
									goto exitthismainloop;//没辙了,我真不想这么写,实在不能再循环了,变量太多了
									//break;
								}
								i++;
							}

							uint32 dis = 0;
							for (uint8 j = 0; j < i; j++)//求数值
							{
								dis += POW((uint32)(NrfBuff[j + 1] - '0'), i - j);
							}
						}
					}
				}
			}
			else
			{
				if (FreecaleConfig.Config.Mode.NrfSendDistance)
				{
					sprintf(NrfBuff, "$%d#", CarDistance);
					NrfSendStrCheck(NrfBuff, sizeof(NrfBuff) / sizeof(uint8), 3);
				}
			}
		}

		//////////////////////////////////////////////////////////////////////////
	exitthismainloop:
		//延迟,控制周期
		DELAY_MS(20);
	}
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//Don't leave main////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
}
Exemplo n.º 16
0
int main()
{

 char msg[128],pin[10],machine[10],item[10],success[30];
 uint8_t number;
 uint8_t motorCounter=0;

 DDRB=0xff;
 DDRD=0xf8;
 
 DDRC=0xff;
 DDRA=0b11111110;
 PORTA=0b00000001;
 PORTC=0x00;

 sei();

 initLCD();
 _delay_ms(50);
 LCDClear();
 LCDGotoXY(0,0);
 _delay_ms(50);

 if(initGSM())
  LCDPrint("Vending Machine");
 
 LCDGotoXY(0,0);

 sendCommand(ENABLE_TEXT_MODE); //Enable Text Mode

// uint8_t j=0;

 while(1)
  {
   number=isMessageNotification();

   if(number)
    {

	 readMsg(2,msg);
	 LCDGotoXY(0,0);
	 LCDPrint(msg);
	 //extractPinCode(msg,pin);
     //extractMachineCode(msg,machine);
     //extractItemCode(msg,item);
	 
	 //CDGotoXY(1,1);
	
	 if(!strcmp(machine,"vm001"))
	  {

	   //LCDGotoXY(0,0);
	   //LCDPrint("Good one");
	   //j++;
	   //LCDGotoXY(0,1);
	   //LCDData(j+48);
	  
	   /* motorCounter=item[2]-48;
	  
	   if(motorCounter<9)
	    {
	     PORTC=(1<<(motorCounter-1));
		 LCDPrint(product[motorCounter-1]);
		 LCDPrint("                ");
		}
	   else
	    {
	     PORTA|=(1<<PA7);
		 LCDPrint(product[8]);
		}
	  
	   while(!(PINA&(1<<PA0)));
	   
	   LCDGotoXY(1,1);
	   LCDPrint("Completed       ");

		PORTC=0;
		PORTA&=~(1<<PA7);
		
		strcpy(success,pin);
		strcat(success," SUCCESS");*/
		//deleteMsg();
		//_delay_ms(500);
		//sendMsg(pin);
		//_delay_ms(500);

		machine[0]=0;
		item[0]=0;
		pin[0]=0;
	  }
	}
  }
 
 return 0;

}
Exemplo n.º 17
0
void LCDPrintLines(char *line1, char *line2){
	LCDClear();
	LCDPrint (line1);
	LCDGotoXY(0, 1);
	LCDPrint (line2);
}
Exemplo n.º 18
0
int main(void)
{
	// Declaration and initialization of message-related data
	unsigned int txMsgSID = 0;
	unsigned char txMsgData[12] = {'1', '2', '3', '4', '5', 'S', 'X', 'U', 'C', 'L', 'D', 'R'};

	unsigned char buffer[32];
	unsigned int lenght = 0;
	unsigned int cursorPosition = 0;

	// Initialize keyboard, CAN and LCD
	KeybInit();
	CANinit(LOOPBACK_MODE, 0x0000, 0x0000);
	LCDInit();

	// Clear LCD
	LCDClear();

	// Char to save key pressed
	unsigned char c;

	while(1)
	{
		if(CANtransmissionCompleted())
		{
			// Get key pressed
			c = getKeyBlocking();

			if(lenght < 32 && cursorPosition < 32)
			{
				buffer[lenght] = txMsgData[c];
				lenght++;

				if(c == 0 || c == 1 || c == 2 || c == 3 || c == 4 || c == 11)
				{
					switch(c)
					{
						case 0:		LCDPrint("1");	break;
						case 1:		LCDPrint("2");	break;
						case 2:		LCDPrint("3");	break;
						case 3:		LCDPrint("4");	break;
						case 4:		LCDPrint("5");	break;
						case 11:	LCDMoveRight(); break;
					}

					// Cursor managment - Update position
					if(cursorPosition == 15)
					{
						// Cursor is at the end of the first line
						// Move to second line
						LCDMoveSecondLine();
					}
					// Increase cursor position
					cursorPosition++;
				}
				else if(c == 6 || c == 9)
				{
					// Pressed erase and go back key ( <- )
					if(cursorPosition == 0)
					{
						// Cursor is at the begining of the first line
						// Do nothing
					}
					else if(cursorPosition == 16)
					{
						// Cursor is at the begining of the second line
						// Move cursor to the last position of the first line
						LCDSetCursor(15);
						if(c == 6)
						{
							// Erase content (print a white space)
							LCDPrint(" ");
							// Move cursor back and decrease cursor position
							LCDMoveLeft();
						}
						cursorPosition--;
					}
					else
					{
						// Cursor is between extreme positions or at position 32
						// Move cursor back
						LCDMoveLeft();
						if(c == 6)
						{
							// Erase content (print a white space)
							LCDPrint(" ");
							// Move cursor back and decrease cursor position
							LCDMoveLeft();
						}
						cursorPosition--;
					}
				}
				else if(c == 7)
				{
					// Move to first line
					LCDMoveFirstLine();
					cursorPosition = 0;
				}
				else if(c == 10)
				{
					// Move to second line
					LCDMoveSecondLine();
					cursorPosition = 16;
				}
				else
				{
					// Pressed clear (C) or send (S)
					if(c == 8)
					{
						// Clear LCD
						LCDClear();
						// Move to home
						LCDMoveHome();
						// Set counter of cursor position to 0 (zero)
						cursorPosition = 0;
					}
					else
					{
						// Clear LCD and show message
						////////////////////
						//    SENDING!    //
						//                //
						////////////////////
						LCDClear();
						LCDMoveHome();
						LCDPrint("    SENDING!");

						// Wait 1s before start send
						for(i = 0; i < 200; i++) Delay5ms();
						// Clear LCD
						LCDClear();

						// Send message according keys pressed
						for(i = 0; i < lenght; i++)
						{
							CANsendMessage(txMsgSID, buffer[i]);
							// Wait until transmission complete
							while(CANtransmissionCompleted() == 0);
							// Wait 0,5s before send the next
							for(j = 0; j < 100; j++) Delay5ms();
						}

						lenght = 0;
						cursorPosition = 0;
						LCDMoveHome();
					}
				}
			}
			else
			{
				// Clear LCD and show message in two lines
				////////////////////
				//    WARNING!    //
				//  Full memory   //
				////////////////////
				LCDClear();
				LCDMoveHome();
				LCDPrint("    WARNING!");
				LCDMoveSecondLine();
				LCDPrint("  Full memory");

				// Pressed key send (S)
				if(c == 5)
				{
					// Clear LCD and show message
					////////////////////
					//    SENDING!    //
					//                //
					////////////////////
					LCDClear();
					LCDMoveHome();
					LCDPrint("    SENDING!");

					// Wait 1s before start send
					for(i = 0; i < 200; i++) Delay5ms();
					// Clear LCD
					LCDClear();

					// Send message according keys pressed
					for(i = 0; i < lenght; i++)
					{
						CANsendMessage(txMsgSID, buffer[i]);
						// Wait until transmission complete
						while(CANtransmissionCompleted() == 0);
						// Wait 0,5s before send the next
						for(j = 0; j < 100; j++) Delay5ms();
					}
				
					lenght = 0;
					cursorPosition = 0;
					LCDMoveHome();
				}
			}
		}
		// Wait 0,25s before to detect another time the key pressed
		for(i = 0; i < 50; i++) Delay5ms();
	}
}
Exemplo n.º 19
0
int main(){
	char **a;
	char **userNo;
	char **textContent;
	int textContentCounter = 0;
	int userNoCounter;

	DDRB = 0xFF;
	DDRD = 0b11111100;
	DDRC = 0xFF;
	DDRA = 0x00;
	PORTA = 0x00;

	initLCD();
	USART_Init(78);
	sei();
	/************************* display Init message ********************/
	LCDClear();
	LCDPrint ("uC working");
	_delay_ms(1000);
	/*******************************************************************/

	/****************************** GSM INIT ***************************/
	okComplete = 0;
	sendATCommand("at");
	while (okComplete == 0);

	if (okComplete == 1) {
		/************** GSM initilization success ******************/
		LCDClear();
		LCDPrintLines ("GSM init.:", "successful");
		/***********************************************************/

		/****** Check for EEPROM value and reset it ****************/
		/***********************************************************/
	}else {
		/************ GSM unsuccessful in initilization *************/
		LCDClear();
		LCDPrintLines ("GSM init.:", "failure");
		_delay_ms(1000);
		LCDClear();
		LCDPrint ("System Halting...");
		while (1);
		/************************************************************/
	}
	_delay_ms(1000);
	okComplete = 0;
	sendATCommand("at+cmgda=\"DEL ALL\"");
	while (okComplete == 0);
	if (okComplete == 1){
		LCDPrintLines ("message Delete",  "successful");
	} else if (okComplete == 2) {
		LCDPrintLines ("can't del. msg.", "system halting...");
		while (1);
	}
	_delay_ms(1000);
	okComplete = 1;
	/*******************************************************************/

	whatIsGoingOn = NOTHING;
	bufferCount = 0;
	while (1){
		if (okComplete == 1){
			//OK received
			LCDClear();
			if (whatIsGoingOn == NOTHING){
				LCDPrintLines("Vending Machine", "Code: vm001");
			} else if (whatIsGoingOn == MESSAGE_SEND_SUCCESSFULLY){
				LCDPrintLines("Product Dropped", "Thank You");
			} else if (whatIsGoingOn == ERRORV){
				LCDPrintLines ("Last Message:", "vmCode invalid");
			} else if (whatIsGoingOn == ERRORP){
				LCDPrintLines ("Last Message:", "itemCode invalid");
			} else if (whatIsGoingOn == ERRORR){
				LCDPrintLines ("Last Message:", "5 Retries Error");
			} else if (whatIsGoingOn == ERRORO){
				LCDPrintLines ("Last Message:", "Overfall");
			} else if (whatIsGoingOn == ERRORA){
				LCDPrintLines ("Last Message:", "unavail. product");
			} else if (whatIsGoingOn == ERRORPA){
				LCDPrintLines ("Last Message:", "und. pinCode len");
			}
			_delay_ms(1000);
			if (whatIsGoingOn != NOTHING){
				whatIsGoingOn = NOTHING;
				okComplete = 1;
			} else {
				okComplete = 0;
			}
		} else if (okComplete == 2){
			//ERROR Received
			LCDClear();
			LCDPrint ("Error Received");
			_delay_ms(1000);

			okComplete = 1;
		}else if (msgReceived == 1){
			//=CMTI Received
			LCDClear();
			LCDPrint ("msg rec @: ");

			if (msgNumber1 == 255){
				LCDData ((char)msgNumber);
			} else {
				LCDData ((char)msgNumber);
				LCDData ((char)msgNumber1);
			}

			/******** read message and process on it **************/

			//@1 set EEPROM
			//@1 (set EEPROM) complete

			okComplete = 0;
			/************** try 5 times to read SMS ***************/
			char repeatCounter = 2;
			while (repeatCounter <= 5){

				if (msgNumber1 == 255){
					sendATCommand1("at+cmgr=", msgNumber);
				} else {
					sendATCommand2("at+cmgr=", msgNumber, msgNumber1);
				}

				while ((okComplete == 0)){
					_delay_ms(200);
				}

				repeatCounter ++;
				if (okComplete == 1 || repeatCounter > 5){
					break;
				} else {
					okComplete = 0;
				}
			}
			/******************************************************/

			if (okComplete == 1){
				/*********** AT+CMGR value received in buffer *********/

				/*********** check for user number ********************/
				if (authCheck){
				userNo = split((char *) buffer, "\"", &userNoCounter);
				if (equals(userNo[3], AUTH_PHONENO) == 0){
					freeSplitedString(userNo, userNoCounter);
					sendMessage1 (phoneNo, "Unknown number detected: ", userNo[3], 2);
					msgReceived = 0;
					msgNumber = -1;
					msgNumber1 = -1;
					continue;
				}
				freeSplitedString(userNo, userNoCounter);
				}
				/******************************************************/

				/********** Check for message format ******************/
				//@1 Spliting message
				char *tempA2Lower;
				a = split((char*) buffer, checkPattern, (int *)&counter);

				tempA2Lower = toLower(a[2]);
				free(a[2]);
				a[2] = tempA2Lower;
				textContent = split (a[2], " ", &textContentCounter);

				pinCode = textContent[0];
				vmCode = textContent[1];
				productCode = textContent[2];
				//@1 Complete

				//@2 Check for 6 digit pinCode
				if (length(pinCode) == 6){
					//@3 check for vmMachine code
					if (equals(vmCode, "vm001") == 1){
						//@4 check for itemcode
						char *subSubString;
						subSubString = subString(productCode, 0, 1);
						if (equals(subSubString, "a")){
							char *subSubString2;

							//@5 check for productValue
							int productValue;
							subSubString2 = subString(productCode, 1, 2);
							productValue = toInteger(subSubString2);
							if (productValue > 6 || productValue < 1){
								/**** unavailable product ***********/
								sendMessage1 (phoneNo, pinCode, "unavailable product", 2);
								LCDPrintLines("Error: ", "unavailable product");
								whatIsGoingOn = ERRORA;
								/************************************/
							} else {
								/******** Every thing is correct drop the product *****/
								//@6 drop the product and display in LCD
								PORTC = (1 << (5 - (productValue - 1)));
								LCDPrintLines("Dropping", "Product: ");
								LCDPrint(subSubString2);
								//@6 (drop the product and display in LCD) complete

								//@7 start motor and count for 2 sec
								unsigned int fallCounter = 0;
								while ((!(bit_is_set(PINA, PA6))) && (!(bit_is_set(PINA, PA7)))) {
									/******* find out time take here *******/
									_delay_ms(1);
									if (fallCounter > 2000){
										break;
									}
									fallCounter++;
									/****************************************/
								}
								//@8 stop the motor and check for time
								PORTC = 0x00;
								if (fallCounter >= 2000) {
									/*********** overFall error **************/
									sendMessage1 (phoneNo, pinCode, "Overfall error", 2);
									LCDPrintLines("Error: ", "Overfall");
									whatIsGoingOn = ERRORO;
									/*****************************************/
								} else {
									/*********** success **************/
									sendMessage (phoneNo, pinCode, 1);
									LCDPrintLines("Drop: ", "successful");
									whatIsGoingOn = MESSAGE_SEND_SUCCESSFULLY;
									/*****************************************/
								}
								//@7 () Complete
								/******************************************************/
							}
							free (subSubString2);
							//@5 (Product value check) complete
						} else {
							/****** invalid vmCode *******/
							sendMessage1 (phoneNo, pinCode, "productCode invalid", 2);
							LCDPrintLines("Error: ", "productCode invalid");
							whatIsGoingOn = ERRORP;
							/*****************************/
						}
						free (subSubString);
						//@4 (check for itemcode) complete
					} else {
						/****** invalid vmCode *******/
						sendMessage1 (phoneNo, pinCode, "vmCode invalid", 2);
						LCDPrintLines("Error: ", "vmCode invalid");
						whatIsGoingOn = ERRORV;
						/*****************************/
					}
					//@3 (check for vmMachine code) completed
				} else {
					/******* invalid pinCode *******/
					sendMessage1 (phoneNo, pinCode, "pinCode invalid", 2);
					LCDPrintLines("Error: und.", "pinCode length");
					whatIsGoingOn = ERRORPA;
					/*******************************/
				}
				//@2 (check for 6 digit pinCode) complete
				freeSplitedString (a, counter);
				freeSplitedString (textContent, textContentCounter);
				/******************************************************/

				/******************************************************/
			} else if (okComplete == 2){
				/**************** error reading sms *******************/
				sendMessage (phoneNo, "couldn't read message from GSM modem", 2);
				LCDPrintLines("Err Reading SMS", "5 Retries Error");
				whatIsGoingOn = ERRORR;
				/******************************************************/
			}

			/*********** delete the message **************/
			if (msgNumber1 == 255) {
				sendATCommand1("at+cmgd=", msgNumber);
			} else {
				sendATCommand2("at+cmgd=", msgNumber, msgNumber1);
			}
			/*********************************************/

			//@2 reset EEPROM
			//@2 (reset EEPROM) complete

			_delay_ms(1000);

			msgNumber = -1;
			msgNumber1 = -1;
			msgReceived = 0;
		} else if (ringReceived == 1){
			//RING received
			LCDClear();
			LCDPrintLines("Message Received:","dummy message");
			_delay_ms(200);
			/******** read message and process on it **************/

			//@1 set EEPROM
			//@1 (set EEPROM) complete

			okComplete = 1;
			strCpy((char*)newBuffer, (char*)buffer);
			if (okComplete == 1){
				/*********** AT+CMGR value received in buffer *********/

				/*********** check for user number ********************/
				if (authCheck){
				userNo = split((char *) buffer, "\"", &userNoCounter);
				if (equals(userNo[3], AUTH_PHONENO) == 0){
					freeSplitedString(userNo, userNoCounter);
					sendMessage1 (phoneNo, "Unknown number detected: ", userNo[3], 2);
					msgReceived = 0;
					msgNumber = -1;
					msgNumber1 = -1;
					continue;
				}
				freeSplitedString(userNo, userNoCounter);
				}
				/******************************************************/

				/********** Check for message format ******************/
				//@1 Spliting message
				char *tempA2Lower;
				a = split((char*) buffer, checkPattern, (int *)&counter);

				tempA2Lower = toLower(a[2]);
				free(a[2]);
				a[2] = tempA2Lower;

				textContent = split (a[2], " ", &textContentCounter);

				pinCode = textContent[0];
				vmCode = textContent[1];
				productCode = textContent[2];
				//@1 Complete

				//@2 Check for 6 digit pinCode
				if (length(pinCode) == 6){
					//@3 check for vmMachine code
					if (equals(vmCode, "vm001") == 1){
						//@4 check for itemcode
						char *subSubString;
						subSubString = subString(productCode, 0, 1);
						if (equals(subSubString, "a")){
							char *subSubString2;

							//@5 check for productValue
							int productValue;
							subSubString2 = subString(productCode, 1, 2);
							productValue = toInteger(subSubString2);
							if (productValue > 6 || productValue < 1){
								/**** unavailable product ***********/
								LCDPrintLines("Error: ", "unavailable product");
								whatIsGoingOn = ERRORA;
								/************************************/
							} else {
								/******** Every thing is correct drop the product *****/
								//@6 drop the product and display in LCD
								PORTC = (1 << (5 - (productValue - 1)));
								LCDPrintLines("Dropping", "Product: ");
								LCDPrint(subSubString2);
								//@6 (drop the product and display in LCD) complete

								//@7 start motor and count for 2 sec
								unsigned int fallCounter = 0;
								while ((!(bit_is_set(PINA, PA6))) && (!(bit_is_set(PINA, PA7)))) {
									/******* find out time take here *******/
									_delay_ms(1);
									if (fallCounter > 2000){
										break;
									}
									fallCounter++;
									/****************************************/
								}
								//@8 stop the motor and check for time
								PORTC = 0x00;
								if (fallCounter >= 2000) {
									/*********** overFall error **************/
									LCDPrintLines("Error: ", "Overfall");
									whatIsGoingOn = ERRORO;
									/*****************************************/
								} else {
									/*********** success **************/
									LCDPrint("Drop success");
									whatIsGoingOn = MESSAGE_SEND_SUCCESSFULLY;
									/*****************************************/
								}
								//@7 () Complete
								/******************************************************/
							}
							free (subSubString2);
							//@5 (Product value check) complete
						} else {
							/****** invalid vmCode *******/
							LCDPrintLines("Error: ", "productCode invalid");
							whatIsGoingOn = ERRORP;
							/*****************************/
						}
						free (subSubString);
						//@4 (check for itemcode) complete
					} else {
						/****** invalid vmCode *******/
						LCDPrintLines("Error: ", "vmCode invalid");
						whatIsGoingOn = ERRORV;
						/*****************************/
					}
					//@3 (check for vmMachine code) completed
				} else {
					/******* invalid pinCode *******/
					LCDPrintLines("Error: und.", "pinCode length");
					whatIsGoingOn = ERRORPA;
					/*******************************/
				}
				//@2 (check for 6 digit pinCode) complete
				freeSplitedString (a, counter);
				freeSplitedString (textContent, textContentCounter);
				/******************************************************/

				/******************************************************/
			} else if (okComplete == 2){
				/**************** error reading sms *******************/
				LCDPrintLines("Err Reading SMS", "5 Retries Error");
				whatIsGoingOn = ERRORR;
				/******************************************************/
			}

			//@2 reset EEPROM
			//@2 (reset EEPROM) complete

			_delay_ms(1000);

			msgNumber = -1;
			msgNumber1 = -1;
			msgReceived = 0;
			/***********************************************************************/

			ringReceived = 0;
		}
	}
	return 0;
}
Exemplo n.º 20
0
int main(void)
{
	int i;
	
	
	RCC_Configuration();	                           //?????????????	        
	
	NVIC_Configuration();    
	LED_Config();
	TIM7_Configuration(10) ;
 
  RCC_Config();



 ADC_initial();
 UART1_Init();
 UART1_Config(9600);
 UART1_Cmd(ENABLE);
 UART1_Write("stm start",9);
 LCD_GLASS_Configure_GPIO();
 LCD_GLASS_Init();
      
	

 while (1)
 {
	  int wdt=0;
		int adc_wdt=0;
	  double adc=0;
	 //// solution 2 working String
	   i=0;
	 
     memcpy(buff2,buff, strlen(buff)); // ? buff ??? buff2
     memset(buff, 0, strlen(buff)); // ?? buff ???????  
						
	   while(1)
		 {
			  if(USART_GetFlagStatus(USART1,USART_FLAG_RXNE) != RESET)
				{
						char c = USART_ReceiveData(USART1); 
						i=i+1;				
						if(c == '\r')
							break;
						else 
						if (c == '\n')
							break;
						else
							 sprintf (buff, "%s%c", buff,c);
						
				}else
				{	
				    wdt++;
					  adc_wdt++;
					  if(adc_wdt%100==0)
						{
							 adc=(adc*99.0+GetADC())/100.0;	
						}
					  if(adc_wdt>10000)
						{
							 adc_wdt=0;
							 LCDPrint(" %0.1f ",adc);
						
						}
						if(wdt==50)
						{
								 wdt=0;
								
								 for(i=0;i<4;i++)
								 {
									 if(flag[i]==0)
									 {
											LED[i]++;
											if(LED[i]>300)
											{
													flag[i]=1;
											}
									 }else
									 {
											 LED[i]--;
											if(LED[i]==0)
											{
													flag[i]=0;
											} 
									 }
									}
								
							}
					}
				}
			/*	strcat(buff,"\n");
				UART1_Write(buff, strlen(buff));
				Lcd_print(buff);
*/				//	UART1_Write(")",1);
				USART_ClearFlag(USART1, USART_FLAG_RXNE);
			
			}
}