void ReallyDisableEverything() //For the pause mode.
{
    DisableAll();
    
    MotorControl1EN_Write(1);
    CyDelay(10);
    MotorComms_UartPutChar(0);
    MotorControl1EN_Write(0);
    
    MotorControl2EN_Write(1);
    CyDelay(10);    
    MotorComms_UartPutChar(0);
    MotorControl2EN_Write(0);
    
    MotorControl3EN_Write(1);
    CyDelay(10);
    MotorComms_UartPutChar(0);
    MotorControl3EN_Write(0);
    
    MotorControl4EN_Write(1);
    CyDelay(10);
    MotorComms_UartPutChar(0);
    MotorControl4EN_Write(0);
    
    MotorControl5EN_Write(1);
    CyDelay(10);
    MotorComms_UartPutChar(0);
    MotorControl5EN_Write(0);
}
Esempio n. 2
0
int main(void) {
    uint8       x = 1;
    uint8       i;
    
    CR1_Write(0);
    
    LCD_Start();
    
    show();
    
    for(;;) {
        if (!SW2_Read()) {
            // PUSH button
            CY_SET_REG8(Fifo_dp_u0__F0_REG, x++);
            show();
            while (!SW2_Read()) {
                CyDelay(10);
            }
        }
        if (!SW3_Read()) {
            // PULL button
            for (i = 0; i < 7; i++) {
                v[i] = v[i+1];
            }
            v[7] = CY_GET_REG8(Fifo_dp_u0__F0_REG);
            show();
            while (!SW3_Read()) {
                CyDelay(10);
            }
        }
    }
}
Esempio n. 3
0
int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    InitNetwork();
    DisplayStart();
    RTC_WDT_Init();

    Display("Sync time...");
    CyDelay(2000);
    
    
    if(NTPsync() == TIME_SYNC_OK)
    {
        Display("Sync ok");
        CyDelay(4 * TIMEOUT_USER_READ_INFO);
        
        result = TIME_SYNC_OK;
    }
    else
    {
        Display("Sync time error");

        CyDelay(4 * TIMEOUT_USER_READ_INFO);
        
        result = TIME_SYNC_ERR;
    }

    for(;;)
    {
        DisplayRealTime();
        CyDelay(100);
    }
}
Esempio n. 4
0
int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    
    Clock_Start();
    SPIM_Start();
    
    setup_matrix();

    for(;;)
    {
        for(h=0;h<=256;h++)
        {
            for(i=0;i<8;i++)
            {
                dato=(((i+1)<<8)+fuente[h][i]);
                SPIM_WriteTxData(dato);
                CyDelay(1);
            }
            CyDelay(1000);
        }
                
        
    }
}
Esempio n. 5
0
WEAK void mbed_die(void) {
    
#ifndef EMUNO
    CyHalt(1);
    PWM_Start();
    PWM_WriteCompare2(0);
    CyPins_SetPinDriveMode(SW_USER, CY_PINS_DM_RES_UP);
    Bootloadable_SET_RUN_TYPE(0); // do not force bootloader
    
    while(1)
    {
        PWM_WriteCompare1(16);
        CyDelay(250);
        PWM_WriteCompare1(64);
        
        if (CyPins_ReadPin(SW_USER) == 0)
        {
            CyDelay(200); // allow yser to release btn, to not go into bootloader
            CySoftwareReset();
        }
        
        CyDelay(400);
        
        if (CyPins_ReadPin(SW_USER) == 0)
        {
            CyDelay(200); // allow yser to release btn, to not go into bootloader
            CySoftwareReset();
        }
    }
#endif

}
Esempio n. 6
0
void run()
{
    ADC_SAR_Seq_1_Start();
    ADC_SAR_Seq_1_StartConvert();

    initPSoCWiFi(SSID,PASS,DevKitIP);
    
    for(;;)
    {
        struct updateParameters values = getValues();     

        struct responses received = sendSensorData(values);

        ID = received.ID;
        wantedMoisture = received.moisture;
        wantedRotate = received.rotate;
        
        if(wantedMoisture >= values.currentMoisture)
        {
            start();
            CyDelay(1000);
            stop();
        }
        
        rotate(wantedRotate);
        
        CyDelay(6000); //10 min delay
    }
}
Esempio n. 7
0
int main()
{
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
    CYGlobalIntEnable; /* Uncomment this line to enable global interrupts. */

    IDAC8_1_Start();

    IDAC8_2_Start();

    CyDelay(1000);

    //Control_Reg_StimSel_Write(STIM_POS);
    for(;;)
    {

        IDAC8_1_SetValue(DAC_V1); //set vdac
        Control_Reg_StimSel_Write(STIM_POS); //switch mux
        CyDelay(PERIOD_P1);

        IDAC8_1_SetValue(0); //set vdac
        Control_Reg_StimSel_Write(STIM_GROUND); //switch mux
        CyDelay(PERIOD_DELAY);

        IDAC8_2_SetValue(DAC_V2); //set vdac
        Control_Reg_StimSel_Write(STIM_NEG); //switch mux
        CyDelay(PERIOD_P2);

        IDAC8_2_SetValue(0); //set vdac
        Control_Reg_StimSel_Write(STIM_GROUND); //switch mux
        CyDelay(PERIOD_INTERVAL);

        LED_B_Write(~LED_B_Read()); //Toggle LED

    }
}
Esempio n. 8
0
WEAK void error(const char* format, ...) {
#if DEVICE_STDIO_MESSAGES
    va_list arg;
    va_start(arg, format);
    vfprintf(stderr, format, arg);
    va_end(arg);
#endif
    
#ifndef EMUNO

    PWM_Start();
    PWM_WriteCompare2(64);
    CyDelay(200);
    PWM_WriteCompare2(0);
    CyDelay(600);
    PWM_WriteCompare2(64);
    CyDelay(200);
    PWM_WriteCompare2(0);
    
    exit(1);
    
#else
    
    printf("EMUNO HALT!");
    while(1);
    
#endif
    
//    Bootloadable_SET_RUN_TYPE(Bootloadable_START_APP);
//    CySoftwareReset();
}
Esempio n. 9
0
/*Requires Delay after call*/
uint8 MagReadByte(uint8 registerAddress, uint8 *readPtr)
{
	/* Pointer to the register address */
    //uint8 *writePtr = &registerAddress;/* changed writeptr to &registerAddress*/
	uint8 i2c_status = I2C_MasterClearStatus();
	//LCD_ClearDisplay();
	LCD_Position(1,7);
	LCD_PrintInt8(i2c_status);
	
	I2C_MasterClearReadBuf();
	I2C_MasterClearWriteBuf();
	
    /* Start the I2C transmission for a read */
    uint8 status = I2C_MasterWriteBuf(SLAVE_ADDRESS, &registerAddress, 1, I2C_MODE_NO_STOP);
    /*wait for the tranmission to finish */
    while (I2C_MasterStatus() && !I2C_MSTAT_WR_CMPLT){}
    /* Needed because of some bug in the psoc I2C tramission */
    CyDelay(1);
	/* read a byte using I2C */
	//return I2C_MasterReadBuf(SLAVE_ADDRESS, readPtr, 1, I2C_MODE_REPEAT_START);
	
	//or TO ENSURE READ IS COMPLETE BEFORE ADDITIONAL CODE EXECUTED
	status |= I2C_MasterReadBuf(SLAVE_ADDRESS,readPtr , 1, I2C_MODE_REPEAT_START);
	while (I2C_MasterStatus() && !I2C_MSTAT_RD_CMPLT){}
    CyDelay(1); //Needed because of some bug in the psoc I2C tramission
	return status;
}
Esempio n. 10
0
int main(void)
{    
    CyGlobalIntEnable; /* Enable global interrupts. */
    
    DisplayStart();
    Display("System init...");
    
    RTC_WDT_Init(); 
    InitNetwork();
    
    
    
    Display("Sync time...");

    uint8_t number = 0;
    while((result = NTPsync()) != TIME_SYNC_OK)
    {
        char buf[10];
        sprintf(buf, "Sync time -%d", number++);
        LCD_Position(0,0);
        LCD_PrintString(buf);
        CyDelay(500);
    }
    
    Display("Sync ok        ");
    CyDelay(4*TIMEOUT_USER_READ_INFO);
    
    for(;;)
    {
        DisplayRealTime();
        CyDelay(500);
    }
}
Esempio n. 11
0
void OUT_OnOff(int pin, int len)
{
    
    switch(pin) {
        
        case 1:
        
        OUT_1_Write( ! OUT_1_Read() );
        CyDelay( len );

        break;
        
        case 2:
        
        OUT_2_Write( ! OUT_2_Read() );
        CyDelay( len );
        
        break;
        
        default:
        
        break;
        
    }//switch(pin)
    
}//void OUT_OnOff(int, int)
Esempio n. 12
0
int main()
{
    char uartBuffer[80];
    char lcdBuffer[16];
    
    UART_1_Start();    
    UART_1_UartPutString("Sequencer Board Test\r\n");
    
    // Sequence Boardをリセット
    Pin_I2C_Reset_Write(0u);
    CyDelay(1);
    Pin_I2C_Reset_Write(1u);
    
    /* Init I2C */
    I2CM_Start();
    CyDelay(1500);
    
    CyGlobalIntEnable;
    
    LCD_Init();
    LCD_Clear();
	LCD_Puts("Sequencer Board");
    
    CyDelay(1000);
        
    for(;;)
    {  
        if (readSequencerBoard() == I2C_TRANSFER_CMPLT) {
            sprintf(uartBuffer, "%d %d %d %d %d %d ",
                sequencerRdBuffer[0],
                sequencerRdBuffer[1],
                sequencerRdBuffer[2],
                sequencerRdBuffer[3],
                sequencerRdBuffer[4],
                sequencerRdBuffer[5]
            );
            UART_1_UartPutString(uartBuffer);
        }
        else {
            UART_1_UartPutString("I2C Master Sequencer Read Error.\r\n");
        }
        
        if (writeSequencerBoard() == I2C_TRANSFER_CMPLT) {
            sprintf(uartBuffer, "%d\r\n", sequencerWrBuffer[0]);
            UART_1_UartPutString(uartBuffer);
        }
        else {
            UART_1_UartPutString("I2C Master Sequencer Write Error.\r\n");
        }
        
        sprintf(lcdBuffer, "%d", sequencerWrBuffer[0]);
        LCD_Clear();
        LCD_Puts(lcdBuffer);
        
        sequencerWrBuffer[0] = inc_within_uint8(sequencerWrBuffer[0], 16, 0);
        
        CyDelay(125);
    }
}
Esempio n. 13
0
File: main.c Progetto: kLabUM/IoT
uint8 blink_LED(uint8 n_blinks) {
	uint8 k;
	for (k = 0; k < n_blinks; k++) {
		LED_Write(1u);
		CyDelay(200u);
		LED_Write(0u);
		CyDelay(200u);
	}	
}
Esempio n. 14
0
void Sparkler ( uint16 runtime, int fade_amount , int num_sparkles ,char white ) 
{
    int x,j;
	led_color temp;

	// length of time to run
	for(x = 0; x <= runtime ; x++)
	{
		if(fade_amount ) {
			// Fade  strip	
			FadeStrip( StripLights_MIN_X, StripLights_MAX_X , fade_amount );
		} else { 
			StripLights_MemClear(0);
		}
		 
		
		// draw in same place 8 times
		for ( j = 0 ; j < num_sparkles ;j++ ){
						
			temp.c.r = calculate_sparkle( j );
			
			if (white ) { 
				temp.c.g = temp.c.b = temp.c.r;
			} else {
				temp.c.g = calculate_sparkle( j );
				temp.c.b = calculate_sparkle( j );
			}
				
			// draw a pixel 
			StripLights_Pixel(rand()%StripLights_MAX_X, 0, temp.rgb );
		}
		
	    // strip ready?
		while( StripLights_Ready() == 0);
		
		//push current data to led strip
	    StripLights_Trigger(1);
	    CyDelay( 3 );     
	}
	
	if( fade_amount ) {
		// fade at end
		for(x = 0; x <= 200 ; x++)
		{
			// Fade  strip	
			FadeStrip( StripLights_MIN_X, StripLights_MAX_X , fade_amount );

			// strip ready?
			while( StripLights_Ready() == 0);

			//push current data to led strip
			StripLights_Trigger(1);
			CyDelay( 3 );     
		}
	}		
}
Esempio n. 15
0
// an automated test that toggles the relay for the dynamixels
void dynamixelRelayTest() {
    while(1) {
        CyDelay(5000);
        TOGGLE_LED0;
        dynamixel_relay_Write(0);
        CyDelay(5000);
        TOGGLE_LED0;
        dynamixel_relay_Write(1);
    }
}
Esempio n. 16
0
/*******************************************************************************
* Function Name: main
********************************************************************************
* Summary:
*  Main function performs following functions:
*   1. Starts Character LCD and print project info
*   2. Starts SPI Master component
*   3. Configures the DMA transfer for RX and TX directions
*   4. Displays the results on Character LCD
*   
* Parameters:
*  None.
*
* Return:
*  None.
*
*******************************************************************************/
void main()
{
    uint8 i = 0u;
    CyGlobalIntEnable; 
    
    for(i=0u; i<8u; i++)
    {
        m_rxBuffer[i] = 0u;
    }
    
    LCD_Start();
    LCD_Position(0u,0u);
    LCD_PrintString("SPI Master");
    LCD_Position(1u,0u);
    LCD_PrintString("example");
    CyDelay(3000u);
    
    Dma_M_Tx_Configuration();
    Dma_M_Rx_Configuration();
    
    CyDmaChEnable(M_TxChannel, 1u); 
    CyDmaChEnable(M_RxChannel, 1u);
    
    LCD_Position(0u,0u);
    LCD_PrintString("Master Tx data:");
    LCD_Position(1u,0u);
    for(i=0u; i<8u; i++)
    {
        LCD_PrintHexUint8(m_txBuffer[i]);
    }
    
    CyDelay(5000u);
    SPIM_Start();
    
    while(!(SPIM_ReadTxStatus() & SPIM_STS_SPI_DONE));
    
    LCD_ClearDisplay();
    LCD_PrintString("Master Rx data:");
    LCD_Position(1u,0u);
    
    for(i=0u; i<8u; i++)
    {
        LCD_PrintHexUint8(m_rxBuffer[i]);
    }
    CyDelay(5000u);
    LCD_ClearDisplay();
    LCD_PrintString("SPI Master");
    LCD_Position(1u,0u);
    LCD_PrintString("example complete.");
     
    for(;;)
    {
        
    }
}
Esempio n. 17
0
File: ui.c Progetto: JFDuval/FlexSEA
//Power On Delay with LEDs
void power_on(void)
{
	set_led_rgb(1,0,0);
	CyDelay(250);
	set_led_rgb(0,1,0);
	CyDelay(250);
	set_led_rgb(0,0,1);
	CyDelay(250);
	set_led_rgb(0,0,0);
	CyDelay(250);
}
Esempio n. 18
0
void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )
{
	/* The stack space has been execeeded for a task, considering allocating more. */
	taskDISABLE_INTERRUPTS();
	for( ;; ) {
        Backlight_Write(0);
        CyDelay(500);
        Backlight_Write(1);
        CyDelay(500);
    }
}
Esempio n. 19
0
void vApplicationMallocFailedHook( void )
{
	/* The heap space has been execeeded. */
	taskDISABLE_INTERRUPTS();
	for( ;; ){
        Backlight_Write(0);
        CyDelay(2000);
        Backlight_Write(1);
        CyDelay(2000);
    }
}
Esempio n. 20
0
// automated test that moves 4 arm joints (all controlled with
// pololu PID boards)
void multiJointTest() {
    int i;
    uint16_t shoulder = 2048;
    uint16_t turret = 2048;
    uint16_t elbow = 2048;
    uint16_t forearm = 2048;
    uint16_t target = 2048;

    while (1) {
        // back to neutral
        TOGGLE_LED0;
        target = 2048;
        turret = shoulder = elbow = forearm = target;
        pololuControl_driveMotor(turret, POLOLUCONTROL_TURRET);
        pololuControl_driveMotor(shoulder, POLOLUCONTROL_SHOULDER);
        pololuControl_driveMotor(elbow, POLOLUCONTROL_ELBOW);
        pololuControl_driveMotor(forearm, POLOLUCONTROL_FOREARM);
        CyDelay(5000);
        
        // slowly move forward
        for (i = 0; i < 5; i++) {
            TOGGLE_LED0;
            target += 200;
            turret = shoulder = elbow = forearm = target;
            pololuControl_driveMotor(turret, POLOLUCONTROL_TURRET);
            pololuControl_driveMotor(shoulder, POLOLUCONTROL_SHOULDER);
            pololuControl_driveMotor(elbow, POLOLUCONTROL_ELBOW);
            pololuControl_driveMotor(forearm, POLOLUCONTROL_FOREARM);
            CyDelay(5000);
        }
        
        // back to neutral
        TOGGLE_LED0;
        target = 2048;
        turret = shoulder = elbow = forearm = target;
        pololuControl_driveMotor(turret, POLOLUCONTROL_TURRET);
        pololuControl_driveMotor(shoulder, POLOLUCONTROL_SHOULDER);
        pololuControl_driveMotor(elbow, POLOLUCONTROL_ELBOW);
        pololuControl_driveMotor(forearm, POLOLUCONTROL_FOREARM);
        CyDelay(5000);    
        
        // slowly move backward
        for (i = 0; i < 5; i++) {
            TOGGLE_LED0;
            target -= 200;
            turret = shoulder = elbow = forearm = target;
            pololuControl_driveMotor(turret, POLOLUCONTROL_TURRET);
            pololuControl_driveMotor(shoulder, POLOLUCONTROL_SHOULDER);
            pololuControl_driveMotor(elbow, POLOLUCONTROL_ELBOW);
            pololuControl_driveMotor(forearm, POLOLUCONTROL_FOREARM);
            CyDelay(5000);           
        }
    }
}
/*******************************************************************************
* Function Name: PhiAbGeneration
********************************************************************************
*
* Summary:
*  Generates PhiA pulses
*
* Parameters direction: 
*  count: count of pulses
*
* Return:
*  None
*
*******************************************************************************/
static void PhiAbGeneration(uint32 count)
{
	uint32 tmp;
	
	for(tmp=0; tmp < count; tmp++)
	{
            phiA_Out_Write (UP); 
			CyDelay(DELAY);
			phiA_Out_Write (DOWN); 
            CyDelay(DELAY);
	}
}
Esempio n. 22
0
void initPosServo()
{
    PWM_ServoBrasDroit_WriteCompare(PWM_DROIT_0);
    CyDelay(500);
    PWM_ServoBrasDroit_WriteCompare(0);
    PWM_ServoBrasGauche_WriteCompare(PWM_GAUCHE_0);
    CyDelay(500);
    PWM_ServoBrasGauche_WriteCompare(0);
    PWM_ServoQueue_WriteCompare(QUEUE_HAUTE);
    CyDelay(500);
    PWM_ServoQueue_WriteCompare(0);
}
Esempio n. 23
0
void LCD_Init(void)
{
    /* Enable Gnd, Vcc & Backlight pins */
    Gnd_Write(LOW);
    Vcc_Write(HIGH);
    BL_Write(HIGH);
    
    /* Reset the LCD - Active Low (1 -> 0 -> 1) */
    RST_Write(HIGH);
    CyDelay(DELAY_1_MS);
    RST_Write(LOW);
    CyDelay(DELAY_1_MS);
    RST_Write(HIGH);
    CyDelay(DELAY_1_MS);
    
    /* No Power Down, Horizontal Addressing Mode, Extended Instruction set */
    /* 0x21 = 0010 0001    Instruction : Function Set (H=1)*/
    LCD_Write(LCD_COMMAND, CMD_FUNCTION_SET | ((((PD_CHIP_ACTIVE << PD_SHIFT) & PD_MASK) \
    | ((V_HORIZONTAL_ADD << V_SHIFT) & V_MASK) | ((H_EXTENDED_INST << H_SHIFT) & H_MASK)) \
    & FUNCTION_SET_MASK));
        
    /* Set LCD Vop (Contrast): Try 0xB1(good @ 3.3V) or 0xBF if your display is too dark */
    /* 0xB1 = 1100 0000    Instruction : Set Vop */
    LCD_Write(LCD_COMMAND, CMD_SET_VOP | (SET_VOP_5V & SET_VOP_MASK));
  	
    /* Set Temp coefficent */
    /* 0x04 = 0000 0100    Instruction : Temperature Control */
    LCD_Write(LCD_COMMAND, CMD_TEMP_CONTROL | (TEMP_CONTROL_COEFF0 & TEMP_CONTROL_MASK));
  	
    /* LCD bias mode 1:48: Try 0x13 or 0x14 */
    /* 0x13 = 0001 0100    Instruction : Bias System */
    LCD_Write(LCD_COMMAND, CMD_BIAS_SYSTEM | (BIAS_1_BY_8 & BIAS_SYSTEM_MASK));
    
    /* We must send 0x20 before modifying the display control mode */
    /* 0x20 = 0010 0000    Instruction : Function set (H=0)*/
    LCD_Write(LCD_COMMAND, CMD_FUNCTION_SET | ((PD_CHIP_ACTIVE << (PD_SHIFT - 1)) & FUNCTION_SET_MASK));
    
    /* Set display control, normal mode. 0x0D for inverse */
    /* 0x0C = 0000 1101    Instruction : Display control */
    LCD_Write(LCD_COMMAND, CMD_DISPLAY_CONTROL | (DISPLAY_NORMAL & DISPLAY_CONTROL_MASK));
    
    /* Clear the LCD screen */
    LCD_Clear();
    
    /* Display bitmap image of Cypress Logo on the LCD */
//    LCD_Bitmap(CypressLogo);
    
    /* Wait for 1 second before clearing the display */
//    CyDelay(1000);
    
    LCD_Clear();
}
Esempio n. 24
0
int main()
{
   CyGlobalIntEnable; /* Enable global interrupts. */
init();
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
        setSpeed(30000,MOTOR_A);
        setSpeed(30000,MOTOR_B);
    for(;;)
    {
       
        goForward();
        CyDelay(2000);
        stop_all();
        CyDelay(2000);
        goBackward();
        CyDelay(2000);
        stop_all();
        CyDelay(2000);
        goLeft();
        CyDelay(2000);
        stop_all();
        CyDelay(2000);
        goRight();
        CyDelay(2000);
        stop_all();
        CyDelay(2000);
    }
}
Esempio n. 25
0
void LCD_Init()
{
	CyDelay(40);
	LCD_Cmd(0b00111000);	// function set
	LCD_Cmd(0b00111001);	// function set
	LCD_Cmd(0b00010100);	// interval osc
	LCD_Cmd(0b01110000 | (contrast & 0xF));	// contrast Low
	LCD_Cmd(0b01011100 | ((contrast >> 4) & 0x3)); // contast High/icon/power
	LCD_Cmd(0b01101100); // follower control
	CyDelay(300);
	
	LCD_Cmd(0b00111000); // function set
	LCD_Cmd(0b00001100); // Display On
}
Esempio n. 26
0
int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    for(;;)
    {
        PWM_Start();
        CyDelay(500);
        PWM_Stop();
        CyDelay(500);
    }
}
Esempio n. 27
0
// an automated test to switch between camera feeds
void cameraTest() {
    while(1) {
        selectCameras(0x00);
        CyDelay(8000);
        TOGGLE_LED0;
        selectCameras(0x11);
        CyDelay(8000);
        TOGGLE_LED0;
        selectCameras(0x22);
        CyDelay(8000);
        TOGGLE_LED0;
        
    }
}
Esempio n. 28
0
/*******************************************************************************
* Function Name: ReceiveData
********************************************************************************
*
* Summary:
*   receive data from start in struct "inData"
* Return:
*   NETWORK_CONNECT or NETWORK_DISCONNECT
*
*******************************************************************************/
uint32_t  ReceiveData(void)
{   
    if(inData.readStatus == NO_READ && outData.writeStatus == WRITE_OK)
    {
        uint32_t result = 0;
        int i;
        uint8_t byte;
        struct Resp recvData;
          
        while((UART_XB_SpiUartGetRxBufferSize() > 0) && ((byte=UART_XB_UartGetChar()) != 0))
        { 
            result = UnpackData(&recvData, (uint8_t)(byte & 0xFF));
            CyDelay(2);
            
            
            if(recvData.EndPacket == 1)
            {
                inData.IDpacket = recvData.Seq;
                
                /*id packet ok*/
                if(outData.IDpacket == inData.IDpacket)
                {
                    inData.readStatus = READ_OK;
                    outData.writeStatus = NO_WRITE;
                    
                    /*connect network*/
                    networkStatus = NETWORK_CONNECT;
                    noConnect = 0;
                    
                    /*write data*/
                    inData.newSkier = (recvData.Data3 & 0xFF00) >> 8;
                    inData.unixStartTime = recvData.Data1;
                    inData.startMsTime = recvData.Data2;
                    inData.reboot = (recvData.Data3 & 0x00FF);
                    
                    /*if new skier on track*/
                    if(inData.newSkier == NEW_SKIER_IN_TARCK )
                    {
                        WriteStartTime(inData.unixStartTime, inData.startMsTime);
                        BLE_sendOneSkierTimeStart(inData.unixStartTime, inData.startMsTime,GetIDskierStarted(),SkierOnWay(),MAX_SKIERS_ON_WAY);
                        IncrementID();
                    }
                    
                    /*next packet*/
                    outData.IDpacket++;
                    CyDelay(50);
                }  
                /* if prev packet late*/
                else if(outData.IDpacket == (inData.IDpacket + 1))
Esempio n. 29
0
void BAT_Simulate()
{
    uint8 IDAC_VAL;
            
    for(IDAC_VAL = 50; IDAC_VAL < 100; IDAC_VAL++)
    {
        IDAC_1_SetValue(IDAC_VAL);
        CyDelay(10);
    }
    for(IDAC_VAL = 100; IDAC_VAL > 90; IDAC_VAL--)
    {
        IDAC_1_SetValue(IDAC_VAL);
        CyDelay(100);
    }
}
Esempio n. 30
0
uint32 TweenerHSV( uint16_t startx, uint16_t count, uint32 from,uint32 to,uint32 delay,int direction) 
{
    int i;
	int offset;
	led_color frgb,trgb;
    hsv_color  src, target,result;

	trgb.rgb = to;
	frgb.rgb = from;
	
	src = rgb_to_hsv( frgb ) ;
	target = rgb_to_hsv( trgb );

	result = src;
	
	offset = startx;
	
    for( i = 1 ; i < count; i ++ )
    {
        result.h.h = TweenU8toU8(src.h.h, target.h.h, i);
        
      	StripLights_PixelHSV(offset, 0, result );
		
		offset += direction;
		
		if (offset < (int)StripLights_MIN_X ) offset = startx ;
		if (offset > startx+count ) offset = StripLights_MIN_X ;
      	
        BOOT_CHECK();    
		
		if(delay) {
   			while( StripLights_Ready() == 0);

			StripLights_Trigger(1);
			CyDelay( delay );
		}
		
    }
		    
   while( StripLights_Ready() == 0);

	StripLights_Trigger(1);

   CyDelay( 5 );


	return result.hsv;
}