OpenHantek
printutils.cpp File Reference
#include <cmath>
#include <QApplication>
#include <QLocale>
#include <QStringList>
#include <libusb-1.0/libusb.h>
#include "utils/printutils.h"

Functions

QString valueToString (double value, Unit unit, int precision)
 Converts double to string containing value and (prefix+)unit (Counterpart to stringToValue). More...
 
double stringToValue (const QString &text, Unit unit, bool *ok)
 Converts string containing value and (prefix+)unit to double (Counterpart to valueToString). More...
 
QString hexDump (unsigned char *data, unsigned int length)
 Returns the hex dump for the given data. More...
 
unsigned int hexParse (const QString dump, uint8_t *data, unsigned int length)
 

Function Documentation

◆ hexDump()

QString hexDump ( unsigned char *  data,
unsigned int  length 
)

Returns the hex dump for the given data.

Parameters
dataPointer to the data bytes that should be dumped.
lengthThe length of the data array in bytes.
Returns
String with the hex dump of the data.

◆ hexParse()

unsigned int hexParse ( const QString  dump,
uint8_t *  data,
unsigned int  length 
)

◆ stringToValue()

double stringToValue ( const QString &  text,
Unit  unit,
bool *  ok = nullptr 
)

Converts string containing value and (prefix+)unit to double (Counterpart to valueToString).

Parameters
textThe text containing the value and its unit.
unitThe base unit of the value.
okPointer to a success-flag, true on success, false on error.
Returns
Decoded value.

◆ valueToString()

QString valueToString ( double  value,
Unit  unit,
int  precision = -1 
)

Converts double to string containing value and (prefix+)unit (Counterpart to stringToValue).

Parameters
valueThe value in prefixless units.
unitThe unit for the value.
precisionSignificant digits, 0 for integer, -1 for auto.
Returns
String with the value and unit.