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

read state of rockets - with ble support

parent 83a19117
Branches
No related tags found
No related merge requests found
......@@ -114,7 +114,7 @@ static const uint8_t UUID_attChar_vibra[] = {
/* BLE UUID for card10 char rockets */
static const uint8_t UUID_char_rockets[] = {
ATT_PROP_WRITE_NO_RSP,
ATT_PROP_READ | ATT_PROP_WRITE_NO_RSP,
UINT16_TO_BYTES(CARD10_ROCKETS_VAL_HDL),
CARD10_UUID_SUFFIX, 0x10, CARD10_UUID_PREFIX
};
......@@ -123,6 +123,9 @@ static const uint8_t UUID_attChar_rockets[] = {
CARD10_UUID_SUFFIX, 0x10, CARD10_UUID_PREFIX
};
static uint8_t rocketsValue[] = { 0, 0, 0 };
static uint16_t rocketsLen = sizeof(rocketsValue);
/* BLE UUID for card10 led background bottom left */
static const uint8_t UUID_char_led_bg_bottom_left[] = {
ATT_PROP_WRITE_NO_RSP,
......@@ -302,12 +305,14 @@ static const attsAttr_t card10SvcAttrList[] = {
.maxLen = sizeof(UUID_char_rockets),
.permissions = ATTS_PERMIT_READ },
{ .pUuid = UUID_attChar_rockets,
.pValue = NULL,
.pValue = rocketsValue,
.pLen = &rocketsLen,
.maxLen = 3 * sizeof(uint8_t),
.settings = ATTS_SET_WRITE_CBACK,
.settings = (ATTS_SET_WRITE_CBACK | ATTS_SET_READ_CBACK),
.permissions =
(ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH) },
ATTS_PERMIT_WRITE_AUTH | ATTS_PERMIT_READ |
ATTS_PERMIT_READ_ENC | ATTS_PERMIT_READ_AUTH) },
// BG LED Bottom left
......@@ -736,6 +741,17 @@ static uint8_t readCard10CB(
APP_TRACE_INFO0("ble-card10: read time\n");
return ATT_SUCCESS;
case CARD10_ROCKETS_VAL_HDL:
pAttr->pValue[0] = epic_leds_get_rocket(0);
pAttr->pValue[1] = epic_leds_get_rocket(1);
pAttr->pValue[2] = epic_leds_get_rocket(2);
APP_TRACE_INFO3(
"ble-card10: get rockets 0:%d, 1:%d, 2:%d\n",
pAttr->pValue[0],
pAttr->pValue[1],
pAttr->pValue[2]
);
return ATT_SUCCESS;
case CARD10_PERSONAL_STATE_VAL_HDL:
ui16 = epic_personal_state_get();
*pAttr->pValue = ui16;
......
......@@ -95,6 +95,7 @@ typedef _Bool bool;
#define API_LEDS_SET_ALL_HSV 0x6b
#define API_LEDS_SET_GAMMA_TABLE 0x6c
#define API_LEDS_CLEAR_ALL 0x6d
#define API_LEDS_GET_ROCKET 0x6e
#define API_VIBRA_SET 0x70
#define API_VIBRA_VIBRATE 0x71
......@@ -705,6 +706,24 @@ API(API_LEDS_UPDATE, void epic_leds_update(void));
*/
API(API_LEDS_SET_ROCKET, void epic_leds_set_rocket(int led, uint8_t value));
/**
* Get the brightness of one of the rocket LEDs.
*
* :param int led: Which LED to get.
*
* +-------+--------+----------+
* | ID | Color | Location |
* +=======+========+==========+
* | ``0`` | Blue | Left |
* +-------+--------+----------+
* | ``1`` | Yellow | Top |
* +-------+--------+----------+
* | ``2`` | Green | Right |
* +-------+--------+----------+
* :return uint8_t value: Brightness of LED (value between 0 and 31).
*/
API(API_LEDS_GET_ROCKET, uint8_t epic_leds_get_rocket(int led));
/**
* Turn on the bright side LED which can serve as a flashlight if worn on the left wrist or as a rad tattoo illuminator if worn on the right wrist.
*
......
......@@ -100,6 +100,10 @@ void epic_leds_set_rocket(int led, uint8_t value)
value = value > 31 ? 31 : value;
pmic_set_led(led, value);
}
uint8_t epic_leds_get_rocket(int led)
{
pmic_get_led(led);
}
void epic_set_flashlight(bool power)
{
......
......@@ -122,7 +122,18 @@ void pmic_set_button_callback(pmic_button_callback_fn cb)
{
pmic_button_callback = cb;
}
uint8_t pmic_get_led(uint8_t led)
{
if (led == 0) {
return MAX77650_getBRT_LED0();
}
if (led == 1) {
return MAX77650_getBRT_LED1();
}
if (led == 2) {
return MAX77650_getBRT_LED2();
}
}
void pmic_set_led(uint8_t led, uint8_t val)
{
if (led == 0) {
......
......@@ -21,6 +21,7 @@
void pmic_init(void);
void pmic_set_led(uint8_t led, uint8_t val);
uint8_t pmic_get_led(uint8_t led);
void pmic_poll(void);
/* weak, so it can be overwritten by applications */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment