Skip to content

Commit a687e70

Browse files
Feature/enum cleanup (#15)
* Move enum into Constants.h to be more broadly available * line length and curly brace cleanup * Added extra const to intermediate variable. Co-authored-by: Aaron Marburg <[email protected]>
1 parent f619fc3 commit a687e70

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

include/liboculus/Constants.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,13 @@ struct FlagBits {
8484
static const uint8_t Do512Beams = (0x01) << 6;
8585
};
8686

87-
} // namespace liboculus
87+
// There doesn't appear to be an enum for the masterMode (like there is
88+
// for pingRate and dataSize), so creating our own to match comments in
89+
// liboculus/thirdparty/Oculus/Oculus.h.
90+
typedef enum {
91+
OCULUS_LOW_FREQ = 1,
92+
OCULUS_HIGH_FREQ = 2
93+
} OculusFreqMode;
94+
95+
96+
} // namespace liboculus

include/liboculus/SonarConfiguration.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <boost/asio.hpp>
3535

3636
#include "Oculus/Oculus.h"
37+
#include "liboculus/Constants.h"
3738

3839
namespace liboculus {
3940

@@ -57,11 +58,6 @@ class SonarConfiguration {
5758
SonarConfiguration &setFlags(uint8_t flags);
5859
SonarConfiguration &setWaterTemperature(double degC);
5960

60-
typedef enum {
61-
OCULUS_LOW_FREQ = 1,
62-
OCULUS_HIGH_FREQ = 2
63-
} OculusFreqMode;
64-
6561
SonarConfiguration &setFreqMode(OculusFreqMode input);
6662
OculusFreqMode getFreqMode() const {
6763
if (_sfm.masterMode == 1)
@@ -96,9 +92,7 @@ class SonarConfiguration {
9692
SonarConfiguration &use512Beams() { return set512Beams(true); }
9793
bool get512Beams() const { return _512beams;}
9894

99-
10095
bool getSendGain() const { return _sendGain; }
101-
//bool getData16Bit() const { return _16bitData; }
10296
bool getSimpleReturn() const { return _simpleReturn; }
10397
bool getGainAssistance() const { return _gainAssistance; }
10498

lib/SonarConfiguration.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,13 @@ std::vector<uint8_t> SonarConfiguration::serialize<OculusSimpleFireMessage>() co
191191

192192
void SonarConfiguration::updateFlags() const {
193193
_sfm.extFlags = 0;
194-
if (_dataSize == dataSize32Bit)
194+
if (_dataSize == dataSize32Bit) {
195195
_sfm.extFlags |= 0x00000200;
196+
}
196197

198+
const bool more_than_8bit = (_dataSize == dataSize16Bit) || (_dataSize == dataSize32Bit);
197199
_sfm.flags = (_rangeInMeters ? FlagBits::RangeAsMeters : 0 ) |
198-
(((_dataSize == dataSize16Bit) || (_dataSize == dataSize32Bit)) ? FlagBits::Data16Bits : 0) |
200+
(more_than_8bit ? FlagBits::Data16Bits : 0) |
199201
(_sendGain ? FlagBits::DoSendGain : 0) |
200202
(_simpleReturn ? FlagBits::SimpleReturn : 0) |
201203
(_gainAssistance ? FlagBits::GainAssistance : 0) |
@@ -221,7 +223,4 @@ void SonarConfiguration::dump() const {
221223
<< "\n use 512 beams " << get512Beams();
222224
}
223225

224-
225-
226-
227226
} // namespace liboculus

0 commit comments

Comments
 (0)