/*!
 * @file        main.c
 *
 * @brief       Main program body
 *
 * @version     V1.0.0
 *
 * @date        2022-11-15
 *
 * @attention
 *
 *  Copyright (C) 2022 Geehy Semiconductor
 *
 *  You may not use this file except in compliance with the
 *  GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
 *
 *  The program is only for reference, which is distributed in the hope
 *  that it will be useful and instructional for customers to develop
 *  their software. Unless required by applicable law or agreed to in
 *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
 *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
 *  and limitations under the License.
 */

/* Includes */
#include "main.h"
#include "usb_config.h"
#include "usbd_hid.h"
#include "usb_user.h"

/** @addtogroup Examples
  @{
*/

/** @addtogroup USBD_HID
  @{
*/

/** @defgroup USB_HID_Variables Variables
  @{
  */

/* Menu title string*/
const char *menuTitleStr[] =
{
    "     USB HID Example     ",
};

/* Menu item string*/
const char *menuItemStr[] =
{
    "KEY1 to Right key",
    "KEY2 to Left key",
    "KEY3 to UP key",
};

/* Menu bottom column string*/
const char *menuBottomColStr[] =
{
    "   GEEHY SEMICONDUCTOR   ",
};

/**@} end of group USB_HID_Variables*/

/** @defgroup USBD_HID_Functions Functions
  @{
*/

void Menu_DisplayInit(void);

/*!
 * @brief       Main program
 *
 * @param       None
 *
 * @retval      int
 */
int main(void)
{
    USBD_HID_GPIOInit();
    USBD_HID_Init();
    
    APM_LCDInit();
    LCD_Clear(0, 0, LCD_WIDTH, LCD_HEIGHT, LCD_BCOLOR);
    Menu_DisplayInit();
    
    printf("This is an example of USB HID.\r\n");

    while (1)
    {
        USBD_HID_Proc();
    }
}

/*!
 * @brief       Initialize the Menu UI
 *
 * @param       None
 *
 * @retval      None
 *
 * @note
 */
void Menu_DisplayInit(void)
{
    /* Menu title*/
    LCD_Clear(0, 0, LCD_WIDTH, 40, LCD_FCOLOR);
    LCD_DisplayString(20, LCD_LINE_TITLE, menuTitleStr[0], LCD_TEXT_SELECT_FC, LCD_TEXT_SELECT_BC, 16, 0);

    /* Menu item*/
    LCD_DisplayString(40, LCD_LINE_0, "ID Vendor =  0x314B", LCD_TEXT_FC, LCD_TEXT_BC, 16, 0);
    LCD_DisplayString(40, LCD_LINE_1, "ID Product = 0x0107", LCD_TEXT_FC, LCD_TEXT_BC, 16, 0);
    LCD_DisplayString(40, LCD_LINE_3, menuItemStr[0], LCD_TEXT_FC, LCD_TEXT_BC, 16, 0);
    LCD_DisplayString(40, LCD_LINE_4, menuItemStr[1], LCD_TEXT_FC, LCD_TEXT_BC, 16, 0);
    LCD_DisplayString(40, LCD_LINE_5, menuItemStr[2], LCD_TEXT_FC, LCD_TEXT_BC, 16, 0);

    /* Menu bottom*/
    LCD_Clear(0, LCD_LINE_BOTTOM, LCD_WIDTH, LCD_HEIGHT, LCD_FCOLOR);
    LCD_DisplayString(20, LCD_LINE_BOTTOM, menuBottomColStr[0], LCD_TEXT_SELECT_FC, LCD_TEXT_SELECT_BC, 16, 0);
}

/**@} end of group USBD_HID_Functions */
/**@} end of group USBD_HID */
/**@} end of group Examples */
