#include "HardwareInfo.c"
#include "JMLib.c"
#include <SetLCDBack.h>
#include <SetLCDString.h>
#include <SetCentiS.h>
#include <GetButton1.h>
#include <GetButton2.h>
#include <SetColorSensorID.h>
#include <SetLCD3Char.h>
#include <SetInBeep.h>
#include <SetTenthS.h>
#include <GetColorSensorID.h>

int main(void)
{
    X3RCU_Init();
    unsigned int btn1 = 0;
    unsigned int m_id = 0;
    unsigned int idnew = 1;
    unsigned int btn2 = 0;
    SetLCDBack(1);
    //硬件接口
    SetLCDString(8, 0, "A1", YELLOW, BLACK);
    SetLCDString(8, 32, "Read ID:", YELLOW, BLACK);
    SetLCDString(8, 48, "Set  ID:", YELLOW, BLACK);
    SetCentiS(20);
    while (1)
    {
        //按键按下进行白平衡处理
        btn1 = GetButton1();
        btn2 = GetButton2();
        if ( btn1==1 )
        {
            SetColorSensorID(_COLOR_1_, 0, idnew);
        }
        if ( btn2 )
        {
            if ( idnew<8 )
            {
                idnew=idnew+1;
            }
            else
            {
                idnew=1;
            }
        }
        SetLCD3Char(72, 48, idnew, YELLOW, BLACK);
        if ( btn1||btn2 )
        {
            SetInBeep(1);
            SetTenthS(2);
            SetInBeep(0);
        }
        m_id = GetColorSensorID(_COLOR_1_);
        SetLCD3Char(72, 32, m_id, YELLOW, BLACK);
        if ( idnew!=m_id )
        {
            SetLCDString(8, 64, "Ready", YELLOW, BLACK);
        }
        else
        {
            SetLCDString(8, 64, "OK!  ", YELLOW, BLACK);
        }
        SetCentiS(10);
    }
    while(1);
}

