Page 1 of 1
TrackBar Command Editor
Posted: Wed Apr 11, 2018 12:23 am
by tfinks
Can I send decimal, hex or binary data with ValueChangedCommandName? Presently, I'd like to send the following:
0xFF 0x00 [Trackbar.Value] (spaces added for clarity). In decimal form:
255 0 [Trackbar.Value] (spaces added for clarity).
Re: TrackBar Command Editor
Posted: Wed Apr 11, 2018 1:49 am
by Paul
Hi,
You can use: [((int)num.Value).ToString("X4")] to create a message with hex values in a string.
But I think you want actual bytes. Unfortunately that doesn't seem to be working at the moment. MegunoLink is converting numbers to strings. I will try to figure out what's gone wrong and fix it.
Kind regards
Paul.
Re: TrackBar Command Editor
Posted: Thu Apr 12, 2018 8:47 pm
by tfinks
Hello Paul,
Yes, I want the actual bytes represented by the hex and decimal values I listed.
By the way, is there available reference material describing the syntax that you provided? Looks like there is a rich set of constructs I had not known of.
Regards,
Tim
Re: TrackBar Command Editor
Posted: Sun Apr 22, 2018 9:46 am
by Paul
Hi Tim,
The latest version (1.20.18108.0418) released today will let you get the actual bytes. In your case, you'll want something like:
Code: Select all
\xFF\x00[Tools.AsByte((byte)TrackBar.Value)]
The \xXX are literal byte values;
converts a number to a sequence of bytes.
Expressions (surrounded by []) use a subset of the C# language so most C# expressions should work. Possibly the most useful is the ToString function, which takes a format string as an argument. Common format strings can be found here:
https://docs.microsoft.com/en-us/dotnet ... at-strings
Kind regards
Paul.
Re: TrackBar Command Editor
Posted: Mon Apr 23, 2018 9:00 pm
by tfinks
Upgraded to 1.20.18112.422.
ValueChangedCommandName = \xFF\x00[Tools.AsByte((byte)ServoPositionTrackbar.Value)]
All wonderful.
Thanks, Paul!