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

The clamp and segment maths a bar or gauge is built from. More...

#include "math/scale.h"

Functions

int clamp_int (int value, int lo, int hi)
 Pin a value into a range, so it lands on the nearer end when it falls outside.
int segment_width (int total, int gap, int count)
 The width of one cell when a strip is carved into evenly spaced segments.
int fraction_px (int total, int num, int den)
 A fraction of a length in pixels, e.g. how far along a bar a moment sits.
int segments_filled (int level, int segments)
 How many cells of a gauge a percentage lights, rounding up so any charge lights one.
int plot_y (int y0, int height, int lo, int hi, int value)
 Map a reading to its pixel row in a plot, with the low end at the bottom.

Detailed Description

The clamp and segment maths a bar or gauge is built from.