TrackBar Command Editor

Support forum for MegunoLink
Post Reply
tfinks
Posts: 3
Joined: Wed Apr 11, 2018 12:13 am

TrackBar Command Editor

Post by tfinks » Wed Apr 11, 2018 12:23 am

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).

Paul
Posts: 13
Joined: Wed Jun 10, 2015 10:35 pm

Re: TrackBar Command Editor

Post by Paul » Wed Apr 11, 2018 1:49 am

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.

tfinks
Posts: 3
Joined: Wed Apr 11, 2018 12:13 am

Re: TrackBar Command Editor

Post by tfinks » Thu Apr 12, 2018 8:47 pm

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

Paul
Posts: 13
Joined: Wed Jun 10, 2015 10:35 pm

Re: TrackBar Command Editor

Post by Paul » Sun Apr 22, 2018 9:46 am

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;

Code: Select all

Tools.AsByte(...)
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.

tfinks
Posts: 3
Joined: Wed Apr 11, 2018 12:13 am

Re: TrackBar Command Editor

Post by tfinks » Mon Apr 23, 2018 9:00 pm

Upgraded to 1.20.18112.422.

ValueChangedCommandName = \xFF\x00[Tools.AsByte((byte)ServoPositionTrackbar.Value)]

All wonderful.

Thanks, Paul!

Post Reply