int main() { // striplights component init StripLights_Start(); /* Start UART component and clear the TX,RX buffers */ UART_Start(); UART_SpiUartClearRxBuffer(); // Switch on ESP8266's PD function CH_PD_SetDriveMode(CH_PD_DM_STRONG ) ; CH_PD_Write(1); // start UART for esp wifi uWIFI_Start(); uWIFI_SpiUartClearRxBuffer(); CyGlobalIntEnable; /* Un/comment this line to dis/enable global interrupts. */ // LED output P1_6_SetDriveMode(P1_6_DM_STRONG ) ; // LED on. P1_6_Write(1); //cycle each of the primaries on all LED's, DisplayClear sets and pushes to LED's, MemoryClear just clears the buffer. StripLights_DisplayClear( StripLights_RED_MASK ); CyDelay( 500 ); StripLights_DisplayClear( StripLights_GREEN_MASK ); CyDelay( 500 ); StripLights_DisplayClear( StripLights_BLUE_MASK ); CyDelay( 500 ); // Set to off StripLights_DisplayClear( 0 ); // uncomment for echo back, useful to setup ESP8266 as well //echo_uart(); run_server(); //reboot on return CySoftwareReset(); return 0; }
int main() { uint16 Diff, FPS; CyGlobalIntEnable; /* Enable global interrupts. */ PixelMask = 0; PixelCounter = 0; NoSpeed = 0; Timer_Start(); Timer_ISR_StartEx(Timer_ISR); StripLights_Start(); StripLights_Dim(0); StripLights_MemClear(0x00000000); StripLights_Trigger(1); // EZI2C_EzI2CSetBuffer1(sizeof(I2C_Struct.I2C_Buffer), sizeof(I2C_Struct.I2C_Buffer), I2C_Struct.I2C_Buffer); // EZI2C_Start(); Diff = 60; for(;;) { //any Hall captures yet? if(Timer_Capture_Flag) { if(Timer_Capture > Timer_Capture_Last) Diff = Timer_Capture - Timer_Capture_Last; else Diff = (65535 - Timer_Capture_Last) + Timer_Capture; Timer_Capture_Flag = 0; StepColors(); NoSpeed = 0; } //nope, maybe I stopped else { Timeout++; } //kill the lights if I'm standing still if(Timeout > 20000) { NoSpeed = 1; Timeout = 0; } FPS = FPS_SCALE/Diff; //not using this but it could be fun later // I2C_Struct.I2C_Buffer[0] = (uint8)(Diff >>8); // I2C_Struct.I2C_Buffer[1] = (uint8)Diff; // I2C_Struct.I2C_Buffer[2] = (uint8)(FPS >>8); // I2C_Struct.I2C_Buffer[3] = (uint8)FPS; // if (!(EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_BUSY)) // { // I2C_Struct.Capture = Diff; // } //OK, time to write out to the LEDs if(1 == NoSpeed) StripLights_MemClear(0x00000000); StripLights_Trigger(1); while(!StripLights_Ready()); } }