From da63ff03d3af123dcf71fff336dac511c991c8e5 Mon Sep 17 00:00:00 2001 From: Benny Liu Date: Fri, 23 Apr 2021 13:25:27 +0800 Subject: [PATCH] Add refresh TRIG01 LED function. --- .../cc26xx/app/headstage/EliteLED.h | 26 +++++++++++++++++-- .../cc26xx/app/headstage/Elite_def.h | 1 + .../cc26xx/app/headstage/headstage.h | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteLED.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteLED.h index 1d59229f1..2ac2ed8c3 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteLED.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteLED.h @@ -17,6 +17,7 @@ static void WorkModeLED(); static void update_LED_status (uint8_t chan, uint8_t bright, uint8_t red, uint8_t green, uint8_t blue); +static void refresh_LED(); static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue) { spi_LEDtxbuf[0] = 0x0000; @@ -111,6 +112,7 @@ static void ModeLED(uint16_t modeStatus) { preWorkLedFlag = 0; workingLedFlag = 0; postWorkLedFlag = 0; + TRIG01workFlag = 0; switch (modeStatus) { case BT_WAIT: { @@ -138,6 +140,11 @@ static void ModeLED(uint16_t modeStatus) { Elite_led_color(COLOR_BLUE); break; } + case TRIG01_WORK: { + TRIG01workFlag = 1; + refresh_LED(); + break; + } default: { LEDPowerON(); break; @@ -161,6 +168,9 @@ static void checkFlafLED() { else if(postWorkLedFlag == 1){ ModeLED(POST_WORK); } + else if(TRIG01workFlag == 1){ + ModeLED(TRIG01_WORK); + } } static void WorkModeLED() { @@ -227,9 +237,7 @@ static void LED_channel_write(uint8_t chan, uint8_t bright, uint8_t red, uint8_t LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf); } - static void update_LED_status (uint8_t chan, uint8_t bright, uint8_t red, uint8_t green, uint8_t blue) { - switch(chan) { case LED_PR0: { LED.LED_buf[2] = 0xE000 | ((uint16_t)bright << 8) | blue; @@ -293,5 +301,19 @@ static void TRIG_LED_Init() { LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf); } +static void refresh_LED() { + spi_LEDtxbuf[0] = 0x0000; + spi_LEDtxbuf[1] = 0x0000; + + for (int i = 2; i < SPI_LED_SIZE - 2; i += 2) { + spi_LEDtxbuf[i] = LED.LED_buf[i]; + spi_LEDtxbuf[i+1] = LED.LED_buf[i+1]; + } + + spi_LEDtxbuf[SPI_LED_SIZE - 2] = 0xffff; + spi_LEDtxbuf[SPI_LED_SIZE - 1] = 0xffff; + + LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf); +} #endif diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_def.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_def.h index bff99e8b5..1609364f1 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_def.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_def.h @@ -103,6 +103,7 @@ #define PRE_WORK 0x03 #define WORKING 0x04 #define POST_WORK 0x05 +#define TRIG01_WORK 0x06 #define VALUE_ZERO_TO_ONE(_v) (_v == 0) ? 1 : _v #endif diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h index 6c9803b9a..da0793f4e 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h @@ -591,6 +591,7 @@ static bool noEventLedFlag = 0; static bool preWorkLedFlag = 0; static bool workingLedFlag = 0; static bool postWorkLedFlag = 0; +static bool TRIG01workFlag = 0; static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow); @@ -1064,6 +1065,7 @@ static void update_ZM_instruction(uint8 *ins) { uint16_t TW1508in = 0; TW1508in = ((uint16_t) (ins[5]) << 8 ) | ((uint16_t) (ins[6])); + ModeLED(TRIG01_WORK); switch(ins[3]) { case AOUT_ADC :{ // 0x00