Straight
All Top-level Files
Not logged in
Public Repositories
mwm's Repositories

Files in the top-level directory in any check-in


Straight - a deviationTx switch/source fixer

Straight is designed to ease converting deviationTx model.ini files from one transmitter to another. You can get usage information with the --help flag.

Switches and Sources

The configuration file is another .ini file. Each options name is an input switch or source name. The option value can also be a switch or source name.

In this case, a "switch" is just the name of a switch as used in the transmitter configuration - something like AIL DR or HOLD or FMODE. Note that it does not have a position indicator. Either name or value can negated if you wish to invert the sense of the switch, so that HOLD=!RUD DR would cause RUD DR0 to act as a hold when HOLD1 did normally, and would also be handled properly in toggle icons and the [safety] section, but not as a trim switch, as that behavior is not set in the model config file.

A "source" is a switch name with a position indicator, like AIL DR0 or HOLD1 or FMODE2.

Switches, not Sources

For the most part, you should use switches instead of sources. That will cause all references to a switch in the model file to be converted. Using a just a source - for instance, RUD DR1=HOLD0 to convert a switch will occurrences of the switch in a toggle icon or as a trim switch to be missed, as well as any occurrences of RUD DR0 or RUD DR2.

You can use switches to override some mappings. For instance, RUD DR=!HOLD would cause RUD DR1 to become !HOLD1, and if you could use RUD DR1=HOLD0 so RUD DR1 becomes HOLD0 if you preferred that.

More usefully, you can use sources to handle mapping 3-way switches to multiple 2-way switches, or vice versa. For instance, to map the three modes from some other transmitter to the 7e, you could just use FMODE2=HOLD1. That would leave FMODE0 and FMODE1 alone, but let you trigger whatever was on FMODE2 via the HOLD1 switch. This is not recommened - you should have a real hold on all aircraft!

Or for the 6, you could map GEAR=MIX along with ELE DR1=MIX2 so that MIX0 and MIX1 are used in place of the GEAR, and MIX2 in place of ELE DR1.

Variables

You can also use variables for the option name or value, along with any negation required. When a switch in the model file is mapped to a variable, the variable will be looked up and that will be used.

Using variables as function names will allow you to assign switches to the functions you want, then specify which switches provide those functions when you convert a model file.

Auto Variables

The following variables will be added based on the input model file. They will be overridden by values in your config.

In additions, the protocol will be checked, and the following variables will be assigned to switches if they are used.

The default file

The idea is to set up a config file (the --help flag will tell you where it should be on your OS) that describes how you use your transmitter(s). If you only have one transmitter, don't use any [section] lines, as the unnamed section will be used by default. If you have more than one transmitter, you can use that section for the most common one, or for shared options. You would then use either the --section option to use a different section, or --extra to use other sections to add or override values in the default section.

The values in the file should use variables naming the function you want to convert. Given a model file and the description of what the switches do, add command line mappings to convert those switches to the appropriate variables in your config file.

For instance, my default config is for my Devo 6, and uses:

    hold=GEAR
    timer=MIX2
    rate=DR

Then, to convert a model file using my standard Devo 10 setup, I'd do:

    straight devo10.ini devo6.ini "AIL DR=rate" "!RUD DR=hold" "ELE DR1=timer" 

No default file

The --disable or -d option turns skips loading the default file. This can be used if a model is mostly right, but you want to make one change. For instance, I use RUD DR0 as a hold switch, because RUD DR1 initializes multirotor flight controllers. Some people would prefer that the other way around, so they can do:

    straight mwm.ini fixed.ini "RUD DR=!RUD DR"

to invert the switch usage.

Building

Don't. If you have a Windows box or a Mac, just download the binary builds. If you have a Unix or Linux system, it's actually easier to set up a VirtualBox VM to run the windows binary on.

If you really have to build it, go through the following steps:

  1. Install the fossil dscm. This is probably in your systems package system, so use that if possible. If not - fossil is easy to build from source.

  2. clone & open the repository:

    $ fossil clone https://chiselapp.com/user/mwm/repository/straight  straight.fossil
    $ mkdir straight
    $ cd straight
    $ fossil open ../straight.fossil
    
  3. Download the stack build tool and copy it to your path. This is probably not in your systems package system.

  4. Build & install the straight binary. This should tell you where it put the binary.

    $ stack build --copy-bins
    

Testing

This uses the tool shelltest tool to run shell tests. It can be installed by doing stack install shelltestrunner. You can then run the all the tests in the test directory with:

    $ cd tests
    $ shelltest .

You can run the tests using a version built with the stack exec command like so:

    $ stack exec shelltest .