LDS, you appear to be thinking of the new_value in:
char value_to send[11] = {0x01, 0x09, 0x00, 0x13, 0x04, 0x03, 0x20, 0x01, new_value, 0x05, 0x00};
char value_to send[11] = {0x01, 0x09, 0x00, 0x13, 0x04, 0x03, 0x20, 0x01, new_value, 0x05, 0x00};
To copy to clipboard, switch view to plain text mode
as if it were a pre-processor macro expansion rather than the run-time variable use it is. In pre-processing the macro is literally replaced with its value (as if you typed it there) and then the code is compiled: it is a compile time event. What you want is for the value passed in to the function to be placed in the array at run time. There is, as others have pointed out, no need to do anything to value other than check it is a valid character value.
void MainWindow::on_dial_valueChanged(int value)
{
// check that value is in the range 0 to 255 (or -128 to 127) perhaps?
char value_to send[11] = {0x01, 0x09, 0x00, 0x13, 0x04, 0x03, 0x20, 0x01, value, 0x05, 0x00};
// do something with the array before it goes out of scope
}
void MainWindow::on_dial_valueChanged(int value)
{
// check that value is in the range 0 to 255 (or -128 to 127) perhaps?
char value_to send[11] = {0x01, 0x09, 0x00, 0x13, 0x04, 0x03, 0x20, 0x01, value, 0x05, 0x00};
// do something with the array before it goes out of scope
}
To copy to clipboard, switch view to plain text mode
Bookmarks