SBB Host
Host communication with the self balancing bike.
Loading...
Searching...
No Matches
SBBUtils.h File Reference
#include <time.h>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>

Go to the source code of this file.

Classes

struct  utils::hhmmss_t
 A structure for handling elapsed time in hour, minute, second format. More...
 

Namespaces

namespace  Colors
 A namespace providing a set of standard colors.
 
namespace  utils
 A namespace providing utility functions.
 

Functions

int utils::filecp (const char FileSource[], const char FileDestination[])
 Copy a file. More...
 
int utils::getIP_and_subnetmask (uint32_t *ip=nullptr, uint32_t *mask=nullptr, std::string *ip_str=nullptr, std::string *mask_str=nullptr)
 Get the local IP and subnet mask. More...
 
uint32_t utils::get_remoteIP (uint32_t ip, uint32_t mask, std::string *str=nullptr)
 Get the remote IP. More...
 
uint32_t utils::get_broadcastIP (uint32_t ip, uint32_t mask, std::string *str=nullptr)
 Get the broadcast IP. More...
 
uint32_t utils::ip_str2num (std::string ip_str)
 Convert IP from string to uint32. More...
 
std::string utils::hex2str (unsigned int v)
 Convert HEX from unsigned int to string. More...
 
bool utils::str2hex (std::string str, unsigned int *p_v)
 Convert HEX from string to unsigned int. More...
 
float utils::average (std::vector< float > const &v)
 Get the average of a vector of float. More...
 
float utils::rms (std::vector< float > const &v)
 Get the RMS of a vector of float. More...
 
std::string utils::get_home_path ()
 Get the HOME path. More...
 
void utils::beep (int mode)
 Send a beep message. More...
 
bool utils::set_env_var (std::string key, std::string val)
 Set a local environment variable. More...
 
hhmmss_t utils::sec2hhmmss (int secs)
 Convert elapsed seconds to hh::mm:ss format. More...
 

Variables

constexpr double Colors::red [] = { 0, 0.85, 0.929, 0.494, 0.466, 0.301, 0.635 }
 red tone of the set of colors More...
 
constexpr double Colors::green [] = { 0.447, 0.325, 0.694, 0.184, 0.674, 0.745, 0.078 }
 green tone of the set of colors More...
 
constexpr double Colors::blue [] = { 0.741, 0.098, 0.125, 0.556, 0.188, 0.933, 0.184 }
 blue tone of the set of colors More...
 
constexpr int Colors::size = 7
 number of color in the color set. More...