Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MeasurementHistory.h@23:f45027ac625c, 2019-05-29 (annotated)
- Committer:
- spadaaa
- Date:
- Wed May 29 06:50:47 2019 +0000
- Revision:
- 23:f45027ac625c
- Parent:
- 18:7002e66af2e5
- Child:
- 24:6f7c34f9d0f8
Pressure trend changer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
loicguibert | 11:dbc310addbf6 | 1 | #pragma once |
loicguibert | 11:dbc310addbf6 | 2 | |
loicguibert | 11:dbc310addbf6 | 3 | #include <stdint.h> |
loicguibert | 16:eed9a9ba319c | 4 | #include "Logger.h" |
loicguibert | 11:dbc310addbf6 | 5 | |
loicguibert | 11:dbc310addbf6 | 6 | class MeasurementHistory { |
loicguibert | 11:dbc310addbf6 | 7 | public: |
loicguibert | 11:dbc310addbf6 | 8 | // constructor |
loicguibert | 16:eed9a9ba319c | 9 | MeasurementHistory(Logger logger); |
loicguibert | 11:dbc310addbf6 | 10 | |
loicguibert | 12:856286ad4cdc | 11 | // Add some new values to the history |
loicguibert | 17:76787f5a334f | 12 | void addMeasurement(uint32_t pressure, int16_t temp, uint16_t humidity, uint32_t time); |
spadaaa | 23:f45027ac625c | 13 | |
spadaaa | 23:f45027ac625c | 14 | uint8_t getPressureTrend( uint32_t newPressure); |
loicguibert | 11:dbc310addbf6 | 15 | |
loicguibert | 11:dbc310addbf6 | 16 | private: |
loicguibert | 11:dbc310addbf6 | 17 | |
loicguibert | 11:dbc310addbf6 | 18 | struct Data { |
loicguibert | 17:76787f5a334f | 19 | uint32_t pressure; |
loicguibert | 17:76787f5a334f | 20 | int16_t temp; |
loicguibert | 12:856286ad4cdc | 21 | uint16_t humidity; |
loicguibert | 12:856286ad4cdc | 22 | uint32_t time; |
loicguibert | 18:7002e66af2e5 | 23 | // Size: 96 bits, 12 Bytes |
loicguibert | 11:dbc310addbf6 | 24 | }; |
spadaaa | 23:f45027ac625c | 25 | // Enum for pressure trend |
spadaaa | 23:f45027ac625c | 26 | enum pressureTrendStates { |
spadaaa | 23:f45027ac625c | 27 | UNKNOWN = 0, |
spadaaa | 23:f45027ac625c | 28 | FALLING_CONTINUOUSLY = 1, |
spadaaa | 23:f45027ac625c | 29 | RISING_CONTINUOUSLY = 2, |
spadaaa | 23:f45027ac625c | 30 | FALLING_STEADY = 3, |
spadaaa | 23:f45027ac625c | 31 | RISING_STEADY = 4, |
spadaaa | 23:f45027ac625c | 32 | FALLING_LESSER_RISE = 5, |
spadaaa | 23:f45027ac625c | 33 | FALLING_GREATER_RISE = 6, |
spadaaa | 23:f45027ac625c | 34 | RISING_GREATER_RISE = 7, |
spadaaa | 23:f45027ac625c | 35 | RISING_LESSER_RISE = 8, |
spadaaa | 23:f45027ac625c | 36 | STEADY = 9 |
spadaaa | 23:f45027ac625c | 37 | }; |
loicguibert | 12:856286ad4cdc | 38 | // Counting the array's dimension according to max size |
loicguibert | 12:856286ad4cdc | 39 | static const int DEFAULT_SIZE = 2048; |
loicguibert | 12:856286ad4cdc | 40 | static const int ARRAY_SIZE = DEFAULT_SIZE/sizeof(Data); |
loicguibert | 12:856286ad4cdc | 41 | |
loicguibert | 11:dbc310addbf6 | 42 | // data members |
loicguibert | 12:856286ad4cdc | 43 | Data m_measures[ARRAY_SIZE]; |
loicguibert | 11:dbc310addbf6 | 44 | |
loicguibert | 17:76787f5a334f | 45 | int m_measurments; |
loicguibert | 16:eed9a9ba319c | 46 | |
loicguibert | 16:eed9a9ba319c | 47 | Logger m_logger; |
loicguibert | 17:76787f5a334f | 48 | }; |