Embedded Artistry C Interfaces
A reference collection of abstract interfaces in C.
Classes | Typedefs
humidity_sensor.h File Reference

Example relative humidity interface. More...

#include <stdbool.h>
#include <stdint.h>
Include dependency graph for humidity_sensor.h:

Go to the source code of this file.

Classes

struct  HumiditySensor
 Virtual Relative Humidity Sensor Interface. More...
 
struct  HumiditySensor_withCb
 Virtual Relative Humidity Sensor Interface with Callback Support. More...
 

Typedefs

typedef void(* NewHumiditySampleCb) (uint8_t humidity)
 Callback function prototype for processing new humidity samples. More...
 
typedef void(* HumidityErrorCb) (void)
 Callback function prototype for humidity sensor errors. More...
 

Detailed Description

Example relative humidity interface.

This header defines the core interfaces for a virtual humdity. Two samples are provided:

  1. A basic interface for reading humidity (HumiditySensor)
  2. An interface expanded with support for callbacks (HumiditySensor_withCb)

Modifying the Interfaces

There are a number of ways you might modify this interface to suit your needs:

Possible Humidity Specifications

For data format, we can consider a few options:

Definition in file humidity_sensor.h.

Typedef Documentation

◆ HumidityErrorCb

typedef void(* HumidityErrorCb) (void)

Callback function prototype for humidity sensor errors.

When an error in the virtual humidity device occurs, this callback function will be invoked. The virtual device itself does not support error handling capabilities, so we recommend using this callback in tightly-coupled system code to take the appropriate recovery action (restart the device, restart the system, etc.).

The callback is not guaranteed to run on its own thread of control. We recommend keeping the implementation small. Your function implementation could take the new sample and perform some dispatching operation (e.g., add the value to a queue), ensuring that any "heavy" processing happens on a new thread.

Definition at line 111 of file humidity_sensor.h.

◆ NewHumiditySampleCb

typedef void(* NewHumiditySampleCb) (uint8_t humidity)

Callback function prototype for processing new humidity samples.

When a new (and valid) humidity sample is available, this callback function will be invoked.

The callback is not guaranteed to run on its own thread of control. We recommend keeping the implementation small. Your function implementation could take the new sample and perform some dispatching operation (e.g., add the value to a queue), ensuring that any "heavy" processing happens on a new thread.

Parameters
[in]humidityThe latest humidity sample. Humidity is specified as an integral perecentage.

Definition at line 96 of file humidity_sensor.h.