Skip to content

Commit

Permalink
rgb_driver
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonae committed Oct 6, 2023
1 parent d425d6f commit eee2af5
Show file tree
Hide file tree
Showing 10 changed files with 482 additions and 72 deletions.
182 changes: 151 additions & 31 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,155 @@
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

#Select the default buil here.
[platformio]
default_envs = NUCLEO-F103RB-co2-rgb

#RB: not all drivers will fit
[env:NUCLEO-F103RB]
platform = ststm32
board_build.core = maple ;source https://github.com/rogerclarkmelbourne/Arduino_STM32
board = genericSTM32F103RB
framework = arduino
build_flags =
-DSTM32
-fpermissive
-DUSE_HSI_CLOCK
-Os
-DPRODUCTION_FIRMWARE_BUILD
build_unflags = -O2
# -std=gnu++17
#build_unflags = -std=gnu++11
board_build.f_cpu = 64000000L
lib_deps =
; [email protected]:ZavenArra/ModularSensors.git#stm32f1
https://github.com/ZavenArra/ModularSensors.git#stm32f1
; https://github.com/deepwinter/Adafruit_BluefruitLE_nRF51.git
https://github.com/WaterBearSondes/DS3231.git
https://github.com/WaterBearSondes/atlas_OEM.git
https://github.com/greiman/SdFat.git#1.1.4
https://github.com/DaveGamble/cJSON.git
https://github.com/ZavenArra/CmdArduino.git
https://github.com/adafruit/DHT-sensor-library.git
https://github.com/adafruit/Adafruit_AHTX0.git
https://github.com/adafruit/Adafruit_BME280_Library.git
;adafruit/DHT sensor library
monitor_speed = 115200
debug_port = /dev/ttyACM0
check_tool = cppcheck
check_flags = --enable=all
platform = ststm32
board_build.core = maple ;source https://github.com/rogerclarkmelbourne/Arduino_STM32
board = genericSTM32F103RB
framework = arduino
build_flags =
-DSTM32
-fpermissive
-DUSE_HSI_CLOCK
-Os
-DPRODUCTION_FIRMWARE_BUILD
-DRRIV_ANALOG

build_unflags = -O2
# -std=gnu++17
#build_unflags = -std=gnu++11
board_build.f_cpu = 64000000L
lib_deps =
; [email protected]:ZavenArra/ModularSensors.git#stm32f1
https://github.com/ZavenArra/ModularSensors.git#stm32f1
; https://github.com/deepwinter/Adafruit_BluefruitLE_nRF51.git
https://github.com/WaterBearSondes/DS3231.git
https://github.com/WaterBearSondes/atlas_OEM.git
https://github.com/greiman/SdFat.git#1.1.4
https://github.com/DaveGamble/cJSON.git
https://github.com/ZavenArra/CmdArduino.git
https://github.com/adafruit/DHT-sensor-library.git
https://github.com/adafruit/Adafruit_AHTX0.git
https://github.com/adafruit/Adafruit_BME280_Library.git
;adafruit/DHT sensor library
monitor_speed = 115200
debug_port = /dev/ttyACM0
check_tool = cppcheck
check_flags = --enable=all
#RB: ch4 & dht
[env:NUCLEO-F103RB-ch4-dht]
platform = ststm32
board_build.core = maple ;source https://github.com/rogerclarkmelbourne/Arduino_STM32
board = genericSTM32F103RB
framework = arduino
build_flags =
-DSTM32
-fpermissive
-DUSE_HSI_CLOCK
-Os
-DPRODUCTION_FIRMWARE_BUILD
-DRRIV_ANALOG
-DRRIV_DHT22

