Phoenard
Macros | Functions
PHNUtils.h File Reference

Various utility functions for use all-around. More...

#include <Arduino.h>
#include "BufferedReadStream.h"
#include "FlashMemoryStream.h"
#include "MemoryStream.h"
#include "DataBuffer.h"

Go to the source code of this file.

Macros

#define swap(a, b)   { int16_t t = a; a = b; b = t; }
 Swaps a signed integer around.
 

Functions

int getFreeRAM (void)
 Gets how much RAM is still available.
 
char * allocateCopy (const char *src)
 Allocates a new copy of a String on the heap.
 
uint8_t bit_reverse (uint8_t b)
 Reverses the byte bit order.
 
void flushRead (Stream &stream)
 Reads a stream until no further reading is possible.
 
bool waitAvailable (Stream &stream, unsigned long timeoutMS)
 Waits until a character becomes available to be read.
 
bool flushTransfer (Stream &streamA, Stream &streamB)
 Flushes one stream to another and vice versa. More...
 
int strcpy_count (char *destination, const char *source)
 Copies one string to another, counting how many characters are copied. More...
 
void shiftElements (void *ptr, int blockSize, int blockCount, int shiftCount)
 Shifts array elements forwards or backwards, settings the shift-out memory to NULL. More...
 

Detailed Description

Various utility functions for use all-around.

Function Documentation

bool flushTransfer ( Stream &  streamA,
Stream &  streamB 
)

Flushes one stream to another and vice versa.

Writes from Stream A to Stream B and vice versa Put into a While loop for infinite transferring Returns whether any form of communication occurred

void shiftElements ( void *  ptr,
int  blockSize,
int  blockCount,
int  shiftCount 
)

Shifts array elements forwards or backwards, settings the shift-out memory to NULL.

Parameters
[in,out]ptrThe pointer to the block of memory to shift
[in]blockSizeThe size of a single element in the array
[in]blockCountThe amount of elements inside the array pointed at by ptr
[in]shiftCountThe amount of times up or down the blocks should be shifted
int strcpy_count ( char *  destination,
const char *  source 
)

Copies one string to another, counting how many characters are copied.

The count is EXCLUDING the terminating null-character (is still copied)