From 7396e2665d1ec7063547c9883eab1af7c788dc51 Mon Sep 17 00:00:00 2001 From: mikeller Date: Sun, 25 Jun 2017 16:49:49 +1200 Subject: [PATCH] Removed 'boxId' from 'rcsplitSwitchState_t', cleaned up naming. --- src/main/io/rcsplit.c | 5 ++--- src/main/io/rcsplit.h | 9 ++++----- src/test/unit/rcsplit_unittest.cc | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/io/rcsplit.c b/src/main/io/rcsplit.c index e9533bed6..774d40aa6 100644 --- a/src/main/io/rcsplit.c +++ b/src/main/io/rcsplit.c @@ -40,8 +40,8 @@ // communicate with camera device variables serialPort_t *rcSplitSerialPort = NULL; -rcsplit_switch_state_t switchStates[BOXCAMERA3 - BOXCAMERA1 + 1]; -rcsplit_state_e cameraState = RCSPLIT_STATE_UNKNOWN; +rcsplitSwitchState_t switchStates[BOXCAMERA3 - BOXCAMERA1 + 1]; +rcsplitState_e cameraState = RCSPLIT_STATE_UNKNOWN; static uint8_t crc_high_first(uint8_t *ptr, uint8_t len) { @@ -138,7 +138,6 @@ bool rcSplitInit(void) // set init value to true, to avoid the action auto run when the flight board start and the switch is on. for (boxId_e i = BOXCAMERA1; i <= BOXCAMERA3; i++) { uint8_t switchIndex = i - BOXCAMERA1; - switchStates[switchIndex].boxId = 1 << i; switchStates[switchIndex].isActivated = true; } diff --git a/src/main/io/rcsplit.h b/src/main/io/rcsplit.h index 6900700ee..85b4d347a 100644 --- a/src/main/io/rcsplit.h +++ b/src/main/io/rcsplit.h @@ -22,15 +22,14 @@ #include "fc/fc_msp.h" typedef struct { - uint8_t boxId; bool isActivated; -} rcsplit_switch_state_t; +} rcsplitSwitchState_t; typedef enum { RCSPLIT_STATE_UNKNOWN = 0, RCSPLIT_STATE_INITIALIZING, RCSPLIT_STATE_IS_READY, -} rcsplit_state_e; +} rcsplitState_e; // packet header and tail #define RCSPLIT_PACKET_HEADER 0x55 @@ -51,6 +50,6 @@ bool rcSplitInit(void); void rcSplitProcess(timeUs_t currentTimeUs); // only for unit test -extern rcsplit_state_e cameraState; +extern rcsplitState_e cameraState; extern serialPort_t *rcSplitSerialPort; -extern rcsplit_switch_state_t switchStates[BOXCAMERA3 - BOXCAMERA1 + 1]; +extern rcsplitSwitchState_t switchStates[BOXCAMERA3 - BOXCAMERA1 + 1]; diff --git a/src/test/unit/rcsplit_unittest.cc b/src/test/unit/rcsplit_unittest.cc index 67be33ae7..59364ce29 100644 --- a/src/test/unit/rcsplit_unittest.cc +++ b/src/test/unit/rcsplit_unittest.cc @@ -47,7 +47,7 @@ extern "C" { int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000] - rcsplit_state_e unitTestRCsplitState() + rcsplitState_e unitTestRCsplitState() { return cameraState; } @@ -55,7 +55,7 @@ extern "C" { bool unitTestIsSwitchActivited(boxId_e boxId) { uint8_t adjustBoxID = boxId - BOXCAMERA1; - rcsplit_switch_state_t switchState = switchStates[adjustBoxID]; + rcsplitSwitchState_t switchState = switchStates[adjustBoxID]; return switchState.isActivated; } @@ -428,4 +428,4 @@ extern "C" { bool feature(uint32_t) { return false;} void serialWriteBuf(serialPort_t *instance, const uint8_t *data, int count) { UNUSED(instance); UNUSED(data); UNUSED(count); } -} \ No newline at end of file +}