build_unflags = -O2
# -std=gnu++17
#build_unflags = -std=gnu++11
board_build.f_cpu = 64000000L
lib_deps =
; [email protected]:ZavenArra/ModularSensors.git#stm32f1
https://github.com/ZavenArra/ModularSensors.git#stm32f1
; https://github.com/deepwinter/Adafruit_BluefruitLE_nRF51.git
https://github.com/WaterBearSondes/DS3231.git
https://github.com/WaterBearSondes/atlas_OEM.git
https://github.com/greiman/SdFat.git#1.1.4
https://github.com/DaveGamble/cJSON.git
https://github.com/ZavenArra/CmdArduino.git
https://github.com/adafruit/DHT-sensor-library.git
https://github.com/adafruit/Adafruit_AHTX0.git
https://github.com/adafruit/Adafruit_BME280_Library.git
;adafruit/DHT sensor library
monitor_speed = 115200
debug_port = /dev/ttyACM0
check_tool = cppcheck
check_flags = --enable=all
#RB: co2 & rgb
[env:NUCLEO-F103RB-co2-rgb]
platform = ststm32
board_build.core = maple ;source https://github.com/rogerclarkmelbourne/Arduino_STM32
board = genericSTM32F103RB
framework = arduino
build_flags =
-DSTM32
-fpermissive
-DUSE_HSI_CLOCK
-Os
-DPRODUCTION_FIRMWARE_BUILD
-DRRIV_CO2
-DRRIV_RGB
-DCONT_PWR

build_unflags = -O2
# -std=gnu++17
#build_unflags = -std=gnu++11
board_build.f_cpu = 64000000L
lib_deps =
; [email protected]:ZavenArra/ModularSensors.git#stm32f1
https://github.com/ZavenArra/ModularSensors.git#stm32f1
; https://github.com/deepwinter/Adafruit_BluefruitLE_nRF51.git
https://github.com/WaterBearSondes/DS3231.git
https://github.com/WaterBearSondes/atlas_OEM.git
https://github.com/greiman/SdFat.git#1.1.4
https://github.com/DaveGamble/cJSON.git
https://github.com/ZavenArra/CmdArduino.git
https://github.com/adafruit/DHT-sensor-library.git
https://github.com/adafruit/Adafruit_AHTX0.git
https://github.com/adafruit/Adafruit_BME280_Library.git
;adafruit/DHT sensor library
monitor_speed = 115200
debug_port = /dev/ttyACM0
check_tool = cppcheck
check_flags = --enable=all

#RE: more space
[env:NUCLEO-F103RE]
platform = ststm32
board_build.core = maple ;source https://github.com/rogerclarkmelbourne/Arduino_STM32
board = genericSTM32F103RE
framework = arduino
build_flags =
-DSTM32
-fpermissive
-DUSE_HSI_CLOCK
-Os
-DPRODUCTION_FIRMWARE_BUILD
-DRRIV_ANALOG
-DRRIV_ATLAS_EC
-DRRIV_DHT22
-DRRIV_CO2
-DRRIV_RGB
-DRRIV_AHT
build_unflags = -O2
# -std=gnu++17
#build_unflags = -std=gnu++11
board_build.f_cpu = 64000000L
lib_deps =
; [email protected]:ZavenArra/ModularSensors.git#stm32f1
https://github.com/ZavenArra/ModularSensors.git#stm32f1
; https://github.com/deepwinter/Adafruit_BluefruitLE_nRF51.git
https://github.com/WaterBearSondes/DS3231.git
https://github.com/WaterBearSondes/atlas_OEM.git
https://github.com/greiman/SdFat.git#1.1.4
https://github.com/DaveGamble/cJSON.git
https://github.com/ZavenArra/CmdArduino.git
https://github.com/adafruit/DHT-sensor-library.git
https://github.com/adafruit/Adafruit_AHTX0.git
https://github.com/adafruit/Adafruit_BME280_Library.git
;adafruit/DHT sensor library
monitor_speed = 115200
debug_port = /dev/ttyACM0
check_tool = cppcheck
check_flags = --enable=all
34 changes: 21 additions & 13 deletions src/datalogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
// #include "sensors/drivers/air_pump.h"
// #include "sensors/drivers/generic_actuator.h"



