/*
 * @Author       : stark1898y 1658608470@qq.com
 * @Date         : 2024-08-29 13:54:45
 * @LastEditors: mbw && 1600520629@qq.com
 * @LastEditTime: 2024-12-30 10:43:36
 * @FilePath: \JT-DT-YD4N02A_RTT_MRS-4G\bsp\src\bsp_beep.c
 * @Description  :
 *
 * Copyright (c) 2024 by yzy, All Rights Reserved.
 */
#include "bsp_beep.h"
#include "rtthread.h"
#include "pin.h"

#define LOG_TAG     "bsp.beep"
#define LOG_LVL     LOG_LVL_DBG
#include <ulog.h>

//用到了atoi
#include <stdlib.h>

agile_led_t *beep = RT_NULL;

int BSP_BEEP_Init(void)
{
    beep = agile_led_create(BEEP_PIN, PIN_HIGH, "100,100", 0);
    BEEP_STOP;

    LOG_D("BSP_BEEP_Init");
    return RT_EOK;
}
// INIT_DEVICE_EXPORT(BSP_BEEP_Init);

#ifdef  TEST_ENABLE
static void TEST_BEEP(int argc, char **argv)
{
    if (argc == 3)
    {
        int loop_cnt = atoi(argv[2]);

        agile_led_dynamic_change_light_mode(beep, argv[1], loop_cnt);
        agile_led_start(beep);
    }
    else
    {
        LOG_E("TEST_BEEP      --use _cmd_ [mode][loop_cnt]");
    }
}
MSH_CMD_EXPORT(TEST_BEEP, "TEST_BEEP");

static void TEST_BEEP_Mode(int argc, char **argv)
{
    if (argc == 2)
    {
        int mode = atoi(argv[1]);
        switch (mode)
        {
            case 1:
                BEEP_PREAT_OK;
                break;
            case 2:
                BEEP_FAULT;
                break;
            case 3:
                BEEP_ALARM;
                break;
            case 4:
                BEEP_SELF_CHECK;
                break;
            case 5:
                BEEP_END_OF_LIFE;
                break;
            default:
                BEEP_STOP;
        }
    }
    else
    {
        LOG_E("TEST_BEEP_Mode      --use _cmd_ [mode]");
    }
}
MSH_CMD_EXPORT(TEST_BEEP_Mode, "TEST_BEEP_Mode");

#endif
