Skip to content

Commit ca8d37e

Browse files
authored
Merge pull request #221 from thebrownhobbit-commits/add-lps28dfw-mode
Add Mode 1/2 option for LPS28DFW sensor with SD card persistence
2 parents 721d455 + d621bea commit ca8d37e

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

Firmware/OpenLog_Artemis/autoDetect.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ bool beginQwiicDevices()
440440
temp->online = tempDevice->begin(temp->address, qwiic) == LPS28DFW_OK;
441441
lps28dfw_md_t modeConfig =
442442
{
443-
.fs = LPS28DFW_1260hPa, // Full scale range
443+
.fs = (nodeSetting->mode == 2) ? LPS28DFW_4000hPa : LPS28DFW_1260hPa, // Full scale range
444444
.odr = LPS28DFW_ONE_SHOT, // Output data rate
445445
.avg = LPS28DFW_4_AVG, // Average filter
446446
.lpf = LPS28DFW_LPF_DISABLE // Low-pass filter

Firmware/OpenLog_Artemis/menuAttachedDevices.ino

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,10 @@ void menuConfigure_LPS28DFW(void *configPtr)
873873
SerialPrint(F("3) Log Temperature: "));
874874
if (sensorSetting->logTemperature == true) SerialPrintln(F("Enabled"));
875875
else SerialPrintln(F("Disabled"));
876+
877+
SerialPrint(F("4) Toggle Pressure Range: "));
878+
if (sensorSetting->mode == 1) SerialPrintln(F("Mode 1 (260 - 1260 hPa)"));
879+
else SerialPrintln(F("Mode 2 (260 - 4000 hPa)"));
876880
}
877881
SerialPrintln(F("x) Exit"));
878882

@@ -886,6 +890,13 @@ void menuConfigure_LPS28DFW(void *configPtr)
886890
sensorSetting->logPressure ^= 1;
887891
else if (incoming == '3')
888892
sensorSetting->logTemperature ^= 1;
893+
else if (incoming == '4') // <-- NEW: Mode toggle
894+
{
895+
if (sensorSetting->mode == 1)
896+
sensorSetting->mode = 2;
897+
else
898+
sensorSetting->mode = 1;
899+
}
889900
else if (incoming == 'x')
890901
break;
891902
else if (incoming == STATUS_GETBYTE_TIMEOUT)

Firmware/OpenLog_Artemis/nvm.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ void recordDeviceSettingsToFile()
622622
settingsFile.println((String)base + "log=" + nodeSetting->log);
623623
settingsFile.println((String)base + "logPressure=" + nodeSetting->logPressure);
624624
settingsFile.println((String)base + "logTemperature=" + nodeSetting->logTemperature);
625+
settingsFile.println((String)base + "mode=" + nodeSetting->mode);
625626
}
626627
break;
627628
case DEVICE_PHT_BME280:
@@ -1206,6 +1207,8 @@ bool parseDeviceLine(char* str) {
12061207
nodeSetting->logPressure = d;
12071208
else if (strcmp(deviceSettingName, "logTemperature") == 0)
12081209
nodeSetting->logTemperature = d;
1210+
else if (strcmp(deviceSettingName, "mode") == 0)
1211+
nodeSetting->mode = d;
12091212
else
12101213
SerialPrintf2("Unknown device setting: %s\r\n", deviceSettingName);
12111214
}

Firmware/OpenLog_Artemis/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct struct_LPS28DFW {
101101
bool log = true;
102102
bool logPressure = true;
103103
bool logTemperature = true;
104+
uint8_t mode = 1; //Allow selection of pressure mode 1 (260-1060 hPa) or mode 2 (260-4000 hPa)
104105
unsigned long powerOnDelayMillis = minimumQwiicPowerOnDelay; // Wait for at least this many millis before communicating with this device. Increase if required!
105106
};
106107

0 commit comments

Comments
 (0)