tcMenu
Classes | Functions | Variables
tcUtil.h File Reference

Go to the source code of this file.

Classes

struct  ConnectorLocalInfo
 

Functions

void appendChar (char *str, char val, int len)
 
void ltoaClrBuff (char *str, long val, uint8_t dp, char padChar, int len)
 
void fastltoa_mv (char *str, long val, long divisor, char padChar, int len)
 
void fastltoa (char *str, long val, uint8_t dp, char padChar, int len)
 
long dpToDivisor (int dp)
 
uint8_t safeProgCpy (char *dst, const char *pgmSrc, uint8_t size)
 
char * potentialProgramMemory (const char *x)
 

Variables

char szGlobalBuffer []
 

Detailed Description

A series of utilities that used thoughout tcMenu


Class Documentation

◆ ConnectorLocalInfo

struct ConnectorLocalInfo

This structure is created in program memory and passed to all RemoteConnector instances. It contains the name that this device should be identified by and it's UUID.

Class Members
char name[20]
char uuid[38]

Function Documentation

◆ appendChar()

void appendChar ( char *  str,
char  val,
int  len 
)

appends a character at the end of the string, if there is space according to len

◆ ltoaClrBuff()

void ltoaClrBuff ( char *  str,
long  val,
uint8_t  dp,
char  padChar,
int  len 
)

A fast long to ascii function that more feature complete than the standard library. Supports zero padding and maximum number of decimal places. This version always starts at position 0 in the provided buffer and goes up to position len always leaving space for a terminator. The other two versions below support appending instead.

Parameters
strthe buffer to be output to
valthe value to be converted
divisorthe power of 10 largest value (eg 10000, 1000000L etc)
padCharthe character to pad with (or NOT_PADDED which is 0)
lenthe length of the buffer passed in, it will not be exceeded.

◆ fastltoa_mv()

void fastltoa_mv ( char *  str,
long  val,
long  divisor,
char  padChar,
int  len 
)

A fast long to ascii function that more feature complete than the standard library. Supports zero padding and the largest actual value to use normally a power of 10. Absolute largest value displayable is 1000000000 - 1. NOTE that this function will append at the end of the current string. Use ltoaClrBuff to start at position 0. This call will not exceed the length provided and will properly terminate the string.

Parameters
strthe buffer to be appended to
valthe value to be converted
divisorthe power of 10 largest value (eg 10000, 1000000L etc)
padCharthe character to pad with (or NOT_PADDED which is 0)
lenthe length of the buffer passed in, it will not be exceeded.

◆ fastltoa()

void fastltoa ( char *  str,
long  val,
uint8_t  dp,
char  padChar,
int  len 
)

A fast long to ascii function that more feature complete than the standard library. Supports zero padding and the number of decimal places to use. Maximum number of decimal places is 9. NOTE that this function will append at the end of the current string and will not exceed the length provided, it will also properly terminate the string. Use ltoaClrBuff to start at position 0 in the buffer.

Parameters
strthe buffer to be appended to
valthe value to be converted
dpthe number of decimal places allowed
padCharthe character to pad with (or NOT_PADDED which is 0)
lenthe length of the buffer passed in, it will not be exceeded.

◆ dpToDivisor()

long dpToDivisor ( int  dp)

converts decimal places into a suitable divisor, eg: 2 -> 100, 4 -> 10000

◆ safeProgCpy()

uint8_t safeProgCpy ( char *  dst,
const char *  pgmSrc,
uint8_t  size 
)

This is always safe to call, if there's a string that's in program mem on AVR but not on other boards, this always does the right thing.

Parameters
dstthe destination buffer
pgmSrcthe source to be copied (program mem on AVR)
sizethe size of dst.