void Datalogger::sleepMCU(uint32 milliseconds)
{
if(milliseconds < 5)
Expand Down Expand Up @@ -131,6 +133,9 @@ Datalogger::Datalogger(datalogger_settings_type *settings)

void Datalogger::setup()
{
#ifdef CONT_PWR
debug("continuous power ON");
#endif
startCustomWatchDog();

setupHardwarePins();
Expand Down Expand Up @@ -231,6 +236,7 @@ void Datalogger::testMeasurementCycle()

void Datalogger::loop()
{

if (inMode(deploy_on_trigger))
{
deploy(); // if deploy returns false here, the trigger setup has a fatal coding defect not detecting invalid conditions for deployment
Expand Down Expand Up @@ -270,11 +276,10 @@ void Datalogger::loop()
return;
}

// otherwise go to sleep
fileSystemWriteCache->flushCache();

//AE actuator hook could go here: is this before or after measurement?


SLEEP:
stopAndAwaitTrigger();
initializeMeasurementCycle();
Expand All @@ -288,7 +293,13 @@ void Datalogger::loop()
if (inMode(logging) || inMode(deploy_on_trigger))
{
// processCLI may have moved logger into a deployed mode
goto SLEEP;
#ifdef CONT_PWR
debug("skip sleep");
#endif
#ifndef CONT_PWR
debug("to sleep");
goto SLEEP;
#endif
}
else if (inMode(interactive))
{
Expand Down Expand Up @@ -473,8 +484,6 @@ void Datalogger::initializeBurst()

void Datalogger::initializeMeasurementCycle()
{
//AE actuate hook before measurement could go here

// notify(F("setting base time"));
currentEpoch = timestamp();
offsetMillis = millis();
Expand Down Expand Up @@ -503,7 +512,7 @@ void Datalogger::initializeMeasurementCycle()
sensorsWarmedUp = true;
for (unsigned short i = 0; i < sensorCount; i++)
{
// notify("check isWarmed");
notify("check isWarmed");
if (!drivers[i]->isWarmedUp())
{
// TODO: enhancement, ask the sensor driver if we should sleep MCU for a while
Expand All @@ -512,7 +521,6 @@ void Datalogger::initializeMeasurementCycle()
}
}
}
//AE actuator call could go here


}
Expand Down Expand Up @@ -687,15 +695,15 @@ void Datalogger::setConfiguration(cJSON *config)
notify("Invalid site name");
}

const cJSON* loggerNameJSON = cJSON_GetObjectItemCaseSensitive(config, "loggerName");
const cJSON* loggerNameJSON = cJSON_GetObjectItemCaseSensitive(config, "logger_name");
if(loggerNameJSON != NULL && cJSON_IsString(loggerNameJSON) && strlen(loggerNameJSON->valuestring) <= 7)
{
strcpy(settings.loggerName, loggerNameJSON->valuestring);
} else {
notify("Invalid logger name");
}

const cJSON* deploymentIdentifierJSON = cJSON_GetObjectItemCaseSensitive(config, "deploymentIdentifier");
const cJSON* deploymentIdentifierJSON = cJSON_GetObjectItemCaseSensitive(config, "deployment_identifier");
if(deploymentIdentifierJSON != NULL && cJSON_IsString(deploymentIdentifierJSON) && strlen(deploymentIdentifierJSON->valuestring) <= 15)
{
strcpy(settings.deploymentIdentifier, deploymentIdentifierJSON->valuestring);
Expand All @@ -711,28 +719,28 @@ void Datalogger::setConfiguration(cJSON *config)
notify("Invalid interval");
}

const cJSON * burstNumberJson = cJSON_GetObjectItemCaseSensitive(config, "burstNumber");
const cJSON * burstNumberJson = cJSON_GetObjectItemCaseSensitive(config, "burst_number");
if(burstNumberJson != NULL && cJSON_IsNumber(burstNumberJson) && burstNumberJson->valueint > 0)
{
settings.burstNumber = (byte) burstNumberJson->valueint;
} else {
notify("Invalid burst number");
}

const cJSON * startUpDelayJson = cJSON_GetObjectItemCaseSensitive(config, "startUpDelay");
const cJSON * startUpDelayJson = cJSON_GetObjectItemCaseSensitive(config, "start_up_delay");
if(startUpDelayJson != NULL && cJSON_IsNumber(startUpDelayJson) && startUpDelayJson->valueint >= 0)
{
settings.startUpDelay = (byte) startUpDelayJson->valueint;
} else {
notify("Invalid start up delay");
}

const cJSON * interBurstDelayJson = cJSON_GetObjectItemCaseSensitive(config, "interBurstDelay");
const cJSON * interBurstDelayJson = cJSON_GetObjectItemCaseSensitive(config, "burst_delay");
if(interBurstDelayJson != NULL && cJSON_IsNumber(interBurstDelayJson) && interBurstDelayJson->valueint >= 0)
{
settings.interBurstDelay = (byte) interBurstDelayJson->valueint;
} else {
notify("Invalid inter burst delay");
notify("Invalid burst delay");
}

storeDataloggerConfiguration();
Expand Down
2 changes: 1 addition & 1 deletion src/sensors/drivers/BME280_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool BME280Driver::takeMeasurement()
measurementTaken = true;
// if(measurementTaken)
// {
// addValueToBurstSummaryMean("temperature", temperature);
// addValueToBurstSummaryMean("temperature", temperature);
// addValueToBurstSummaryMean("pressure", pressure);
// }

Expand Down
16 changes: 5 additions & 11 deletions src/sensors/drivers/atlas_co2_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "system/logs.h" // for debug() and notify()

#define CO2_TAG "co2"
#define TEMP_TAG "temp"

AtlasCO2Driver::AtlasCO2Driver()
{
Expand Down Expand Up @@ -77,14 +78,14 @@ bool AtlasCO2Driver::takeMeasurement()
bool measurementTaken = modularSensorDriver->addSingleMeasurementResult();
if(measurementTaken)
{
value = modularSensorDriver->sensorValues[0];
co2 = modularSensorDriver->sensorValues[0];
modularSensorDriver->clearValues();
measurementTaken = true;
addValueToBurstSummaryMean(CO2_TAG, value);
addValueToBurstSummaryMean(CO2_TAG, co2);
}
else
{
value = -1;
co2 = -1;
}


Expand All @@ -93,7 +94,7 @@ bool AtlasCO2Driver::takeMeasurement()

const char * AtlasCO2Driver::getRawDataString()
{
sprintf(dataString, "%d", value);
sprintf(dataString, "%d", co2);
return dataString;
}

Expand All @@ -102,13 +103,6 @@ const char * AtlasCO2Driver::getSummaryDataString()
sprintf(dataString, "%0.2f", getBurstSummaryMean(CO2_TAG));
return dataString;
}
// const char *AtlasCO2Driver::getRawDataString()
// {
// // debug("configuring driver template dataString");
// // process data string for .csv
// sprintf(dataString, "%d,%d",value,0);
// return dataString;
// }

const char *AtlasCO2Driver::getBaseColumnHeaders()
{
Expand Down
4 changes: 2 additions & 2 deletions src/sensors/drivers/atlas_co2_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class AtlasCO2Driver : public I2CProtocolSensorDriver

/*value(s) to be placed in dataString, should correspond to number of
column headers and entries in dataString*/
int value; // sensor raw return(s) to be added to dataString
const char *baseColumnHeaders = "CO2_ppm,temperature_C"; // will be written to .csv
int co2; // sensor raw return(s) to be added to dataString
const char *baseColumnHeaders = "CO2_ppm"; // will be written to .csv
char dataString[30]; // will be written to .csv

void addCalibrationParametersToJSON(cJSON *json);
Expand Down
Loading

0 comments on commit eee2af5

Please sign in to comment.