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@12:856286ad4cdc, 2019-03-25 (annotated)
- Committer:
- loicguibert
- Date:
- Mon Mar 25 14:54:43 2019 +0000
- Revision:
- 12:856286ad4cdc
- Parent:
- 11:dbc310addbf6
- Child:
- 16:eed9a9ba319c
Advertising done
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 | 11:dbc310addbf6 | 4 | |
loicguibert | 11:dbc310addbf6 | 5 | class MeasurementHistory { |
loicguibert | 11:dbc310addbf6 | 6 | public: |
loicguibert | 11:dbc310addbf6 | 7 | // constructor |
loicguibert | 11:dbc310addbf6 | 8 | MeasurementHistory(); |
loicguibert | 11:dbc310addbf6 | 9 | |
loicguibert | 12:856286ad4cdc | 10 | // Add some new values to the history |
loicguibert | 12:856286ad4cdc | 11 | void addMeasurement(float temp, float pressure, float humidity, uint32_t time); |
loicguibert | 11:dbc310addbf6 | 12 | |
loicguibert | 11:dbc310addbf6 | 13 | private: |
loicguibert | 11:dbc310addbf6 | 14 | |
loicguibert | 11:dbc310addbf6 | 15 | struct Data { |
loicguibert | 12:856286ad4cdc | 16 | uint16_t temp; |
loicguibert | 12:856286ad4cdc | 17 | uint16_t pressure; |
loicguibert | 12:856286ad4cdc | 18 | uint16_t humidity; |
loicguibert | 12:856286ad4cdc | 19 | uint32_t time; |
loicguibert | 12:856286ad4cdc | 20 | // Size: 80 bits, 10 Bytes |
loicguibert | 11:dbc310addbf6 | 21 | }; |
loicguibert | 12:856286ad4cdc | 22 | |
loicguibert | 12:856286ad4cdc | 23 | // Counting the array's dimension according to max size |
loicguibert | 12:856286ad4cdc | 24 | static const int DEFAULT_SIZE = 2048; |
loicguibert | 12:856286ad4cdc | 25 | static const int ARRAY_SIZE = DEFAULT_SIZE/sizeof(Data); |
loicguibert | 12:856286ad4cdc | 26 | |
loicguibert | 11:dbc310addbf6 | 27 | // data members |
loicguibert | 12:856286ad4cdc | 28 | Data m_measures[ARRAY_SIZE]; |
loicguibert | 11:dbc310addbf6 | 29 | |
loicguibert | 11:dbc310addbf6 | 30 | int m_index; |
loicguibert | 11:dbc310addbf6 | 31 | }; |