task_light_sensor.c
/******************************************************************************
* Examines lux values from the Light Sensor
******************************************************************************/
Examines lux values from the Light Sensor
Examines lux values from the Light Sensor
void Task_Light_Sensor_Bottom_Half(void *pvParameters)
{
    uint32_t lux;
    PACKMAN_MSG_t direction;
    while(1)
        {
            vTaskDelay(pdMS_TO_TICKS(250));
            lux = OPT3001_get_lux();
            if(lux<100){
                Packman_Color = LCD_COLOR_WHITE;
                direction.value = 25;
            }else if(lux>100 && lux <200){
                Packman_Color = LCD_COLOR_MAGENTA;
                direction.value = 22.22;
            }else if(lux>200 && lux <300){
                Packman_Color = LCD_COLOR_BLUE2;
                direction.value = 19.44;
            }else if(lux>300 && lux <400){
                Packman_Color = LCD_COLOR_BLUE2;
                direction.value = 16.66;
            }else if(lux>400 && lux <500){
                Packman_Color = LCD_COLOR_GREEN2;
                direction.value = 13.88;
            }else if(lux>500 && lux <800){
                Packman_Color = LCD_COLOR_GREEN;
                direction.value = 11.11;
            }else if(lux>800 && lux <1000){
                Packman_Color = LCD_COLOR_RED;
                direction.value = 8.33;
            }else if(lux>1000 && lux <1300){
                Packman_Color = LCD_COLOR_ORANGE ;
                direction.value = 5.55;
            }else if(lux>1300 && lux <1700){
                Packman_Color = LCD_COLOR_CYAN;
                direction.value = 2.77;
            }else if(lux>1700){
                Packman_Color = LCD_COLOR_YELLOW;
                direction.value = 1;
            }
            Draw_Fruit();
            Draw_Packman();
            direction.cmd = PACKMAN_CMD_SPEED;
            xQueueSend(Queue_Packman, &direction, portMAX_DELAY);
        }
}
void Task_Light_Sensor_Bottom_Half ( void * pvParameters ) { uint32_t lux ; PACKMAN_MSG_t direction ; while ( 1 ) { vTaskDelay ( pdMS_TO_TICKS ( 250 ) ) ; lux = OPT3001_get_lux ( ) ; if ( lux < 100 ) { Packman_Color = LCD_COLOR_WHITE ; direction . value = 25 ; } else if ( lux > 100 && lux < 200 ) { Packman_Color = LCD_COLOR_MAGENTA ; direction . value = 22.22 ; } else if ( lux > 200 && lux < 300 ) { Packman_Color = LCD_COLOR_BLUE2 ; direction . value = 19.44 ; } else if ( lux > 300 && lux < 400 ) { Packman_Color = LCD_COLOR_BLUE2 ; direction . value = 16.66 ; } else if ( lux > 400 && lux < 500 ) { Packman_Color = LCD_COLOR_GREEN2 ; direction . value = 13.88 ; } else if ( lux > 500 && lux < 800 ) { Packman_Color = LCD_COLOR_GREEN ; direction . value = 11.11 ; } else if ( lux > 800 && lux < 1000 ) { Packman_Color = LCD_COLOR_RED ; direction . value = 8.33 ; } else if ( lux > 1000 && lux < 1300 ) { Packman_Color = LCD_COLOR_ORANGE ; direction . value = 5.55 ; } else if ( lux > 1300 && lux < 1700 ) { Packman_Color = LCD_COLOR_CYAN ; direction . value = 2.77 ; } else if ( lux > 1700 ) { Packman_Color = LCD_COLOR_YELLOW ; direction . value = 1 ; } Draw_Fruit ( ) ; Draw_Packman ( ) ; direction . cmd = PACKMAN_CMD_SPEED ; xQueueSend ( Queue_Packman , & direction , portMAX_DELAY ) ; } }
Examines lux values from the Light Sensor
Examines lux values from the Light Sensor
//            print_device_id(); //            print_manufacturer_id(); // change the color and speed of packman depending on the ambient light // update the color of the fruit and packman