Loading...
Searching...
No Matches
uv_band.c File Reference

The risk band a UV index falls in, with a long and a short name for each. More...

#include "weather/uv_band.h"

Macros

#define UV_BAND_COUNT   (UV_BAND_EXTREME + 1)
 How many bands there are, UV_BAND_NONE included.

Functions

UvBand uv_band (int uv)
 The band a UV index falls in.
static const char * band_lookup (const char *const names[UV_BAND_COUNT], UvBand band)
 Looks a band up in one of the name tables.
const char * uv_band_name (UvBand band)
 The band's full name in capitals, such as "MODERATE" or "VERY HIGH".
const char * uv_band_short_name (UvBand band)
 The band's short name in capitals, at most six letters, such as "MOD" or "V.HIGH".

Detailed Description

The risk band a UV index falls in, with a long and a short name for each.

Function Documentation

◆ band_lookup()

const char * band_lookup ( const char *const names[UV_BAND_COUNT],
UvBand band )
static

Looks a band up in one of the name tables.

A band is an enum, so a caller can still hand in any number. Anything outside the table gets the empty name rather than a read past its end. The compare is unsigned, so a negative value wraps to a big one and is turned away by the same check. A band < 0 test on an enum the compiler made unsigned would fail the watch build under -Werror.

Parameters
namesThe table, one name per band.
bandThe band.
Returns
The band's name, or an empty string.