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@24:6f7c34f9d0f8, 2019-05-29 (annotated)
- Committer:
- spadaaa
- Date:
- Wed May 29 07:11:21 2019 +0000
- Revision:
- 24:6f7c34f9d0f8
- Parent:
- 23:f45027ac625c
- Child:
- 25:a5e5b51d4c2a
avec commentaires
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 | 24:6f7c34f9d0f8 | 13 | |
spadaaa | 24:6f7c34f9d0f8 | 14 | //return the trend of the pressure (not a "value" but the enum) |
spadaaa | 24:6f7c34f9d0f8 | 15 | pressureTrendStates getPressureTrend( uint32_t newPressure); |
loicguibert | 11:dbc310addbf6 | 16 | |
loicguibert | 11:dbc310addbf6 | 17 | private: |
loicguibert | 11:dbc310addbf6 | 18 | |
loicguibert | 11:dbc310addbf6 | 19 | struct Data { |
loicguibert | 17:76787f5a334f | 20 | uint32_t pressure; |
loicguibert | 17:76787f5a334f | 21 | int16_t temp; |
loicguibert | 12:856286ad4cdc | 22 | uint16_t humidity; |
loicguibert | 12:856286ad4cdc | 23 | uint32_t time; |
loicguibert | 18:7002e66af2e5 | 24 | // Size: 96 bits, 12 Bytes |
loicguibert | 11:dbc310addbf6 | 25 | }; |
spadaaa | 23:f45027ac625c | 26 | // Enum for pressure trend |
spadaaa | 23:f45027ac625c | 27 | enum pressureTrendStates { |
spadaaa | 23:f45027ac625c | 28 | UNKNOWN = 0, |
spadaaa | 23:f45027ac625c | 29 | FALLING_CONTINUOUSLY = 1, |
spadaaa | 23:f45027ac625c | 30 | RISING_CONTINUOUSLY = 2, |
spadaaa | 23:f45027ac625c | 31 | FALLING_STEADY = 3, |
spadaaa | 23:f45027ac625c | 32 | RISING_STEADY = 4, |
spadaaa | 23:f45027ac625c | 33 | FALLING_LESSER_RISE = 5, |
spadaaa | 23:f45027ac625c | 34 | FALLING_GREATER_RISE = 6, |
spadaaa | 23:f45027ac625c | 35 | RISING_GREATER_RISE = 7, |
spadaaa | 23:f45027ac625c | 36 | RISING_LESSER_RISE = 8, |
spadaaa | 23:f45027ac625c | 37 | STEADY = 9 |
spadaaa | 23:f45027ac625c | 38 | }; |
loicguibert | 12:856286ad4cdc | 39 | // Counting the array's dimension according to max size |
loicguibert | 12:856286ad4cdc | 40 | static const int DEFAULT_SIZE = 2048; |
loicguibert | 12:856286ad4cdc | 41 | static const int ARRAY_SIZE = DEFAULT_SIZE/sizeof(Data); |
loicguibert | 12:856286ad4cdc | 42 | |
loicguibert | 11:dbc310addbf6 | 43 | // data members |
loicguibert | 12:856286ad4cdc | 44 | Data m_measures[ARRAY_SIZE]; |
loicguibert | 11:dbc310addbf6 | 45 | |
loicguibert | 17:76787f5a334f | 46 | int m_measurments; |
loicguibert | 16:eed9a9ba319c | 47 | |
loicguibert | 16:eed9a9ba319c | 48 | Logger m_logger; |
loicguibert | 17:76787f5a334f | 49 | }; |