TactilityC: Forgot the most important function, getting the unit string of course!

This commit is contained in:
Dominic Höglinger 2025-09-23 20:57:48 +02:00
parent 9c6fa9d152
commit fad1980f98
2 changed files with 23 additions and 0 deletions

View File

@ -128,6 +128,18 @@ RadioParameterStatus tt_hal_radio_set_parameter(RadioHandle handle, RadioParamet
*/
RadioParameterStatus tt_hal_radio_get_parameter(RadioHandle handle, RadioParameter parameter, float *value);
/**
* Get the unit string of a parameter.
* If the parameter isn't available, the returned string is empty.
* If the unit string does not fit into the provided character array,
* it is truncated but always null terminated.
* @param[in] handle the radio driver handle
* @param[in] parameter the parameter
* @param[out] str character array to store the unit string into
* @param[in] maxSize the maximum size the array str can hold
*/
void tt_hal_radio_get_parameter_unit_str(RadioHandle handle, RadioParameter parameter, char str[], unsigned maxSize);
/**
* Check whenever the radio driver object can transmit a certain modulation.
* @param[in] handle the radio driver handle

View File

@ -69,6 +69,17 @@ extern "C" {
return fromCpp(wrapper->device->getParameter(toCpp(parameter), *value));
}
void tt_hal_radio_get_parameter_unit_str(RadioHandle handle, RadioParameter parameter, char str[], unsigned maxSize) {
auto wrapper = static_cast<DeviceWrapper*>(handle);
assert(str);
std::string unitString = wrapper->device->getParameterUnit(toCpp(parameter)).toString();
size_t i = 0;
for (; i < (maxSize - 1); ++i) {
str[i] = unitString[i];
}
str[i] = '\0';
}
bool tt_hal_radio_can_transmit(RadioHandle handle, Modulation modulation) {
auto wrapper = static_cast<DeviceWrapper*>(handle);
return wrapper->device->canTransmit(toCpp(modulation));