// According to Gavin's "PCBA TEST_Side_Main(0.2)&KEY(0.2)_V0.0_20211130.xlsx".

    
    
// Init    
LL_PWM_DutySet(E_LL_PWM_FRONT_WHITE, 100); LL_PWM_ON(E_LL_PWM_FRONT_WHITE);
LL_PWM_DutySet(E_LL_PWM_FRONT_RED, 100); LL_PWM_OFF(E_LL_PWM_FRONT_RED); 
LL_PWM_DutySet(E_LL_LED_PCB_B, 100); LL_PWM_OFF(E_LL_LED_PCB_B);
//unsigned long lights_RGB[3][4] = { 
//    I2C_LED1, I2C_LED4, I2C_LED7, I2C_LED10,    // R
//    I2C_LED2, I2C_LED5, I2C_LED8, I2C_LED11,    // G
//    I2C_LED3, I2C_LED6, I2C_LED9, I2C_LED12,    // B
//};


    
// Testing
unsigned long index_RGB = 0;
unsigned long count_loop = 0;
do {    
    // Front White: solid ON if button pressed, else, toggle ON/OFF.
    LL_PWM_Toggle(E_LL_PWM_FRONT_WHITE);
    //
    // red
    LL_PWM_Toggle(E_LL_PWM_FRONT_RED);
    //
    // a small RGB for charging and testing: toggle ON/OFF
    LL_PWM_Toggle(E_LL_LED_PCB_B);
    //
    // RGB
    { 
        // clear all the lights
        for(int sw = 1; sw <= 3; sw++) {
            for(int cs = 1; cs <= 4; cs++) {
                LL_LED_Panel__setBuffer(0, cs, sw, 0); // turn OFF
            }
        }
        //
        // turn ON the R/G/B acc to index
        index_RGB++; if(index_RGB > 3) { index_RGB = 1; }
        for(int cs = 1; cs <= 4; cs++) {
            LL_LED_Panel__setBuffer(0, cs, index_RGB, 255); // turn ON
        }; LL_LED_Panel__refresh();
    }
    //
    // variable delay according to accelerometer
    LL_AccGyro_Read(); if(gssLSM_XL[0] < 0) { nrf_delay_ms(500); } else { nrf_delay_ms(250); }
    //
    count_loop++; if(count_loop >= 3*5) { 
        if(BUTTON_STATE_IS_PRESSED) { 
            // clear all the lights
            for(int sw = 1; sw <= 3; sw++) {
                for(int cs = 1; cs <= 4; cs++) {
                    LL_LED_Panel__setBuffer(0, cs, sw, 0); // turn OFF
                }
            }; LL_LED_Panel__refresh();
        break; }
    }
} while(1); // loop


