ePaper_EXT3_Basic_Library Reference Manual  501
Library for Pervasive Displays EXT3 - Basic level
Functions | Variables
hV_Utilities.cpp File Reference
#include "hV_Utilities.h"
#include "stdarg.h"
#include "stdio.h"
Include dependency graph for hV_Utilities.cpp:

Functions

void delay_ms (uint32_t ms)
 Blocking delay. More...
 
String formatString (const char *format,...)
 Format string. More...
 
String trimString (String text)
 Remove leading and ending characters. More...
 
int32_t cos32x100 (int32_t degreesX100)
 Cosinus. More...
 
int32_t sin32x100 (int32_t degreesX100)
 Sinus. More...
 
void convertPolar2Rectangle (uint16_t centerX, uint16_t centerY, uint16_t angle, uint16_t radius, uint16_t &rectangularX, uint16_t &rectangularY)
 Convert polar to rectangle coordinates. More...
 
void convertRectangle2Polar (uint16_t centerX, uint16_t centerY, uint16_t rectangularX, uint16_t rectangularY, uint16_t &angle, uint16_t &radius)
 Convert rectangle to polar coordinates. More...
 
String utf2iso (String s)
 UTF-8 to ISO-8859-1 Converter. More...
 
String i32toa (int32_t number, int32_t unit, uint8_t decimal, uint8_t size)
 Convert int32_t to string. More...
 
String htoa (uint32_t number, uint8_t size)
 Convert hexadecimal to string. More...
 
String ttoa (uint32_t number, uint8_t size)
 Convert time is ms to string. More...
 
String btoa (uint32_t number, uint8_t size)
 Convert binary to string. More...
 
uint16_t checkRange (uint16_t value, uint16_t valueMin, uint16_t valueMax)
 Check value in range. More...
 
void setMinMax (uint16_t value, uint16_t &valueMin, uint16_t &valueMax)
 Update min and max values. More...
 
uint32_t roundUp (uint32_t value, uint16_t modulo)
 Round-up. More...
 
void swap (uint16_t &a, uint16_t &b)
 Swap number, uint16_t. More...
 
void swap (int16_t &a, int16_t &b)
 Swap number, int16_t. More...
 
void swap (uint8_t &a, uint8_t &b)
 Swap number, uint8_t. More...
 

Variables

char bufferIn [128]
 
char bufferOut [128]
 
char bufferFormat [32]
 

Function Documentation

◆ btoa()

String btoa ( uint32_t  number,
uint8_t  size = 8 
)

Convert binary to string.

Parameters
numberbinary value
sizetotal number of digits, default=0=no check
Returns
formated string

◆ checkRange()

uint16_t checkRange ( uint16_t  value,
uint16_t  valueMin,
uint16_t  valueMax 
)

Check value in range.

Parameters
valuevalue to check
valueMinrange minimum
valueMaxrange maximum
Returns
value within range
Note
Assuming valueMin < valueMax
  • if value < valueMin, return valueMin
  • if value > valueMax, return valueMax Otherwise, if valueMin > valueMax, valueMin and valueMax are swapped

◆ convertPolar2Rectangle()

void convertPolar2Rectangle ( uint16_t  centerX,
uint16_t  centerY,
uint16_t  angle,
uint16_t  radius,
uint16_t &  rectangularX,
uint16_t &  rectangularY 
)

Convert polar to rectangle coordinates.

Parameters
[in]centerXcircle center, x coordinate
[in]centerYcircle center, y coordinate
[in]angleangle, degrees 0..360°
[in]radiusradius, pixels
[out]rectangularXx rectangular coordinate
[out]rectangularYy rectangular coordinate

◆ convertRectangle2Polar()

void convertRectangle2Polar ( uint16_t  centerX,
uint16_t  centerY,
uint16_t  rectangularX,
uint16_t  rectangularY,
uint16_t &  angle,
uint16_t &  radius 
)

Convert rectangle to polar coordinates.

Parameters
[in]centerXcircle center, x coordinate
[in]centerYcircle center, y coordinate
[in]rectangularXx rectangular coordinate
[in]rectangularYy rectangular coordinate
[out]angleangle in degrees 0..360°
[out]radiusradius in pixels

