|
| 1 | +/** |
| 2 | + * @file SensorPresets.h |
| 3 | + * @brief Predefined display formats for common maker/STEM sensor types. |
| 4 | + * |
| 5 | + * Maps physical quantities (temperature, pressure, weight, light, etc.) |
| 6 | + * to their display representation: unit, decimal places, and icon. |
| 7 | + * |
| 8 | + * When adding a new sensor driver, just pick the matching preset: |
| 9 | + * SensorValueFormat fmt = SensorPresets::TEMPERATURE_CELSIUS; |
| 10 | + * |
| 11 | + * Covers the most common units in DIY automation, environmental monitoring, |
| 12 | + * agriculture, laboratory, industrial sensing, and energy metering. |
| 13 | + * |
| 14 | + * @project SIMUT — Integrated Universal Monitoring and Telemetry System |
| 15 | + * @target Raspberry Pi Pico W (RP2040) — Arduino Framework |
| 16 | + * @license MIT License |
| 17 | + */ |
| 18 | + |
| 19 | +#pragma once |
| 20 | + |
| 21 | +#include "SensorHelpers.h" /* SensorValueFormat definition */ |
| 22 | + |
| 23 | +namespace SensorPresets { |
| 24 | + |
| 25 | +/* =========================================================================== |
| 26 | + * TEMPERATURE |
| 27 | + * =========================================================================== */ |
| 28 | +constexpr SensorValueFormat TEMPERATURE_CELSIUS = {"°C", 1, "thermometer"}; |
| 29 | +constexpr SensorValueFormat TEMPERATURE_FAHRENHEIT = {"°F", 1, "thermometer"}; |
| 30 | +constexpr SensorValueFormat TEMPERATURE_KELVIN = {"K", 1, "thermometer"}; |
| 31 | + |
| 32 | +/* =========================================================================== |
| 33 | + * HUMIDITY / MOISTURE |
| 34 | + * =========================================================================== */ |
| 35 | +constexpr SensorValueFormat HUMIDITY_PERCENT = {"%", 0, "drop"}; |
| 36 | +constexpr SensorValueFormat HUMIDITY_ABSOLUTE = {"g/m³", 1, "drop"}; |
| 37 | +constexpr SensorValueFormat DEW_POINT_CELSIUS = {"°C", 1, "dewpoint"}; |
| 38 | + |
| 39 | +/* =========================================================================== |
| 40 | + * ATMOSPHERIC / GAS PRESSURE |
| 41 | + * =========================================================================== */ |
| 42 | +constexpr SensorValueFormat PRESSURE_HPA = {"hPa", 1, "gauge"}; |
| 43 | +constexpr SensorValueFormat PRESSURE_KPA = {"kPa", 2, "gauge"}; |
| 44 | +constexpr SensorValueFormat PRESSURE_PASCAL = {"Pa", 0, "gauge"}; |
| 45 | +constexpr SensorValueFormat PRESSURE_BAR = {"bar", 3, "gauge"}; |
| 46 | +constexpr SensorValueFormat PRESSURE_PSI = {"psi", 2, "gauge"}; |
| 47 | +constexpr SensorValueFormat PRESSURE_MMHG = {"mmHg", 1, "gauge"}; |
| 48 | +constexpr SensorValueFormat PRESSURE_ATM = {"atm", 3, "gauge"}; |
| 49 | + |
| 50 | +/* =========================================================================== |
| 51 | + * MASS / WEIGHT |
| 52 | + * =========================================================================== */ |
| 53 | +constexpr SensorValueFormat WEIGHT_KILOGRAM = {"kg", 3, "scale"}; |
| 54 | +constexpr SensorValueFormat WEIGHT_GRAM = {"g", 1, "scale"}; |
| 55 | +constexpr SensorValueFormat WEIGHT_MILLIGRAM = {"mg", 1, "scale"}; |
| 56 | +constexpr SensorValueFormat WEIGHT_POUND = {"lb", 2, "scale"}; |
| 57 | +constexpr SensorValueFormat WEIGHT_OUNCE = {"oz", 2, "scale"}; |
| 58 | + |
| 59 | +/* =========================================================================== |
| 60 | + * FORCE / TORQUE |
| 61 | + * =========================================================================== */ |
| 62 | +constexpr SensorValueFormat FORCE_NEWTON = {"N", 2, "scale"}; |
| 63 | +constexpr SensorValueFormat FORCE_KGF = {"kgf", 2, "scale"}; |
| 64 | +constexpr SensorValueFormat TORQUE_NM = {"N·m", 2, "wrench"}; |
| 65 | + |
| 66 | +/* =========================================================================== |
| 67 | + * LIGHT / ILLUMINANCE |
| 68 | + * =========================================================================== */ |
| 69 | +constexpr SensorValueFormat LIGHT_LUX = {"lx", 0, "bulb"}; |
| 70 | +constexpr SensorValueFormat LIGHT_KLUX = {"klx", 1, "bulb"}; |
| 71 | +constexpr SensorValueFormat LIGHT_PAR = {"µmol/m²/s", 0, "bulb"}; |
| 72 | +constexpr SensorValueFormat LIGHT_WATTS_PER_M2 = {"W/m²", 1, "bulb"}; |
| 73 | +constexpr SensorValueFormat LIGHT_UV_INDEX = {"UVI", 1, "bulb"}; |
| 74 | + |
| 75 | +/* =========================================================================== |
| 76 | + * DISTANCE / LENGTH |
| 77 | + * =========================================================================== */ |
| 78 | +constexpr SensorValueFormat DISTANCE_METER = {"m", 3, "ruler"}; |
| 79 | +constexpr SensorValueFormat DISTANCE_CENTIMETER = {"cm", 1, "ruler"}; |
| 80 | +constexpr SensorValueFormat DISTANCE_MILLIMETER = {"mm", 1, "ruler"}; |
| 81 | +constexpr SensorValueFormat DISTANCE_INCH = {"in", 2, "ruler"}; |
| 82 | + |
| 83 | +/* =========================================================================== |
| 84 | + * LIQUID / FLUID LEVEL |
| 85 | + * =========================================================================== */ |
| 86 | +constexpr SensorValueFormat LEVEL_PERCENT = {"%", 0, "vial"}; |
| 87 | +constexpr SensorValueFormat LEVEL_CENTIMETER = {"cm", 1, "vial"}; |
| 88 | +constexpr SensorValueFormat LEVEL_MILLIMETER = {"mm", 1, "vial"}; |
| 89 | + |
| 90 | +/* =========================================================================== |
| 91 | + * CHEMICAL — pH / ORP / CONDUCTIVITY / TDS / SALINITY |
| 92 | + * =========================================================================== */ |
| 93 | +constexpr SensorValueFormat CHEM_PH = {"pH", 2, "vial"}; |
| 94 | +constexpr SensorValueFormat CHEM_ORP_MV = {"mV", 0, "vial"}; |
| 95 | +constexpr SensorValueFormat CHEM_EC_US_CM = {"µS/cm", 0, "vial"}; |
| 96 | +constexpr SensorValueFormat CHEM_EC_MS_CM = {"mS/cm", 2, "vial"}; |
| 97 | +constexpr SensorValueFormat CHEM_TDS_PPM = {"ppm", 0, "vial"}; |
| 98 | +constexpr SensorValueFormat CHEM_SALINITY_PPT = {"ppt", 1, "vial"}; |
| 99 | +constexpr SensorValueFormat CHEM_SALINITY_PSU = {"PSU", 1, "vial"}; |
| 100 | + |
| 101 | +/* =========================================================================== |
| 102 | + * DISSOLVED GAS — O2 / CO2 / O3 / NH3 |
| 103 | + * =========================================================================== */ |
| 104 | +constexpr SensorValueFormat GAS_DO_MG_L = {"mg/L", 2, "bubbles"}; |
| 105 | +constexpr SensorValueFormat GAS_DO_PERCENT = {"%", 1, "bubbles"}; |
| 106 | +constexpr SensorValueFormat GAS_CO2_PPM = {"ppm", 0, "co2"}; |
| 107 | +constexpr SensorValueFormat GAS_O3_PPB = {"ppb", 0, "cloud"}; |
| 108 | +constexpr SensorValueFormat GAS_NH3_PPM = {"ppm", 1, "cloud"}; |
| 109 | +constexpr SensorValueFormat GAS_CO_PPM = {"ppm", 1, "cloud"}; |
| 110 | + |
| 111 | +/* =========================================================================== |
| 112 | + * PARTICULATE MATTER — PM1.0 / PM2.5 / PM10 |
| 113 | + * =========================================================================== */ |
| 114 | +constexpr SensorValueFormat DUST_PM1_UG_M3 = {"µg/m³", 1, "dust"}; |
| 115 | +constexpr SensorValueFormat DUST_PM25_UG_M3 = {"µg/m³", 1, "dust"}; |
| 116 | +constexpr SensorValueFormat DUST_PM10_UG_M3 = {"µg/m³", 1, "dust"}; |
| 117 | + |
| 118 | +/* =========================================================================== |
| 119 | + * VOLATILE ORGANIC COMPOUNDS (VOC) / AIR QUALITY INDEX |
| 120 | + * =========================================================================== */ |
| 121 | +constexpr SensorValueFormat VOC_PPB = {"ppb", 0, "cloud"}; |
| 122 | +constexpr SensorValueFormat VOC_UG_M3 = {"µg/m³", 1, "cloud"}; |
| 123 | +constexpr SensorValueFormat AIR_QUALITY_INDEX = {"AQI", 0, "cloud"}; |
| 124 | +constexpr SensorValueFormat AIR_QUALITY_IAQ = {"IAQ", 1, "cloud"}; |
| 125 | + |
| 126 | +/* =========================================================================== |
| 127 | + * VOLTAGE |
| 128 | + * =========================================================================== */ |
| 129 | +constexpr SensorValueFormat VOLTAGE_VOLT = {"V", 2, "bolt"}; |
| 130 | +constexpr SensorValueFormat VOLTAGE_MILLIVOLT = {"mV", 0, "bolt"}; |
| 131 | +constexpr SensorValueFormat VOLTAGE_MICROVOLT = {"µV", 0, "bolt"}; |
| 132 | + |
| 133 | +/* =========================================================================== |
| 134 | + * CURRENT |
| 135 | + * =========================================================================== */ |
| 136 | +constexpr SensorValueFormat CURRENT_AMPERE = {"A", 3, "bolt"}; |
| 137 | +constexpr SensorValueFormat CURRENT_MILLIAMPERE = {"mA", 1, "bolt"}; |
| 138 | +constexpr SensorValueFormat CURRENT_MICROAMPERE = {"µA", 0, "bolt"}; |
| 139 | + |
| 140 | +/* =========================================================================== |
| 141 | + * POWER |
| 142 | + * =========================================================================== */ |
| 143 | +constexpr SensorValueFormat POWER_WATT = {"W", 2, "bolt"}; |
| 144 | +constexpr SensorValueFormat POWER_KILOWATT = {"kW", 3, "bolt"}; |
| 145 | +constexpr SensorValueFormat POWER_MILLIWATT = {"mW", 1, "bolt"}; |
| 146 | + |
| 147 | +/* =========================================================================== |
| 148 | + * ENERGY (accumulated) |
| 149 | + * =========================================================================== */ |
| 150 | +constexpr SensorValueFormat ENERGY_WATTHOUR = {"Wh", 0, "meter"}; |
| 151 | +constexpr SensorValueFormat ENERGY_KILOWATTHOUR = {"kWh", 2, "meter"}; |
| 152 | +constexpr SensorValueFormat ENERGY_JOULE = {"J", 1, "meter"}; |
| 153 | + |
| 154 | +/* =========================================================================== |
| 155 | + * FREQUENCY / ROTATION |
| 156 | + * =========================================================================== */ |
| 157 | +constexpr SensorValueFormat FREQUENCY_HZ = {"Hz", 1, "pulse"}; |
| 158 | +constexpr SensorValueFormat FREQUENCY_KHZ = {"kHz", 2, "pulse"}; |
| 159 | +constexpr SensorValueFormat FREQUENCY_RPM = {"RPM", 0, "pulse"}; |
| 160 | + |
| 161 | +/* =========================================================================== |
| 162 | + * FLOW RATE |
| 163 | + * =========================================================================== */ |
| 164 | +constexpr SensorValueFormat FLOW_LITRE_PER_MIN = {"L/min", 2, "pipe" }; |
| 165 | +constexpr SensorValueFormat FLOW_LITRE_PER_HOUR = {"L/h", 1, "pipe"}; |
| 166 | +constexpr SensorValueFormat FLOW_M3_PER_HOUR = {"m³/h", 2, "pipe"}; |
| 167 | +constexpr SensorValueFormat FLOW_GALLON_PER_MIN = {"GPM", 2, "pipe"}; |
| 168 | + |
| 169 | +/* =========================================================================== |
| 170 | + * VOLUME (accumulated) |
| 171 | + * =========================================================================== */ |
| 172 | +constexpr SensorValueFormat VOLUME_LITRE = {"L", 1, "pipe"}; |
| 173 | +constexpr SensorValueFormat VOLUME_MILLILITRE = {"mL", 1, "pipe"}; |
| 174 | +constexpr SensorValueFormat VOLUME_CUBIC_METER = {"m³", 3, "pipe"}; |
| 175 | +constexpr SensorValueFormat VOLUME_GALLON = {"gal", 2, "pipe"}; |
| 176 | + |
| 177 | +/* =========================================================================== |
| 178 | + * SPEED / VELOCITY |
| 179 | + * =========================================================================== */ |
| 180 | +constexpr SensorValueFormat SPEED_M_PER_S = {"m/s", 1, "gauge"}; |
| 181 | +constexpr SensorValueFormat SPEED_KM_PER_H = {"km/h", 1, "gauge"}; |
| 182 | +constexpr SensorValueFormat SPEED_MPH = {"mph", 1, "gauge"}; |
| 183 | + |
| 184 | +/* =========================================================================== |
| 185 | + * SOUND |
| 186 | + * =========================================================================== */ |
| 187 | +constexpr SensorValueFormat SOUND_DB = {"dB", 1, "speaker"}; |
| 188 | +constexpr SensorValueFormat SOUND_DBA = {"dBA", 1, "speaker"}; |
| 189 | + |
| 190 | +/* =========================================================================== |
| 191 | + * ANGLE / INCLINATION |
| 192 | + * =========================================================================== */ |
| 193 | +constexpr SensorValueFormat ANGLE_DEGREE = {"°", 1, "compass"}; |
| 194 | +constexpr SensorValueFormat ANGLE_RADIAN = {"rad", 3, "compass"}; |
| 195 | +constexpr SensorValueFormat INCLINATION_PERCENT = {"%", 1, "compass"}; |
| 196 | + |
| 197 | +/* =========================================================================== |
| 198 | + * SOIL |
| 199 | + * =========================================================================== */ |
| 200 | +constexpr SensorValueFormat SOIL_MOISTURE_PERCENT = {"%", 0, "drop"}; |
| 201 | +constexpr SensorValueFormat SOIL_MOISTURE_CBAR = {"cbar", 0, "drop"}; |
| 202 | +constexpr SensorValueFormat SOIL_TEMPERATURE = {"°C", 1, "thermometer"}; |
| 203 | + |
| 204 | +/* =========================================================================== |
| 205 | + * RAINFALL |
| 206 | + * =========================================================================== */ |
| 207 | +constexpr SensorValueFormat RAIN_MM = {"mm", 1, "drop"}; |
| 208 | +constexpr SensorValueFormat RAIN_MM_PER_HOUR = {"mm/h", 1, "drop"}; |
| 209 | + |
| 210 | +/* =========================================================================== |
| 211 | + * WIND |
| 212 | + * =========================================================================== */ |
| 213 | +constexpr SensorValueFormat WIND_SPEED_M_S = {"m/s", 1, "flag"}; |
| 214 | +constexpr SensorValueFormat WIND_SPEED_KM_H = {"km/h", 1, "flag"}; |
| 215 | +constexpr SensorValueFormat WIND_DIRECTION_DEG = {"°", 0, "compass"}; |
| 216 | + |
| 217 | +/* =========================================================================== |
| 218 | + * RADIATION |
| 219 | + * =========================================================================== */ |
| 220 | +constexpr SensorValueFormat RADIATION_USV_H = {"µSv/h", 2, "atom"}; |
| 221 | +constexpr SensorValueFormat RADIATION_CPM = {"CPM", 0, "atom"}; |
| 222 | +constexpr SensorValueFormat RADIATION_BQ_M3 = {"Bq/m³", 1, "atom"}; |
| 223 | + |
| 224 | +/* =========================================================================== |
| 225 | + * BATTERY / STATE OF CHARGE |
| 226 | + * =========================================================================== */ |
| 227 | +constexpr SensorValueFormat BATTERY_PERCENT = {"%", 0, "battery"}; |
| 228 | +constexpr SensorValueFormat BATTERY_VOLTAGE = {"V", 2, "battery"}; |
| 229 | + |
| 230 | +/* =========================================================================== |
| 231 | + * PULSE / COUNT / RATE |
| 232 | + * =========================================================================== */ |
| 233 | +constexpr SensorValueFormat COUNT_PULSES = {"pulses", 0, "pulse"}; |
| 234 | +constexpr SensorValueFormat COUNT_UNITS = {"", 0, "counter"}; |
| 235 | +constexpr SensorValueFormat RATE_PER_SECOND = {"/s", 1, "pulse"}; |
| 236 | +constexpr SensorValueFormat RATE_PER_MINUTE = {"/min", 1, "pulse"}; |
| 237 | +constexpr SensorValueFormat RATE_PER_HOUR = {"/h", 1, "pulse"}; |
| 238 | + |
| 239 | +/* =========================================================================== |
| 240 | + * LEAK / BINARY STATE |
| 241 | + * =========================================================================== */ |
| 242 | +constexpr SensorValueFormat STATE_OPEN_CLOSED = {"", 0, "switch"}; |
| 243 | +constexpr SensorValueFormat STATE_ON_OFF = {"", 0, "switch"}; |
| 244 | +constexpr SensorValueFormat STATE_DRY_WET = {"", 0, "switch"}; |
| 245 | +constexpr SensorValueFormat STATE_PRESENT_ABSENT = {"", 0, "switch"}; |
| 246 | + |
| 247 | +} /* namespace SensorPresets */ |
0 commit comments