Skip to content

Commit 320035a

Browse files
committed
Re-arrange for PlatformIO support
1 parent 00ceff6 commit 320035a

File tree

5 files changed

+46
-14
lines changed

5 files changed

+46
-14
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.pio
2+
.idea
3+
CMake*
4+
CMakeListsPrivate.txt
5+
cmake-build-*/

platformio.ini

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
12+
[env:promini]
13+
platform = atmelavr
14+
board = pro8MHzatmega328
15+
framework = arduino

KellerLD.cpp renamed to src/KellerLD.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ void KellerLD::init() {
3232
year = scaling0 >> 11;
3333
month = (scaling0 & 0b0000011110000000) >> 7;
3434
day = (scaling0 & 0b0000000001111100) >> 2;
35-
35+
3636
// handle P-mode pressure offset (to vacuum pressure)
3737

38-
if (mode == 0) {
38+
if (mode == 0) {
3939
// PA mode, Vented Gauge. Zero at atmospheric pressure
4040
P_mode = 1.01325;
4141
} else if (mode == 1) {
@@ -49,11 +49,11 @@ void KellerLD::init() {
4949

5050
uint32_t scaling12 = (uint32_t(readMemoryMap(LD_SCALING1)) << 16) | readMemoryMap(LD_SCALING2);
5151

52-
P_min = *reinterpret_cast<float*>(&scaling12);
52+
P_min = *reinterpret_cast<float *>(&scaling12);
5353

5454
uint32_t scaling34 = (uint32_t(readMemoryMap(LD_SCALING3)) << 16) | readMemoryMap(LD_SCALING4);
5555

56-
P_max = *reinterpret_cast<float*>(&scaling34);
56+
P_max = *reinterpret_cast<float *>(&scaling34);
5757
}
5858

5959
void KellerLD::setFluidDensity(float density) {
@@ -69,13 +69,13 @@ void KellerLD::read() {
6969

7070
delay(9); // Max conversion time per datasheet
7171

72-
Wire.requestFrom(LD_ADDR,5);
72+
Wire.requestFrom(LD_ADDR, 5);
7373
status = Wire.read();
7474
P = (Wire.read() << 8) | Wire.read();
7575
uint16_t T = (Wire.read() << 8) | Wire.read();
76-
77-
P_bar = (float(P)-16384)*(P_max-P_min)/32768 + P_min + P_mode;
78-
T_degc = ((T>>4)-24)*0.05-50;
76+
77+
P_bar = (float(P) - 16384) * (P_max - P_min) / 32768 + P_min + P_mode;
78+
T_degc = ((T >> 4) - 24) * 0.05 - 50;
7979
}
8080

8181
uint16_t KellerLD::readMemoryMap(uint8_t mtp_address) {
@@ -87,37 +87,37 @@ uint16_t KellerLD::readMemoryMap(uint8_t mtp_address) {
8787

8888
delay(1); // allow for response to come in
8989

90-
Wire.requestFrom(LD_ADDR,3);
90+
Wire.requestFrom(LD_ADDR, 3);
9191
status = Wire.read();
9292
return ((Wire.read() << 8) | Wire.read());
9393
}
9494

9595
bool KellerLD::status() {
96-
if (equipment <= 62 ) {
96+
if (equipment <= 62) {
9797
return true;
9898
} else {
9999
return false;
100100
}
101101
}
102102

103103
float KellerLD::range() {
104-
return P_max-P_min;
104+
return P_max - P_min;
105105
}
106106

107107
float KellerLD::pressure(float conversion) {
108-
return P_bar*1000.0f*conversion;
108+
return P_bar * 1000.0f * conversion;
109109
}
110110

111111
float KellerLD::temperature() {
112112
return T_degc;
113113
}
114114

115115
float KellerLD::depth() {
116-
return (pressure(KellerLD::Pa)-101325)/(fluidDensity*9.80665);
116+
return (pressure(KellerLD::Pa) - 101325) / (fluidDensity * 9.80665);
117117
}
118118

119119
float KellerLD::altitude() {
120-
return (1-pow((pressure()/1013.25),0.190284))*145366.45*.3048;
120+
return (1 - pow((pressure() / 1013.25), 0.190284)) * 145366.45 * .3048;
121121
}
122122

123123
bool KellerLD::isInitialized() {

KellerLD.h renamed to src/KellerLD.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class KellerLD {
110110
uint16_t cust_id1;
111111

112112
uint16_t readMemoryMap(uint8_t mtp_address);
113+
114+
const int i2cAddress;
113115
};
114116

115117
#endif

src/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "Arduino.h"
2+
#include "KellerLD.h"
3+
4+
KellerLD sensor;
5+
6+
void setup() {
7+
}
8+
9+
void loop() {
10+
}

0 commit comments

Comments
 (0)