◆ cos32x100()

int32_t cos32x100 ( int32_t  degreesX100)

Cosinus.

Parameters
degreesX100angle in degrees, x100
Returns
cosinus value, x100
Note
This function uses integers only.

◆ delay_ms()

void delay_ms ( uint32_t  ms)

Blocking delay.

Parameters
msduration in ms
Note
delay_ms() is blocking, as it doesn't use delay()

◆ formatString()

String formatString ( const char *  format,
  ... 
)

Format string.

Based on vsprint

Parameters
formatformat with standard codes
...list of values
Returns
string with values formatted
See also
http://www.cplusplus.com/reference/cstdio/printf/?kw=printf for codes

◆ htoa()

String htoa ( uint32_t  number,
uint8_t  size = 0 
)

Convert hexadecimal to string.

Parameters
numberhexadecimal value
sizetotal number of digits, default=0=no check
Returns
formated string

◆ i32toa()

String i32toa ( int32_t  number,
int32_t  unit = 1,
uint8_t  decimal = 0,
uint8_t  size = 0 
)

Convert int32_t to string.

Parameters
numbervalue, int32_t, already multiplied by unit
unitdefault=1, 10 or 100
decimalnumber of decimal digits, default=0
sizetotal number of digits, default=0=free size, no check
Note
size >= integer digits + 1 for decimal separator . + decimal=decimal digits
Returns
formated string
Note
In case of insufficient place or overflow, # is returned

◆ roundUp()

uint32_t roundUp ( uint32_t  value,
uint16_t  modulo 
)

Round-up.

Parameters
valuevalue to round-up
modulomodulo
Returns
rounded-up value / modulo
Note
Examples
  • roundUp(7, 8) = 1;
  • roundUp(8, 8) = 1;
  • roundUp(9, 8) = 2;

◆ setMinMax()

void setMinMax ( uint16_t  value,
uint16_t &  valueMin,
uint16_t &  valueMax 
)

Update min and max values.

Parameters
valuevalue to consider
valueMinminimum value to update if value < valueMin
valueMaxmaximum value to update if value > valueMax
Note
valueMin < valueMax is assumed

◆ sin32x100()

int32_t sin32x100 ( int32_t  degreesX100)

Sinus.

Parameters
degreesX100angle in degrees, x100
Returns
sinus value, x100
Note
This function uses integers only.

◆ swap() [1/3]

void swap ( uint16_t &  a,
uint16_t &  b 
)

Swap number, uint16_t.

Parameters
afirst number
bsecond number

◆ swap() [2/3]

void swap ( int16_t &  a,
int16_t &  b 
)

Swap number, int16_t.

Parameters
afirst number
bsecond number

◆ swap() [3/3]

void swap ( uint8_t &  a,
uint8_t &  b 
)

Swap number, uint8_t.

Parameters
afirst number
bsecond number

◆ trimString()

String trimString ( String  text)

Remove leading and ending characters.

Parameters
textinput text
Returns
trimmed text
Note
Removed characters are LF CR TAB SPACE '

◆ ttoa()

String ttoa ( uint32_t  number,
uint8_t  size = 0 
)

Convert time is ms to string.

Parameters
numberms
sizetotal number of digits, default=0=free size, no check
Returns
formated string with time unit, ms, s, mn, h
Note
Automatic selection of the time unit: ms, s, mn, h
In case of insufficient place or overflow, # is returned

◆ utf2iso()

String utf2iso ( String  s)

UTF-8 to ISO-8859-1 Converter.

Parameters
sUTF-8 string, input
Returns
ISO-8859-1 string, output
See also
The Unicode Consortium. The Unicode Standard, Version 6.2.0, (Mountain View, CA: The Unicode Consortium, 2012. ISBN 978-1-936213-07-8) http://www.unicode.org/versions/Unicode6.2.0/

Variable Documentation

◆ bufferFormat

char bufferFormat[32]

◆ bufferIn

char bufferIn[128]

◆ bufferOut

char bufferOut[128]