Skip to content
Snippets Groups Projects
Verified Commit d2a91e93 authored by genofire's avatar genofire
Browse files

ble: card10 svc - put bg leds into function

parent 6992ef6e
No related branches found
No related tags found
No related merge requests found
...@@ -533,6 +533,38 @@ static uint8_t setTime(uint8_t *pValue) ...@@ -533,6 +533,38 @@ static uint8_t setTime(uint8_t *pValue)
return ATT_SUCCESS; return ATT_SUCCESS;
} }
/*
* Set a rgb led
*/
static uint8_t setRGBLed(uint8_t led, uint8_t *pValue)
{
epic_leds_set(led, pValue[0], pValue[1], pValue[2]);
APP_TRACE_INFO4(
"ble-card10: set rgb led %d: #%02x%02x%02x\n",
led,
pValue[0],
pValue[1],
pValue[2]
);
return ATT_SUCCESS;
}
/*
* Get value of a rgb led
*/
static uint8_t getRGBLed(uint8_t led, attsAttr_t *pAttr)
{
epic_leds_get_rgb(led, pAttr->pValue);
APP_TRACE_INFO4(
"ble-card10: set rgb led %d: #%02x%02x%02x\n",
led,
pAttr->pValue[0],
pAttr->pValue[1],
pAttr->pValue[2]
);
return ATT_SUCCESS;
}
/* /*
* BLE card10 write callback. * BLE card10 write callback.
*/ */
...@@ -573,41 +605,13 @@ static uint8_t writeCard10CB( ...@@ -573,41 +605,13 @@ static uint8_t writeCard10CB(
return ATT_SUCCESS; return ATT_SUCCESS;
// bg leds // bg leds
case CARD10_LED_BG_BOTTOM_LEFT_VAL_HDL: case CARD10_LED_BG_BOTTOM_LEFT_VAL_HDL:
epic_leds_set(11, pValue[0], pValue[1], pValue[2]); return setRGBLed(11, pValue);
APP_TRACE_INFO3(
"ble-card10: set bg bottom left: #%02x%02x%02x\n",
pValue[0],
pValue[1],
pValue[2]
);
return ATT_SUCCESS;
case CARD10_LED_BG_BOTTOM_RIGHT_VAL_HDL: case CARD10_LED_BG_BOTTOM_RIGHT_VAL_HDL:
epic_leds_set(12, pValue[0], pValue[1], pValue[2]); return setRGBLed(12, pValue);
APP_TRACE_INFO3(
"ble-card10: set bg bottom right: #%02x%02x%02x\n",
pValue[0],
pValue[1],
pValue[2]
);
return ATT_SUCCESS;
case CARD10_LED_BG_TOP_RIGHT_VAL_HDL: case CARD10_LED_BG_TOP_RIGHT_VAL_HDL:
epic_leds_set(13, pValue[0], pValue[1], pValue[2]); return setRGBLed(13, pValue);
APP_TRACE_INFO3(
"ble-card10: set bg top right: #%02x%02x%02x\n",
pValue[0],
pValue[1],
pValue[2]
);
return ATT_SUCCESS;
case CARD10_LED_BG_TOP_LEFT_VAL_HDL: case CARD10_LED_BG_TOP_LEFT_VAL_HDL:
epic_leds_set(14, pValue[0], pValue[1], pValue[2]); return setRGBLed(14, pValue);
APP_TRACE_INFO3(
"ble-card10: set bg top left: #%02x%02x%02x\n",
pValue[0],
pValue[1],
pValue[2]
);
return ATT_SUCCESS;
// dim // dim
case CARD10_LEDS_BOTTOM_DIM_VAL_HDL: case CARD10_LEDS_BOTTOM_DIM_VAL_HDL:
ui8 = pValue[0]; ui8 = pValue[0];
...@@ -773,41 +777,13 @@ static uint8_t readCard10CB( ...@@ -773,41 +777,13 @@ static uint8_t readCard10CB(
return ATT_SUCCESS; return ATT_SUCCESS;
// background leds // background leds
case CARD10_LED_BG_BOTTOM_LEFT_VAL_HDL: case CARD10_LED_BG_BOTTOM_LEFT_VAL_HDL:
epic_leds_get_rgb(11, pAttr->pValue); return getRGBLed(11, pAttr);
APP_TRACE_INFO3(
"ble-card10: set bg bottom left: #%02x%02x%02x\n",
pAttr->pValue[0],
pAttr->pValue[1],
pAttr->pValue[2]
);
return ATT_SUCCESS;
case CARD10_LED_BG_BOTTOM_RIGHT_VAL_HDL: case CARD10_LED_BG_BOTTOM_RIGHT_VAL_HDL:
epic_leds_get_rgb(12, pAttr->pValue); return getRGBLed(12, pAttr);
APP_TRACE_INFO3(
"ble-card10: get bg bottom right: #%02x%02x%02x\n",
pAttr->pValue[0],
pAttr->pValue[1],
pAttr->pValue[2]
);
return ATT_SUCCESS;
case CARD10_LED_BG_TOP_RIGHT_VAL_HDL: case CARD10_LED_BG_TOP_RIGHT_VAL_HDL:
epic_leds_get_rgb(13, pAttr->pValue); return getRGBLed(13, pAttr);
APP_TRACE_INFO3(
"ble-card10: get bg top right: #%02x%02x%02x\n",
pAttr->pValue[0],
pAttr->pValue[1],
pAttr->pValue[2]
);
return ATT_SUCCESS;
case CARD10_LED_BG_TOP_LEFT_VAL_HDL: case CARD10_LED_BG_TOP_LEFT_VAL_HDL:
epic_leds_get_rgb(14, pAttr->pValue); return getRGBLed(14, pAttr);
APP_TRACE_INFO3(
"ble-card10: get bg top left: #%02x%02x%02x\n",
pAttr->pValue[0],
pAttr->pValue[1],
pAttr->pValue[2]
);
return ATT_SUCCESS;
// personal state // personal state
case CARD10_PERSONAL_STATE_VAL_HDL: case CARD10_PERSONAL_STATE_VAL_HDL:
ui16 = epic_personal_state_get(); ui16 = epic_personal_state_get();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment