93 lines
1.9 KiB
C
93 lines
1.9 KiB
C
#include "led_drv.h"
|
|
#include "app_config.h"
|
|
|
|
#include "nrf_log.h"
|
|
|
|
#include "FreeRTOS.h"
|
|
#include "semphr.h"
|
|
#include "task.h"
|
|
|
|
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_20)
|
|
#include "apa102_2020.h"
|
|
static const led_drv_if_t *p_inst = &apa102_drv;
|
|
#else
|
|
static led_drv_if_t *p_inst = NULL;
|
|
#endif
|
|
|
|
static bool btWaitLedFlag = 0;
|
|
static bool noEventLedFlag = 0;
|
|
static bool preWorkLedFlag = 0;
|
|
static bool workingLedFlag = 0;
|
|
static bool postWorkLedFlag = 0;
|
|
|
|
int32_t led_mode(uint16_t mode_status)
|
|
{
|
|
btWaitLedFlag = 0;
|
|
noEventLedFlag = 0;
|
|
preWorkLedFlag = 0;
|
|
workingLedFlag = 0;
|
|
postWorkLedFlag = 0;
|
|
|
|
switch (mode_status)
|
|
{
|
|
case BT_WAIT:
|
|
btWaitLedFlag = 1;
|
|
NRF_LOG_INFO("%s(BT_WAIT) is unimplemented.", __FUNCTION__);
|
|
break;
|
|
|
|
case NO_EVENT:
|
|
noEventLedFlag = 1;
|
|
NRF_LOG_INFO("%s(NO_EVENT) is unimplemented.", __FUNCTION__);
|
|
break;
|
|
|
|
case PRE_WORK:
|
|
preWorkLedFlag = 1;
|
|
NRF_LOG_INFO("%s(PRE_WORK) is unimplemented.", __FUNCTION__);
|
|
break;
|
|
|
|
case WORKING:
|
|
workingLedFlag = 1;
|
|
NRF_LOG_INFO("%s(WORKING) is unimplemented.", __FUNCTION__);
|
|
break;
|
|
|
|
case POST_WORK:
|
|
postWorkLedFlag = 1;
|
|
NRF_LOG_INFO("%s(POST_WORK) is unimplemented.", __FUNCTION__);
|
|
break;
|
|
|
|
default:
|
|
NRF_LOG_INFO("%s(default) is unimplemented.", __FUNCTION__);
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int32_t led_set(struct led_color color)
|
|
{
|
|
if (p_inst == NULL)
|
|
{
|
|
return LED_DRV_ERROR;
|
|
}
|
|
|
|
if (p_inst->set != NULL)
|
|
{
|
|
for (int i = 0; i < 12; i++)
|
|
{
|
|
p_inst->set(i, color, 1);
|
|
}
|
|
return LED_DRV_SUCCESS;
|
|
}
|
|
|
|
return LED_DRV_SUCCESS;
|
|
}
|
|
|
|
int32_t led_init(void)
|
|
{
|
|
if (p_inst == NULL)
|
|
{
|
|
return LED_DRV_ERROR;
|
|
}
|
|
|
|
return p_inst->init();
|
|
}
|