/* This function reads light by ap3216c sensor measurement */
uint16_t ap3216c_read_ambient_light(void)
/* This function reads light by ap3216c sensor measurement */
uint16_t ap3216c_read_ambient_light(void)
{
    uint16_t brightness = 0;
    uint16_t read_data;
    uint8_t  range;
    read_data = (uint16_t)read_low_and_high(AP3216C_ALS_DATA_L_REG, 1);
    ap3216c_get_param(AP3216C_ALS_RANGE, &range);
    if (range == AP3216C_ALS_RANGE_20661) {
        brightness =
            0.35 * read_data;
    } else if (range == AP3216C_ALS_RANGE_5162) {
        brightness =
            0.0788 * read_data;
    } else if (range == AP3216C_ALS_RANGE_1291) {
        brightness =
            0.0197 * read_data;
    } else if (range == AP3216C_ALS_RANGE_323) {
        brightness =
            0.0049 * read_data;
    }
    return brightness;
}