fsdfds
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal by
MicroBitThermometer Class Reference
Class definition for MicroBit Thermometer. More...
#include <MicroBitThermometer.h>
Inherits MicroBitComponent.
Public Member Functions | |
MicroBitThermometer (MicroBitStorage &_storage, uint16_t id=MICROBIT_ID_THERMOMETER) | |
Constructor. | |
MicroBitThermometer (uint16_t id=MICROBIT_ID_THERMOMETER) | |
Constructor. | |
void | setPeriod (int period) |
Set the sample rate at which the temperatureis read (in ms). | |
int | getPeriod () |
Reads the currently configured sample rate of the thermometer. | |
int | setOffset (int offset) |
Set the value that is used to offset the raw silicon temperature. | |
int | getOffset () |
Retreive the value that is used to offset the raw silicon temperature. | |
int | setCalibration (int calibrationTemp) |
This member function fetches the raw silicon temperature, and calculates the value used to offset the raw silicon temperature based on a given temperature. | |
int | getTemperature () |
Gets the current temperature of the microbit. | |
int | updateSample () |
Updates the temperature sample of this instance of MicroBitThermometer only if isSampleNeeded() indicates that an update is required. | |
virtual void | idleTick () |
Periodic callback from MicroBit idle thread. | |
virtual void | systemTick () |
The system timer will call this member function once the component has been added to the array of system components using system_timer_add_component. |
Detailed Description
Class definition for MicroBit Thermometer.
Infers and stores the ambient temoperature based on the surface temperature of the various chips on the micro:bit.
Definition at line 53 of file MicroBitThermometer.h.
Constructor & Destructor Documentation
MicroBitThermometer | ( | MicroBitStorage & | _storage, |
uint16_t | id = MICROBIT_ID_THERMOMETER |
||
) |
Constructor.
Create new MicroBitThermometer that gives an indication of the current temperature.
- Parameters:
-
_storage an instance of MicroBitStorage used to persist temperature offset data id the unique EventModel id of this component. Defaults to MICROBIT_ID_THERMOMETER.
MicroBitStorage storage; MicroBitThermometer thermometer(storage);
Definition at line 66 of file MicroBitThermometer.cpp.
MicroBitThermometer | ( | uint16_t | id = MICROBIT_ID_THERMOMETER ) |
Constructor.
Create new MicroBitThermometer that gives an indication of the current temperature.
- Parameters:
-
id the unique EventModel id of this component. Defaults to MICROBIT_ID_THERMOMETER.
MicroBitThermometer thermometer;
Definition at line 93 of file MicroBitThermometer.cpp.
Member Function Documentation
int getOffset | ( | ) |
Retreive the value that is used to offset the raw silicon temperature.
- Returns:
- the current offset.
Definition at line 250 of file MicroBitThermometer.cpp.
int getPeriod | ( | ) |
Reads the currently configured sample rate of the thermometer.
- Returns:
- The time between samples, in milliseconds.
Definition at line 223 of file MicroBitThermometer.cpp.
int getTemperature | ( | ) |
Gets the current temperature of the microbit.
- Returns:
- the current temperature, in degrees celsius.
thermometer.getTemperature();
Definition at line 111 of file MicroBitThermometer.cpp.
void idleTick | ( | ) | [virtual] |
Periodic callback from MicroBit idle thread.
Reimplemented from MicroBitComponent.
Definition at line 187 of file MicroBitThermometer.cpp.
int setCalibration | ( | int | calibrationTemp ) |
This member function fetches the raw silicon temperature, and calculates the value used to offset the raw silicon temperature based on a given temperature.
- Parameters:
-
calibrationTemp the temperature used to calculate the raw silicon temperature offset.
- Returns:
- MICROBIT_OK on success
Definition at line 264 of file MicroBitThermometer.cpp.
int setOffset | ( | int | offset ) |
Set the value that is used to offset the raw silicon temperature.
- Parameters:
-
offset the offset for the silicon temperature
- Returns:
- MICROBIT_OK on success
Definition at line 235 of file MicroBitThermometer.cpp.
void setPeriod | ( | int | period ) |
Set the sample rate at which the temperatureis read (in ms).
The default sample period is 1 second.
- Parameters:
-
period the requested time between samples, in milliseconds.
- Note:
- the temperature is always read in the background, and is only updated when the processor is idle, or when the temperature is explicitly read.
Definition at line 212 of file MicroBitThermometer.cpp.
virtual void systemTick | ( | ) | [virtual, inherited] |
The system timer will call this member function once the component has been added to the array of system components using system_timer_add_component.
This callback will be in interrupt context.
Reimplemented in MicroBitSystemTimerCallback, MicroBitButton, and MicroBitDisplay.
Definition at line 125 of file MicroBitComponent.h.
int updateSample | ( | ) |
Updates the temperature sample of this instance of MicroBitThermometer only if isSampleNeeded() indicates that an update is required.
This call also will add the thermometer to fiber components to receive periodic callbacks.
- Returns:
- MICROBIT_OK on success.
Definition at line 127 of file MicroBitThermometer.cpp.
Generated on Wed Jul 13 2022 00:58:04 by 1.7.2