summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Lindenfelser <llindenfelser@multitech.com>2015-12-09 15:57:07 -0600
committerLeon Lindenfelser <llindenfelser@multitech.com>2015-12-09 15:57:07 -0600
commit96b7412369c44c3cc7608859c19161073cd114da (patch)
tree3ab007d9093f7ad2045f688760e37cfa00c87ccd
parent01988b37d50f8e5fefd2d21aea8102683c6917a1 (diff)
downloadmtdot-box-evb-factory-firmware-96b7412369c44c3cc7608859c19161073cd114da.tar.gz
mtdot-box-evb-factory-firmware-96b7412369c44c3cc7608859c19161073cd114da.tar.bz2
mtdot-box-evb-factory-firmware-96b7412369c44c3cc7608859c19161073cd114da.zip
Display sensor data on demo screen.
-rw-r--r--Layout/LayoutDemoSampling.cpp48
-rw-r--r--Layout/LayoutDemoSampling.h8
-rw-r--r--Mode/Mode.cpp3
-rw-r--r--Mode/Mode.h3
-rw-r--r--Mode/ModeDemo.cpp10
-rw-r--r--SensorHandler/SensorHandler.cpp2
6 files changed, 71 insertions, 3 deletions
diff --git a/Layout/LayoutDemoSampling.cpp b/Layout/LayoutDemoSampling.cpp
index c88acee..52c1493 100644
--- a/Layout/LayoutDemoSampling.cpp
+++ b/Layout/LayoutDemoSampling.cpp
@@ -80,3 +80,51 @@ void LayoutDemoSampling::updateInterval(uint32_t seconds) {
writeField(_fInfo, buf, size, true);
}
+void LayoutDemoSampling::updateAccelerationX(uint16_t x) {
+ char buf[16];
+ memset(buf, ' ', sizeof(buf));
+ snprintf(buf, sizeof(buf), "%d", x);
+ writeField(_fAccx, buf, true);
+}
+
+void LayoutDemoSampling::updateAccelerationY(uint16_t y) {
+ char buf[16];
+ memset(buf, ' ', sizeof(buf));
+ snprintf(buf, sizeof(buf), "%d", y);
+ writeField(_fAccy, buf, true);
+}
+
+void LayoutDemoSampling::updateAccelerationZ(uint16_t z) {
+ char buf[16];
+ memset(buf, ' ', sizeof(buf));
+ snprintf(buf, sizeof(buf), "%d", z);
+ writeField(_fAccz, buf, true);
+}
+
+void LayoutDemoSampling::updatePressure(float pressure) {
+ char buf[16];
+ memset(buf, ' ', sizeof(buf));
+ snprintf(buf, sizeof(buf), "%3.2f KPa", pressure/1000);
+ writeField(_fPres, buf, true);
+}
+
+void LayoutDemoSampling::updateAltitude(float altitude) {
+ char buf[16];
+ memset(buf, ' ', sizeof(buf));
+ snprintf(buf, sizeof(buf), "%5.2f m", altitude);
+ writeField(_fAlt, buf, true);
+}
+
+void LayoutDemoSampling::updateTemperature(float temperature) {
+ char buf[16];
+ memset(buf, ' ', sizeof(buf));
+ snprintf(buf, sizeof(buf), "%3.2f C", temperature);
+ writeField(_fTemp, buf, true);
+}
+
+void LayoutDemoSampling::updateLight(float light) {
+ char buf[16];
+ memset(buf, ' ', sizeof(buf));
+ snprintf(buf, sizeof(buf), "%4.2f lux", light);
+ writeField(_fLight, buf, true);
+}
diff --git a/Layout/LayoutDemoSampling.h b/Layout/LayoutDemoSampling.h
index 9d075b2..f3faceb 100644
--- a/Layout/LayoutDemoSampling.h
+++ b/Layout/LayoutDemoSampling.h
@@ -2,6 +2,7 @@
#define __LAYOUTDEMOSAMPLING_H__
#include "Layout.h"
+#include "MMA845x.h"
class LayoutDemoSampling : public Layout {
public:
@@ -14,6 +15,13 @@ class LayoutDemoSampling : public Layout {
void updateSw2(std::string sw2);
void updateCountdown(uint32_t seconds);
void updateInterval(uint32_t seconds);
+ void updateAccelerationX(uint16_t x);
+ void updateAccelerationY(uint16_t y);
+ void updateAccelerationZ(uint16_t z);
+ void updatePressure(float pressure);
+ void updateAltitude(float altitude);
+ void updateTemperature(float temperature);
+ void updateLight(float light);
private:
Label _lAccx;
diff --git a/Mode/Mode.cpp b/Mode/Mode.cpp
index a97b226..47dbc29 100644
--- a/Mode/Mode.cpp
+++ b/Mode/Mode.cpp
@@ -155,7 +155,7 @@ void Mode::updateData(DataItem& data, DataType type, bool status) {
data.power = _power;
}
-void Mode::updateSensors(SensorItem& data) {
+void Mode::updateSensorData(SensorItem& data) {
data.accel_data = _mdot_sensors.getAcceleration();
data.baro_data = _mdot_sensors.getBarometer();
data.lux_data_raw = _mdot_sensors.getLightRaw();
@@ -163,6 +163,7 @@ void Mode::updateSensors(SensorItem& data) {
data.light = _mdot_sensors.getLight();
data.pressure = _mdot_sensors.getPressure();
data.altitude = _mdot_sensors.getAltitude();
+ data.temperature = _mdot_sensors.getTemp(SensorHandler::CELSIUS);
}
uint32_t Mode::getIndex(DataType type) {
diff --git a/Mode/Mode.h b/Mode/Mode.h
index ca8433a..6b4e24f 100644
--- a/Mode/Mode.h
+++ b/Mode/Mode.h
@@ -42,6 +42,7 @@ class Mode {
float light;
float pressure;
float altitude;
+ float temperature;
} SensorItem;
Mode(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps);
@@ -53,7 +54,7 @@ class Mode {
bool deleteDataFile();
bool appendDataFile(const DataItem& data);
void updateData(DataItem& data, DataType type, bool status);
- void updateSensors(SensorItem& data);
+ void updateSensorData(SensorItem& data);
uint32_t getIndex(DataType type);
std::vector<uint8_t> formatSurveyData(DataItem& data);
diff --git a/Mode/ModeDemo.cpp b/Mode/ModeDemo.cpp
index e70ccbd..dcc06e6 100644
--- a/Mode/ModeDemo.cpp
+++ b/Mode/ModeDemo.cpp
@@ -138,6 +138,16 @@ bool ModeDemo::start() {
_lora->send(s_data);
osDelay(500);
}
+ if(_state != show_help){
+ updateSensorData(_data);
+ _sam.updateAccelerationX(_data.accel_data._x);
+ _sam.updateAccelerationY(_data.accel_data._y);
+ _sam.updateAccelerationZ(_data.accel_data._z);
+ _sam.updatePressure(_data.pressure);
+ _sam.updateAltitude(_data.altitude);
+ _sam.updateTemperature(_data.temperature);
+ _sam.updateLight(_data.light);
+ }
}
}
diff --git a/SensorHandler/SensorHandler.cpp b/SensorHandler/SensorHandler.cpp
index 89f7d2d..1b471b3 100644
--- a/SensorHandler/SensorHandler.cpp
+++ b/SensorHandler/SensorHandler.cpp
@@ -105,7 +105,7 @@ void SensorHandler::readSensors()
// Retrieve light level
_mutex.lock();
_light = _lightSensor.getData();
- _mutex.unlock();
+ _mutex.unlock();
}
}