//------------------------------------------------------------------------------------------- void xenDemoSetPaused(bool bPaused){ if(bPaused){ swTimerStop(gameLoopTimerID); }else{ swTimerStart(gameLoopTimerID); } }
/********************************************************************************************* * Task to setup traffic light timer to send packets *********************************************************************************************/ void prvTrafficLightTask( void *pvParameters ) { // Setup timer to start the state machine // Send packet every 5 seconds sendTrafficLight = swTimerInit( 5000, REPEAT, prvSendTrafficLightCallback ); // Initialize the first state light_system_state = state_1; // Initialize the transition times timer_NS = 25; timer_EW = 30; swTimerStart(sendTrafficLight, 0); // Let task run infinitely for(;;) { // Process any incoming packets if( process_packet ) { // Create local string to represent the packet char* packet = pvPortMalloc( MAX_LENGTH*sizeof(uint8_t) ); // Pop packet from queue xQueueReceive( xPacketQueue, packet, 0 ); // Process packet handlePacket( packet ); // Free variables vPortFree( packet ); // Reset process_packet process_packet = FALSE; } // Send updated traffic packets if( update_traffic ) { // Light states systemState current_lights = current_system_state[light_system_state]; // Create Header Header* traffic_header = pvPortMalloc( sizeof(Header) ); traffic_header->addr = MY_ADDR; traffic_header->mode = allModes; // Iterate through all SAVs uint8_t sav; for(sav=0; sav<NUMBER_SAV; sav++){ // Check if active if( wifi_channel_active[sav] == TRUE ) { // Define destination traffic_header->dest = sav; // Send current state packet // traffic_header->type = trafficLightCurrent; // sendTrafficLightCurrent( traffic_header, current_lights.northSouth, current_lights.eastWest ); // Send future state packet traffic_header->type = trafficLightFuture; // sendTrafficLightFuture( traffic_header, next_light_state[current_lights.northSouth], timer_NS, // next_light_state[current_lights.eastWest], timer_EW ); sendTrafficLightFuture( traffic_header, current_lights.northSouth, timer_NS, current_lights.eastWest, timer_EW ); } } // Reset flag update_traffic = FALSE; // Free variables vPortFree( traffic_header ); } } }