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@18:7002e66af2e5, 2019-04-17 (annotated)
- Committer:
- loicguibert
- Date:
- Wed Apr 17 11:29:46 2019 +0000
- Revision:
- 18:7002e66af2e5
- Parent:
- 17:76787f5a334f
- Child:
- 23:f45027ac625c
Pressure Average done, enums to fix
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); |
loicguibert | 16:eed9a9ba319c | 13 | |
loicguibert | 16:eed9a9ba319c | 14 | uint32_t getPressureTrend(); |
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 | }; |
loicguibert | 12:856286ad4cdc | 25 | |
loicguibert | 12:856286ad4cdc | 26 | // Counting the array's dimension according to max size |
loicguibert | 12:856286ad4cdc | 27 | static const int DEFAULT_SIZE = 2048; |
loicguibert | 12:856286ad4cdc | 28 | static const int ARRAY_SIZE = DEFAULT_SIZE/sizeof(Data); |
loicguibert | 12:856286ad4cdc | 29 | |
loicguibert | 11:dbc310addbf6 | 30 | // data members |
loicguibert | 12:856286ad4cdc | 31 | Data m_measures[ARRAY_SIZE]; |
loicguibert | 11:dbc310addbf6 | 32 | |
loicguibert | 17:76787f5a334f | 33 | int m_measurments; |
loicguibert | 16:eed9a9ba319c | 34 | |
loicguibert | 16:eed9a9ba319c | 35 | Logger m_logger; |
loicguibert | 17:76787f5a334f | 36 | }; |