MegaTune Setup Wizard is created with the excellent Inno Setup by Jordan
Russell.  Details and downloads can be found at http://www.jrsoftware.org/

Any problem reports, comments or suggestions should be directed to Eric
Fahlgren <eric@wryday.com>, not to Bruce or Al, since this was my doing
and is not necessarily condoned by them.

First Time Startup
==================
      USB Serial Port Adapter Users READ THIS NOW!

Occasionally USB adapters will cause MT to hang on startup (you'll start
MT and it will just never appear).  This can usually be cured by editing
the config file,

   c:\Program Files\MegaSquirt\MegatuneN.NN\mtCfg\megatune.cfg

and modifying the first line to correspond to the comm port that is
mapped to the USB adapter.

The communications settings dialog allows you to set the timer interval.
The megatune.cfg file is generated and written automatically whenever
you change settings, so there is no need to edit it manually any more
except as noted above.

If you have comm errors writing to your MS with a USB adaptor, try
changing the "writeBlocks" and "interWriteDelay" values in the ini file
for your configuration.

WHEN DIALOGS DON'T APPEAR
=========================
If you click on a menu and the corresponding dialog box does not appear
when you expect it to, hit the "alt" key once.  If the dialog then pops
into existence, report this to me as I think I know how to fix it...

GENERIC FIRMWARE UPDATE SUGGESTIONS
===================================

(Write me at eric@wryday.com with any suggestions for this list
and sooner or later I'll automate it in the Configurator.)

1) Practice "upgrading" first by using your current .s19 file, so
   that you have as few variables as possible when things go wrong
   and so that you become familiar with the process with the most
   likely-to-work scenario.

2) Make sure you have the old .s19 for the current firmware in the
   current project directory so you can back off the changes if you
   have unresolvable problems.

3) Make sure you have all the ini and inc files that are specific
   to the current installation in the old project's mtCfg directory.
   If you have only ever had one project, it is probably called
   "car1", so you should have your base ini in car1/mtCfg.

4) Make sure to save your current configuration before you do
   anything else.  Do a File -> Save, then go to each table and
   do File -> Table Export on each table.

5) Print out a hard copy of you current settings first.  Use Tools
   -> Dump and print the resulting MegaTune.dmp file (I usually edit
   it to add comments and remove anything I consider useless for my
   archiving).

6) Create a new project for your new firmware, use the MegaTune
   Configurator, Project -> New, name it such that you know that
   it is associated with the new firmware "Corvette 024s9" or
   something like that.  Copy the ini and inc files for this
   installation into the new project's mtCfg directory; copy the
   s19 into the project directory.

7) Once you've installed the new firmware, make use of MegaTune's
   review mode, Tools -> Review Mode, to go through all the menus
   and verify that all the settings are as you expect.

V 2.25 - 30 JAN 2006 ===================================================
========================================================================
After almost two years of development, I'm calling 2.25 finished.
Here's a quick guide to the ini file contents, more details are
contained in the build notes following the ini documentation.

[MegaTune]
   MTversion      = number
   writeXML       = true|false ; Forces use of binary msq if false.

   versionInfo    = string
   queryCommand   = string
   signature      = number | string

[BurstMode]
   commRate      = number
   commPort      = number
   getCommand    = string
   initialDeltaT = number

=================================================================

[Constants]
   endianness          = little | big
   writeBlocks         = on | off
   verify              = on | off
   interWriteDelay     = ms ; Time between subsequent data writes.
   blockReadTimeout    = ms
   pageActivationDelay = ms

   nPages          = number
   burnCommand     = string, ...
   pageSize        = number, ...
   pageReadCommand = string, ...
   pageChunkRead   = string, ...
   pageValueRead   = string, ...
   pageIdentifier  = string, ...
   pageActivate    = string, ...
   pageWriteCommand= string, ...
   pageChunkWrite  = string, ...
   pageValueWrite  = string, ...

   page = 1
      name       = array,  type, offset, shape,   units,     scale, translate,  lo,   hi, digits
      VE         = array,  U08,       0, [X:8x8], "%",         1.0,       0.0,   0,  255,      0
      WWU        = array,  U08,      68, [   10], "%",         1.0,       0.0,   0,  255,      0

      name       = scalar, type, offset,          units,     scale, translate,  lo,   hi, digits
      TPSthresh  = scalar, U08,      83,          "v/s", 0.1953125,       0.0,   0,   50,      3
      TPSclock   = scalar, U08,      84,          "ms",        0.1,       0.0, 0.1, 25.5,      1

      name       = bits,   type, offset, bits
      ; Config12 byte at 117
      cltType    = bits,   U08,     117, [0:1], "GM", "1", "2", "3"
      matType    = bits    U08,     117, [2:3], "GM" ; Same as above.
      nInjectors = bits,   U08,     117, [4:7+1]  ; Use auto-generated "1"-"16"

   where "type" is one of S08, U08, S16, U16, S32 or U32.
   Signed versus unsigned has no effect on bit fields.
   "INVALID" in bits holds a place that is not displayed in the combo box.

[OutputChannels]
   ochBlockSize          = number
   ochGetCommand         = string
   user-defined-variable = { expression } [, "optional-units" ]

 ; name  hunk    type  ofs  units  scale  trans
   rpm = scalar, S16,    7, "RPM", 1.000, 0.000

 ; name  hunk    type  ofs  bitSpec
   sch = bits,   U08,   11, [2:2]

Note:
   user-defined-variable = @(number) ; Now obsolete, generates an error.

=================================================================

[GaugeConfigurations]
   ; Put the following all on one line...
   user-defined-gauge-name = name-string, variable-reference, title-string,
      units-string, lo, hi, lo-danger, lo-warning, hi-warning, hi-danger,
      value-decimals, range-decimals

[FrontPage]
   gaugeN    = gauge-configuration-reference ; N = 1 through 8
   egoLEDs   = lo-number, hi-number, redline-number
   indicator = expression, "-Txt", "+Txt", "-bg", "-fg", "+bg", "+fg"
   saved     = "-bg", "-fg", "+bg", "+fg"
   logging   = "-bg", "-fg", "+bg", "+fg"
   connected = "-bg", "-fg", "+bg", "+fg"

   "+/-fg" and "+/-bg" are color names defined in the ColorMap section.
   The - ones are used when the indicator is in the "off" state, the +
   ones are for the "on" state.

[AccelerationWizard]
   tpsDotBar = 0,  30
   mapDotBar = 0, 300

[RunTime]
   barHysteresis = seconds
   egoBar        = lo-number, hi-number
   coolantBar    = lo-number, hi-number
   batteryBar    = lo-number, hi-number
   throttleBar   = lo-number, hi-number
   gammaEBar     = lo-number, hi-number
   mapBar        = lo-number, hi-number
   matBar        = lo-number, hi-number
   rpmBar        = lo-number, hi-number
   pulseWidthBar = lo-number, hi-number
   dutyCycleBar  = lo-number, hi-number
   egoCorrBar    = lo-number, hi-number
   baroCorrBar   = lo-number, hi-number
   warmupCorrBar = lo-number, hi-number
   airdenCorrBar = lo-number, hi-number
   veCorrBar     = lo-number, hi-number
   accCorrBar    = lo-number, hi-number

[Tuning]
   gaugeColumns    = 1 | 2
   ; Four columns of gauge configuration references per gaugeN:
   gaugeN          = gauge-configuration-reference, gauge-co... ; N = 1 through 8

   pageButtons     = string, ... for N pages

   egoLEDs         = lo-number, hi-number

   font            = "font", size
   cursorDepth     = number
   spotDepth       = number
   backgroundColor = color-name | R-byte, G-byte, B-byte
   cursorColor     = color-name | R-byte, G-byte, B-byte
   gridColor       = color-name | R-byte, G-byte, B-byte
   spotColor       = color-name | R-byte, G-byte, B-byte
   textColor       = color-name | R-byte, G-byte, B-byte

[AutoTune]
   table = veTableMap ; Should be the map3d_id of a TableEditor entry.
      allowAutoTune          = on            ; Displays the check box on the specified tuning dialog.
      corrector              = egoCorrection ; Variable used for correction algorithm.

      ; Tuning block parameters
      ;    Global limits on tuning, outside the box and nothing happens.
      xLimits                = 1500, 4000    ; RPM
      yLimits                =   60,   90    ; MAP
      zLimits                =   10,  200    ; VE

      ; Vertex tolerance parameters
      ;   How close you must be to a vertex before tuning takes place.
      xRadius                = 200           ; RPM
      yRadius                =   7           ; MAP

      ; Controller parameters
      initialStartupInterval = 1.0           ; Seconds before first adjustment
      updateInterval         = 1.0           ; Seconds between each consecutive adjustment.
      proportionalGain       = 0.5           ; Proportion of (100-corrector) to use for adjustment.
      lumpiness              = 5             ; Maximum percent adjustment above or below neighboring VE points.

=================================================================

[ColorMap]
   fieldColoring = on | off
   color-name    = R, G, B

   See color24b.ini for examples.  There are several pre-defined
   colors derived from windows:
   
      SYSTEM_BG = ::GetSysColor(COLOR_3DFACE       )
      SYSTEM_WT = ::GetSysColor(COLOR_WINDOWTEXT   )
      SYSTEM_AC = ::GetSysColor(COLOR_ACTIVECAPTION)
      SYSTEM_CT = ::GetSysColor(COLOR_CAPTIONTEXT  )

[GaugeColors]
   alertColor      = color-name | R-byte, G-byte, B-byte
   backgroundColor = color-name | R-byte, G-byte, B-byte
   bgDangerColor   = color-name | R-byte, G-byte, B-byte
   bgWarningColor  = color-name | R-byte, G-byte, B-byte
   faceColor       = color-name | R-byte, G-byte, B-byte
   ledAlertColor   = color-name | R-byte, G-byte, B-byte
   ledColor        = color-name | R-byte, G-byte, B-byte
   needleColor     = color-name | R-byte, G-byte, B-byte
   rangeColor      = color-name | R-byte, G-byte, B-byte
   scaleColor      = color-name | R-byte, G-byte, B-byte
   titleColor      = color-name | R-byte, G-byte, B-byte
   valueColor      = color-name | R-byte, G-byte, B-byte

=================================================================

[Menu]
   menu = "display-string" [, { enabling-expression } ]
      subMenu = dialog_name, "display-string" [, page-number [, { enabling-expression }]]
      plugIn  = "path",      "display_string" [, verb        [, { enabling-expression }]

      Plug-in paths may utilize the following pre-defined variables:

         %MEGASQUIRT_DIR%
         %PLUGINS_DIR%
         %COMMON_DIR%
         %INSTALL_DIR%
         %WORKING_DIR%

      The path is fed to the windows shell execute with the default
      verb, so if you feed it just a directory name, the directory will
      be opened; if you feed it an executable path, the program will be
      run; if you feed it a .doc file, it will launch the editor and so
      on.

      The verb is an action that MegaTune takes upon executing the plugin.
      Valid verbs are none, minimize or exit, meaning do nothing, minimize
      the MegaTune window and exit MegaTune, respectively.

   menuDialog = dialog-identifier (main is the front page, default at start up)
      menu = "File"
         plugIn  = "%INSTALL_DIR%/mtCfg.exe", "&Configurator", exit

      menu = "&Settings", { enabled }
         subMenu = std_constants,   "&Constants" [, 0 [, { enabled }]]
         subMenu = std_enrichments, "&Enrichments"
         subMenu = std_separator

      menu = "&Tuning"
         subMenu = std_realtime,    "&Realtime Display"
         subMenu = std_warmup,      "&Warmup Wizard"

[UserDefined]
   dialog = dialog-identifier-string [,dialog-title-string [,int-page-number]]
      topicHelp = help-identifier
      field     = label-string, bit-const                 [,expression]
      field     = label-string, scalar-const              [,expression]
      array1D   = title-string, label-string, array-const [,expression]

   help = help-identifier, "Help box title"
      webHelp = URI
      text    = "text <br>"

   dialog = dtSettings, "General Dual Table Settings", 2

[TableEditor]
   table = table-id,    map3d-id,    "title" [, page]
   table = veTable1Tbl, veTable1Map, "VE Table 1", 1
      topicHelp   = table-help-identifer, tuning-help-identifer
      xBins       = constant, variable [, readonly]
      yBins       = constant, variable [, readonly]
      zVals       = constant [, readonly]
      gridHeight  = number
      gridOrient  = x-rotation-number, y-rotation-number, z-rotation-number
      upDownLabel = "up", "down"


[CurveEditor]
   curve = Id-for-menu, "dialog box title"
      topicHelp   = Help-id or URL ; optional entry
      columnLabel = x-label, y-label
      xAxis       = lo, hi, nTicks
      yAxis       = lo, hi, nTicks
      xBins       = x-array [,tracking variable]
      yBins       = y-array
      gauge       = gauge-definition ; optional entry

   curve = coldAdvance, "Cold Ignition Advance"
      topicHelp   = "http://www.megasquirt.info/megatune.htm#ap"
      columnLabel = "Coolant", "Offset"
      xAxis       = -40, 200, 9
      yAxis       = -10, 10, 11
      xBins       = tempTable, coolant
      yBins       = coldAdvanceTable
      gauge       = coolantGauge

=================================================================

[Datalog]
   enableWrite      = { expression }
   markOnTrue       = variable-reference
   delimiter        = "byte-string"     ; default is "\t"
   defaultExtension = "file-extension"  ; default is "xls"

   entry = variable-reference, label-string, float|int, format-string
   ; Example:
   entry = time, "Time", float, "%.3f"

=================================================================

Standard dialogs

std_separator

std_accel - Handle to the Acceleration Wizard.  Define constants
   with the following names to make them accessible to the AE Wizard:

      tpsDOT
      mapDOT

      tpsProportion
      tpsThresh
      mapThresh
      taeTime
      tdePct
      taeColdA
      taeColdM
      maeRates
      maeBins
      taeRates
      taeBins

std_constants - This is the handle to the original MS-I constants
   dialog.

      algorithm
      alternate
      baroCorr
      battFac
      engineType
      fastIdleT
      injOpen
      injPwmP
      injPwmT
      injType
      mapType
      nCylinders
      nInjectors
      reqFuel
      twoStroke
      rpmk
      divider

std_enrichments - MS-I style enrichments dialog.
      egoType
      primePulse
      crankCold
      crankHot
      asePct
      aseCount
      tpsThresh
      taeTime
      tdePct
      taeColdA
      taeColdM
      egoRPM
      egoTemp
      egoCount
      egoDelta
      egoLimit
      egoSwitch
      wueBins - 10 values
      taeBins - 4 values

std_injection - Subset of above std_constants, used in MS-II.
      algorithm
      alternate
      engineType
      injType
      nCylinders
      nInjectors
      reqFuel
      twoStroke
      rpmk
      divider

std_realtime
      engine - specific bit settings required...  Change to use userIndicator.

      barometer
      secl
      egoVoltage
      map
      mat
      coolant
      throttle
      batteryVoltage
      rpm
      pulseWidth
      egoCorrection
      airCorrection
      warmupEnrich
      accelEnrich
      baroCorrection
      veCurr
      gammaEnrich
      idleDC

std_warmup
      primePulse
      crankCold
      crankHot
      floodClear
      asePct
      aseCount
      wueBins - 10 values

      coolant
      egoVoltage
      map
      warmupEnrich

std_ms2gentherm
std_ms2geno2

=================================================================

Data types:
*  byte   - scalar 8-bit integer.
   int    - scalar 16-bit integer.
   double - scalar double precision float.
   string - dynamic length collection of characters.

   Boolean results may be derived from any value, with 0, 0.0 and
   "" being false and all other values being true.

Operators in order of descending precendence:
   () grouping

*  [] indexing NOT DONE

   !  logical NOT
   ~  bitwise NOT
   -  unary minus = negation

   *  multiplication
   /  division
   %  modulus

   +  addition
   -  subtraction

   << left shift
   >> right shift

   <  less than
   <= less than or equal to
   == equal to
   >  greater than
   >= greater than or equal to
   != not equal to

   &  bitwise AND
   ^  bitwise XOR

   |  bitwise OR

   && logical AND

   || logical OR

   ?: conditional

Built-in math functions and constants:
   PI
   acos(double)
   asin(double)
   atan(double)
   atan2(double, double)
   ceil(double)
   cos(double)
   exp(double)
   fabs(double)
   floor(double)
   fmod(double, double)
   log(double)
   log10(double)
   pow(double, double)
   sin(double)
   sqrt(double)
   tan(double)
   timeNow

MS-specific functions:

   itable(val, "filename") - Inverse table lookup.  Given a value,
      it returns the index of the table value nearest that value.

   table(idx, "filename") - Causes the table to be read on the first
      invocation.  Indexes into the table and returns the value
      contained at the specified location.  Table files may contain
      an arbitrary number of 16-bit signed or unsigned quantities.

   tempCvt(x) - Converts Fahrenheit temperature to user-selected
      units.  Does nothing if temperature is set to F.

   vexInterp(rpm, load, page, "file.vex") - Performs interpolation
      of a vex file using the same algorithm as is used in MS-I and
      MS-II code.

=================================================================

Build 757
   Make Alt-C close all menu-containing dialog boxes, shortcut for
   File -> Exit.

Build 755
   Add post-plugin execution verbs to ini, so we can manipulate MT as
   we shoot off an executable.

   File -> Configurator launches MT Config and exits MT.

Build 754
   Get rid of root mtCfg, which does not work on win98 for some reason.

Build 753
   Added "indicator = restart" so you can delete all existing indicators
   on a dialog and define new ones in your custom.ini.

   Added better comm port checking at startup, should eliminate any lock
   up behavior on USB ports.

   Fix a windows resource leak in the runtime dialog, bug reported by
   Jeff Bond.

Build 752
   Ctrl-A now toggles Auto-tune in the 3D tuning dialog.

   Hopefully removed all the little nitpicks from the msns-extra.ini
   files...

Build 749
   Add "F1" button on user dialogs, only appears if there is user help.

Build 748
   Bug fix for gauge updating.

Build 745
   Clean up warmup wizard internals.
   Move some stuff around in the configuration files.

Build 744
   Added real logarithmic curve generation to complement the linear and
   exponential curves in the curve generator.

Build 743
   Put back the creation of the commmon directory, created a new include
   "common.ini" that is included into megatune.ini just before custom.ini.
   Moved all the "writeBlocks" and "interWriteDelay" parameters into the
   new common.ini.

   Fixed a bug in interpolation that Andy found, small values of X or Y
   were being truncated to integers, resulting in garbage on the 3D
   tuning dialog.

   Have I fixed the dialog drawing problem once and for all???

Build 742
   Created File -> Offline mode, which doesn't even attempt to talk to
   MS, you are completely disconnected.

Build 741
   Added xAxis and yAxis settings on the curve editor.

   Fix check mark on tuning dialog Tools -> Autotune.

   Added display checking to runtime dialog, so timer events don't
   make it disappear.

   Fixed up plugin execution to edit .doc, .txt and .log files.

   Added audit log editing to all ini files.


Build 739
   Added curve generator to Tools menu of curve editor.  It allows one
   to define linear or exponential curves through two points.  The exp
   curve is especially useful for defining cranking pulsewidth tables,
   just enter a pair of points that are known to work pretty well and
   set the y-offset to about 0.5-PW_at_160 and see what sort of curve
   it gives you.

   The datalog now contains the firmware signature as the first line.
   This probably breaks a bunch of log viewers...

Build 738
   Fixed bug wrt non-square tables.  Old MS-II 2.3+ ini files will not
   work properly with this build or later.  Spare port settings were
   affected, but old msq files were correct even though the inin file
   was not.

   Exposed Automatic Mixture Control parameters in MS-II 2.5.

Build 737
   Add menu to 3D tuning dialog, still need to clean up buttons and
   other controls on the dialog.  This menu is user extensible as are
   all other menus in MegaTune (see details in build 734).  The
   Autotune button has been moved to the Tools menu.

Build 736
   Added topicHelp to table editor, you get a page for each of the
   table and tuning dialogs.

      table = tableVE, tuningVE
         topicHelp = "http://www.msefi.com/table.html", tuningHelp
         ...

   Timer mechanism rework, helps make the user menus on the table and
   curve editors more robust.

Build 735
   Cleaned up messaging system in ini file reader so that all messages
   get logged into the audit.log file.

   Added "#alert" to the ini file, so you can now display user messages
   using lines like this:

      #alert "Hello, world."

   Touched up the MS-II 2.5 configuration a bit.

Build 734
   User-defined Menus
   ------------------
   Allow user-defined modification of menus on curve and table editor.
   This is accomplished by setting the "menuDialog" for the menu items
   that you wish to appear

   menuDialog = ignitionTbl  <-- Created in [TableEditor] section
      menu = "&Settings"
         subMenu = generalIgnition,   "&General Settings"

   menuDialog = main  <-- "main" is a predefined name for the front page
      menu = "T&ables"
         subMenu = iacBins,           "I&dle Steps"

   You can use the same "menuDialog" name as often as you wish, and you
   may want to mix them up because the Tools -> Review Mode displays all
   dialogs in the order in which they are placed in menus, so you would
   see generalIgnition followed by iacBins if you used the example above.

   Color Map
   ---------
   Added two new colors for the text used on the table and curve editors
   when tracking the spot and cursor.  Previously the tuning dialog's
   text color was used to contrast with the spotColor and cursorColor
   used for field coloring, now there are spotText and cursorText colors
   to allow them to contrast with the spot and cursor colors, respectively.

Build 733
   Completed run-time variable tracking in the curve editor, turned on
   gauge display.  Added help also (see example below), reworking it to
   allow addition of user-defined help on any dialog (still need to add
   syntax to the ini file to expose this).  Also reworked the table
   editor dialog, deleting the buttons and moving the commands to the
   menus.

Build 731
   Added the preliminary two-D curve editor.  Right now it has only the
   most rudimentary capabilities, just basic editing either via entry of
   numeric values or using shift-arrow or ctrl-shift-arrow on the curve.

      [CurveEditor]
       ; curve = Id-for-menu, "dialog box title"
       ;    topicHelp   = Help-id or URL (optional entry)
       ;    columnLabel = x-label, y-label
       ;    xBins       = x-array [,tracking variable]
       ;    yBins       = y-array
       ;    gauge       = gauge-definition (optional entry)

         curve = coldAdvance, "Cold Ignition Advance"
            topicHelp   = "http://www.megasquirt.info/megatune.htm#ap"
            columnLabel = "Coolant", "Offset"
            xBins       = tempTable, coolant
            yBins       = coldAdvanceTable
            gauge       = coolantGauge

Build 730
   Color Map
   ---------
   Finish up the color map and color referencing stuff.  Now all the
   colors can be specified either with the old RGB sequence or with
   a color name.  The following definitions of backgroundColor are
   equivalent:

      [ColorMap]
         black = 0, 0, 0

      [GaugeColors]
         backgroundColor = 0, 0, 0
         backgroundColor = black

   There are now some pre-defined colors, sucked out of the windows
   repertoire of colors:

      SYSTEM_BG = ::GetSysColor(COLOR_3DFACE       )
      SYSTEM_WT = ::GetSysColor(COLOR_WINDOWTEXT   )
      SYSTEM_AC = ::GetSysColor(COLOR_ACTIVECAPTION)
      SYSTEM_CT = ::GetSysColor(COLOR_CAPTIONTEXT  )

   Color Scheme Ini Files
   ----------------------
   Moved a bunch of standard colors to be predefined, see the new
   color definition file, colorScheme.ini, which replaces the two
   files colors24b.ini and colors08b.ini.

   Table Editor
   ------------
   Add runtime variable tracking on table editor.  It uses the tuning
   dialog spot color for the highlighted cell, and the tuning dialog
   text color.  Required rework of the 3D tuning dialog, also, so be
   sensitive to weird behavior there and report it right away.

   Ini File Processing
   -------------------
   Better error checking was added to byte string escape sequences.  James
   pointed out that invalid octal sequences like "\008" were being passed
   through as "\00" + "8", goofing things up badly.

Build 729
   Label formatting options in user dialogs are now fully explicit;
   there is no more implicit highlighting of "header" lines.  Formats
   may be stacked, the three prefixes are:

      > - Right justify label
      # - Use system header color for label
      ! - Use white text on red background for label

   So, this would display "Something" right justified in red:

      field = ">!Something"

   Implemented array1D to user dialogs.  Here's the syntax for the
   new statement:

      array1D = title-string, label-string, array-const [,expression]

   If the title string is an empty string, then only the fields of
   interest are displayed, otherwise a group box is created to contain
   the fields and display the title.

   To support proper label generation, new format options for title and
   label strings have been added.  Formatting options support the same
   symbol interpretation that was introduced in build 718, but has been
   enhanced to index into the symbol when used in the context of an
   array1D label.  For example, the following label string

      array1D = "Cranking PW", "At %tempTable%", crankingPW

   will generate labels of the form "At -40.0 C", with the values being
   taken from tempTable[i] for each row.  Similarly, there is now a
   "%INDEX%" pseudo-symbol that is replaced by the row number in the
   dialog, so you could use a label string like "Temperature %INDEX%",
   which turns into "Temperature 1", "Temperature 2" and so on.

   There is also a "%#symbol%" option, which replaces the format with
   the count of values for the symbol, instead of the value of the
   symbol.  See the megasquirt-II.ini files for examples of usage on
   all this.

Build 728
   Reformat user-defined dialogs, add some structure for array
   editor enhancements.

   Finish up some stuff in mtCfg, add a help file.

Build 727
   Add more formatting options to user defined dialog fields to
   complement the symbol stuff from build 718. Try putting a
   ">" at the front of a label to make it right justified.

Build 726
   Make popups work on 95, which doesn't have scrolling menus.

Build 724
   Fix up the right mouse stuff from previous build.

   Rework mtCfg's File -> Open mechanism so it works on more
   windows versions.

Build 723
   Expose front panel gauge selection/reset mechanism.  Right
   mouse on a gauge and see what happens.

Build 718
   Add label pre-processing, with symbol value substitution into
   static strings at dialog or menu creation time.  Stick this
   into a dbox definition and %symbol% will be replaced with the
   constant's value and units.

      field = "String %symbol%", otherSymbol

Build 717
   Put in a whole bunch of ini file reader validation, mostly in
   the Constants and OutputChannels sections.

Build 715
   Finish up "plugIn" menu item, looks like:

   menu = "File"
      subMenu = std_separator
      plugIn  = "path_to_file",  "Menu display string"

   The path to the file may contain any of the following path
   variables, which will be expanded to the directory relative to
   the MegaTune installation directory.  For a "standard" install
   to C:/Program Files/, these would be:

   %MEGASQUIRT_DIR% = C:/Program Files/MegaSquirt
   %INSTALL_DIR%    = %MEGASQUIRT_DIR%/MegaTune2.25xxx
   %COMMON_DIR%     = %MEGASQUIRT_DIR%/mtCfg
   %PLUGINS_DIR%    = %MEGASQUIRT_DIR%/plugIns
   %WORKING_DIR%    = %MEGASQUIRT_DIR%/wherever you are working

   This uses the windows ShellExecute function that should open
   file folders, launch programs based upon the extension of the
   path specified, or run executables.

Build 710
   Refinements to Mini-Term: added baud rate and comm port selections
   to the dialog, wrote a help file for it.  Moved it under the
   Communications menu.

Build 709
   Added mini-terminal under Tools.

Build 707
   Rework error messages in xml reader per Lance's suggestions
   and add better version consistency checking.

Build 706
   Have AFR and thermistor calibration write actual C include files
   for use in compiling executables that are already calibrated.

   Public release of XML msq files.

Build 700
   Alpha test version: XML msq files.

   Add Matt Durys's changes to better support multi-WB installs
   on MS-II.

Build 695
   Add "File -> Activate" to MT Configurator.  Allows one to
   activate a specific file of the form "name.ini.version",
   where "version" is anything you want it to be and this
   file gets copied to "name.ini" and then is read into the
   tree as the active file.

   Fix LED designations on PM4 and PM5.

   Make scaling of port edit hysteresis values work with
   Celsius temperature values.

Build 693
   Fix size of output block in MS-II 2.3 ini file.

Build 690
   Better consistency between port editor and flash, more
   descriptive labels.

   Changed all "Send to ECU" buttons to read "Burn to ECU" to
   better reflect what they actually do.

Build 688
   Preliminary general port editor for MS-II 2.3e.

Build 683
   Added group indicators to settings in audit.log.
   Put the MS-II 2.3 release ini in the installer, delete any
   MS-II 2.3 ini older than 13 NOV 2005.

Build 674
   More stuff for MS-II 2.3 code, spare port stuff and CAN id on
   output channel fetch command.

Build 666
   Add new datalog options to allow reformatting the output and
   specifying the default extension for the output files.

      [Datalog]
         delimiter        = "\t"
         defaultExtension = "xls"

Build 663
   Have MS-II thermistor calibration check for connection first,
   clean up table labels in log file, renamed file from
   "temperature.tbl" to "thermistor.log" to indicate more clearly
   what its intended purpose is.

Build 662
   Added support for MS-II multi-board CAN stuff.  This includes
   the MS-II 2.3 ini file.

Build 656
   Finished up the common directory processing.  Here's the
   current directory tree that I build for the various program
   files.  (Revised for build 755.)

   c:/Program Files/
      MegaSquirt/
         MegaTuneV.VVbNNN/
            mtCfg/
               megatune.ini
               msns-extra.ini
               megasquirt-I.ini
               megasquirt-II.ini
         mtCommon/
            common.ini
         Firmware/
            MS-II/
         MS-II Download V.VV/
         EasyTherm/
         LogViewerV.VV/
         car1/
            mtCfg/
               settings.ini
               custom.ini


   The startup sequence for MT is as follows:

      1. Check the current directory, if it is a "car/project"
         directory, we are done, stay here, skip down to 5.
      2. If we are anywhere else, chdir to the MegaSquirt install
         directory, and find all of the car/project directories.
      3. If there is only one in the list, chdir there and skip
         down to 5.
      4. Present the list to the user, allow them to select one,
         then chdir there.
      5. Open megatune.ini and process its contents.
      6. Display the front page, start communicating with MS.

   Given the above collection of directories, here's what MT does
   when it tries to open megatune.ini or any other "config" file
   (i.e., anything that has to do the startup .ini files).  Once
   MT finds a file, it skips the subsequent search steps.

      1. Look for the file in the selected car/project
         directory's mtCfg subdirectory.
      2. Look for the file in the selected car/project directory.
         (OBSOLETE, don't put files here, put them in the mtCfg.)
      3. Look in the MegaSquirt/mtCommon directory.
      4. Look in the MegaSquirt/MegaTuneV.VVbNNN/mtCfg directory.

   That third one is the new addition, it is completely
   transparent and will not cause anything to change (just as
   number 2 should be unused).

   So, typical reading goes as follows:

      1. megatune.ini is found in MegaSquirt/MegaTuneV.VVbNNN/mtCfg,
         it contains a line like
            #include "settings.ini"
      2. The include is processed and settings.ini is found in
         MegaSquirt/car1/mtCfg.
      3. Once settings.ini is read, it is closed an megatune.ini
         processing continues, you'll then get to
            #include "msns-extra.ini"
         or whatever you've got selected in settings.ini.
      4. This will be found wherever it lives and so on...
      5. Finally, we get all that including and stuff done (all
         of which is logged in audit.log) and we process
         custom.ini.

   Now, assume that you want to make a set of common gauges for several cars/projects. You'd do something like this:

   c:/Program Files/
      MegaSquirt/
         mtCommon/
            extraGauges.ini
         car1/
            mtCfg/
               settings.ini
               custom.ini
         car2/
            mtCfg/
               settings.ini
               custom.ini

   Create "extraGauges.ini" in the mtCommon directory, change
   all of your custom.ini files to contain
      '#include "extraGauges.ini"'
   and remove all gauge definitions from those same files.

Build 655
   DELETE THIS BUILD IF YOU HAVE IT INSTALLED, IT DOESN'T WORK.

   Added another directory to the configuration file search path,
   so that users with multiple cars can write common files for
   their projects that are not mangled by the installation of a
   new build.  The path is now:

      1) ./mtCfg/file
      2) ./file
      3) c:/Program Files/MegaSquirt/mtCommon/file
      4) c:/Program Files/MegaSquirt/MegaTuneN.NN/mtCfg/file

   where "." is the project directory and "c:/Prog..." is the
   installation area.

   Fix up ini file reading so that you can re-specify table
   editor entries so as to change things like gridOrient in the
   custom.ini file, after they have been defined.

Build 654
   Output a final status on burst logging.  Add "initialDeltaT"
   to ini file on BurstMode block, so that if you know how fast
   your logs were run, you can get the early clock values closer.

Build 631
   Re-fix alternating pattern stuff.

Build 627
   Fix handling of non-square tables.

   Add corrected AutoTune block to custom.ini.

Build 623
   Fixed bug in injector control dialog that didn't detect
   invalid alternating combinations.

Build 620
   Moved "gridOrient" from [Tuning] to table editor entries,
   so each editor has its own unique orientation settings.

Build 619
   Refined auto-tune algorithm, changed defaults to more safe
   values.  It produces many more diagnostic messages now, too.

Build 615
   Implemented interface to auto-tune parameters in ini files.

Build 614
   Added preliminary auto-tune feature to the 3D tuning dialog.
   You must add "allowAutoTune = on" to the proper TableEditor
   definition, which then shows the auto-tune check box on the
   tuning dialog.  All control parameters are hardcoded at this
   point, they will be published in a future release.

Build 612
   File->Msq info...  Reports MegaTune file version number and
   file signature for all msq files that MT can find.

   Added more MS-II ini files.

Build 602
   Added DynoJet Wideband Commander support to lambdaSensor.ini
   and code for MS-II.

Build 596
   Default ini file for MS-II is for C64 v2.0g code.

Build 587
   MAKE SURE TO MANUALLY COPY settings.ini from MegaTune/carMtCfg/
   and place it in your car1/mtCfg directory.  The definitions in
   settings.ini have been reworked quite a bit.  The old names
   and new names are in the table below:

      DIY_TechE_NonL          DIYWB_NON_LINEAR
      FIDLE                   FIDLE_GAUGE
      GM300KPa                DELETED (identical to MPXH6300A)
      IAC                     IAC_GAUGE
      Innovate0_5             INNOVATE_0_5_LINEAR
      Innovate1_2             INNOVATE_1_2_LINEAR
      MSpark                  DELETED
      PWM                     PWM_GAUGE
      TechEdge_Lin            TECHEDGE_LINEAR
      WB_NB_EMULATOR          WB_1_0_LINEAR
      WB_Non_Above            WB_UNKNOWN
      Zeit_100                ZEITRONIX_NON_LINEAR

Build 554 - Fix "Rate" units on Acceleration Wizard to reflect
            the correct units of the data rather than have the
            "v/s" hard coded.

            Add IAC scale to MS-II ini, requires version 1.31.


Build 545 - Add proper field definitions for AE taper to MS-II
            configuration so it actually works.

            Add AEM sensors to settings.ini and lambdaSensors.ini
            for MS-I.  Added AEM non-linear to MS-II configuration
            tool.

Build 543 - Add acceleration enrichment tail-off tapering to AE
            Wizard.  This is implemented in MS-II as of version
            1.3 of the MS-II code.

            Fix MS-II Flood Clear value's units.

Build 541 - Add real GM 3-BAR info to MS-II ini file.

            Rework MS-II TPS calibration, requires MS-II code be
            upgraded to 1.30 or later.  The included megasquirt-II.ini
            is for 1.30.

            Fixed minor bug in Communications Settings dialog,
            which would display the old Timer Interval even after
            you had actually changed it.

Build 531 - Fix MAP bin range to allow 300 and 400 kPa sensors on
            MS-II.

            Add "Rename" to MT configurator.

            Fix MS-II TPS calibration scheme.

Build 514 - Write correct page numbers to VEX files.

            Correct use of lambdaSensors.inc in some cases; fix a
            bug in the file itself.

Build 484 - Enable  MS-II alpha-N options, clean up lambda
            sensor definitions.

Build 462 - Fix bug in VEX reader that transposed indices on
            table.  This only affected non-square imports, so
            most examples still worked fine.

Build 447 - Use DEFAULT_CHARSET instead of ANSI_CHARSET so that
            Cyrillic and other characters are displayed properly
            in gauges and dialogs.

Build 443 - MS-II datalogging enhancements: turned spare1 and
            spare2 into dtPred error and deltaT, adding them to
            the log.

Build 442 - Added Stewart's suggestion to increment/decrement 3D
            tuning points by bigger increment.  This is mapped to
            Ctrl-Shift-Up and Ctrl-Shift-Down arrow keys, which
            increment by 5 internal units while the Shift-Up and
            Shift-Down still increment by 1 unit.

Build 441 - Add Zenon's "Review" mode under Tools.

Build 421 - Add comm status output to burst mode dialog.

Build 420 - Fix memory overwrite with Tuning->Runtime dialog.
            Added Project->X options to MT Configurator.

Build 417 - Units wrong on MS-II TPSdot values (affect AE wizard values).
            AE wizard dialog occasionally didn't appear when commanded.
            Added #group and #ungroup to ini parser, ignored by MT.
            Proto-MT Configurator included in release.

Bug Fixes
---------
More infrastructure rework with all edit dialogs.
Better error recovery from mismatches in the signature contained
in the ini file and reported by the embedded code.

William Turner pointed out that the Warmup Wizard could leave
incorrect values of 99 or 101 in the 160F bin under certain
conditions.

Jerome Lambourne found a very serious problem with the VEX reader,
it turned out to be two things: 1) the VEX Import command was
writing the VEX file over the original as soon as it was read
(this looks like it has been there forever, a stupid cut'n'paste
bug when I first did the export); 2) in certain cases, MT's path
search routines were doubling up the directory name, so it would
try to open something like this:

   c:\dir\c:\dir\file.vex

which, of course, failed.  These two bugs by themselves would
have been fairly benign, but combined they actually overwrote
the original file with an empty one, so this was pretty nasty!

Enhancements
------------
Lance's VE Table Estimator has been incorporated under the Tools
menu, it has a little different interface than the version on
his website, but it should be fairly obvious what you need to
do and experimentation should clear up it's behavior.

There is a new datalogging "burst mode" to support Johan Grahn's
Palm logging software.  When in burst mode, MegaTune ignores the
comm settings, and uses ones from the init files.  By default,
burst mode uses 115,200 baud and the same comm port as was set
for talking to MegaSquirt, but these can be overridden with the
values in settings.ini.  The time delay between frames is always
zero in burst mode.  Johan has tested this to read logs at about
30 lines/second, which I find to be somewhat slower than I expected
but it's a starting point.

Burst mode basically does three things:

1) Turns on datalogging (using the User-Defined format, which
   has become the only format in 2.25 at this point).

2) Changes the delay between frames to zero.

3) Raises the comm rate to 115200 baud.

It also suppresses sending extraneous "what version are you"
type of messages, so that the connected device (the palm pilot)
does not have to deal with them.

By default, it uses the same comm port that is specified for normal
MS operations, but that is settable in the .ini file (likewise the
baud rate can be changed there, too).

Right now, the main event loop is still in operation during burst
mode, so all the gauges are updated, the menus are still alive and
all sorts of non-productive processing is going on during the burst.
I've got a note in my to-do list to make a burst mode dialog that
would merely have a status line, "3840 records received..." along
with "Done" and "Abort" buttons.  This would probably make throughput
about 4 times faster (mostly due to no gauge updates), and would
give some assurance that things were cranking along at a decent clip.

There is one caveat to logs created with burst mode, the "Time"
column is totally useless, in that it reflects real time during
download, not during recording (which, of course, must be the case
since Time is a MegaTune thing and not MS).


Multi-Car File Management
-------------------------
I finally got around to creating a real installer and defining a
standard file structure for MegaTune installations.  It looks like
this, if you don't change any of the defaults:

   C:\Program Files\
      MegaSquirt\
         MegaTune VERSION\
            exec and help files
            mtCfg\ default init files
         car1\
            log and msq files go here
            mtCfg\

Shortcuts and menus start up MegaTune in the "MegaSquirt" directory,
and MT then looks around for "*\mtCfg".  If it finds just one, it
works there, so in the above default directory tree, you'd start
up MT and see that you were in the "car1" directory.  Now if you
add peer directories to "car1", and put an "mtCfg" subdirectory
in them, then when MT starts up, it will present you with a list
of th directories found, allow you to select one, then run there.

You can rename "car1" to be anything you want, the actual names
are un-important, the structure is what is important.  In fact,
you could actually move the startup directory somewhere else
if you like and things will work just fine, as long as you modify
the "Start in" setting on all shortcuts and menus.

Here's an alternative example, for those of you who want to
separate your programs and data.
   C:\Program Files\
      MegaSquirt\
         MegaTune VERSION\
            exec and help files
            mtCfg\ default init files
   C:\users\
      eric\
         cars\
            MaxQ\
               mtCfg\
                  dual table mods in "settings.ini"
                  dual table mods in "custom.ini"
                  Bosch clt.inc
                  GM mat.inc
            Scirocco\
               mtCfg\
                  standard settings in "settings.ini"
                  empty "custom.ini"
                  different Bosch clt.inc
                  some Bosch mat.inc

After I set my shortcuts to start in "C:\users\eric\cars", I
see both MaxQ and Scirocco in my startup list.

Want to see more details on what's going on?  Look for a file
named "audit.log" in your startup directory after you've exited
MegaTune.  It will contain all sorts of useful information relating
to the processing of the initialization files, and is extremely
useful for debugging your init files.

General Init File
-----------------
Two new files, settings.ini and custom.ini, are installed
in the car-specific directories, and are intended to hold
any modifications specific to that MegaSquirt installation.
If you look in settings.ini you will see where metric temperature
reporting (Celsius) is enabled, among other things.  If you
wish to redefine gauge settings specifically for one vehicle,
then you would do that in custom.ini.  For changes that you
wish to be global to all vehicles, modify the base megatune.ini
file.

Added "#include" to ini file reader, so you can better organize
your changes.  In use it looks like this:

   #include "gaugeColors.ini"

where the content of the file gaugeColors.ini would be anything
that is valid in the megatune.ini file.

Simple conditionals allow you have a global setting that changes
many smaller specific things.  Look for "CELSIUS" in megatune.ini
for an example.  Generally, you do this:

   #set   THIS
   #unset THAT
   #if THIS
      whatever...
   #elif TOTHER ; As many "elif" clauses as you want.
      more stuff...
   #else
      something else.
   #endif

You can use "set" and "unset" to toggle a setting back and
forth; the "elif" and "else" parts of the "if" are strictly
optional.  A negation of the "if" is possible, using "ifnot"
as follows:

   #ifnot SPEED_DENSITY
      #error "Alpha-N is not implemented by the MSnLaserBeam variant."
      #exit
   #endif

Additionally, for debugging purposes, there is a logging feature
that allows you to write a string to the audit log:

   #log "This text goes to the audit log."

will add a line to audit.log prefixed by the current file name
and the line number on which the "log" directive was found.

And finally, to round out the directives, you can generate error
messages when things go wrong.  The string after the "#error"
directive is sent displayed in an alert box and also logged in
the audit file; the "#exit" directive terminates megatune
immediately.

   #if BLAH
      ...
   #else
      #error "BLAH was unset, killing MegaTune"
      #exit
   #endif

User-Defined Dialogs
--------------------
This capability has been completely reworked.  You can now define
up to 30 dialog boxes with 20 edit fields each.  If you supply more
too many of either, those extra entries will be silently ignored.
You now must define the menu entry and dialog box title.  The field
entries allow for constant scaling and translation of the values so
that the "database" value can be in arbitrary units and then will
be converted to user units for display and editing; each has its
own scale, translate and limit values.  Additionally, you may
specify the number of digits to display in each field.

You may now also edit bit fields from 1 to 8 bits long.  The entry
for the bit field editing contains the field lable, a location spec,
and a list of values to be used to display the bit settings.

The order of definition determines the order of display, for both
dialogs and fields.

[UserDefined]
   ;----------------------------------------------------------------------------
   ; dialog = "menu entry", "dialog title", pageNumber
   ;    field = "field label", offset-in-constants, scale, translate, lo, hi, digits
   ;    field = "field label", location, "value 1", "value 2",...
   ;
   ; The scaling and translation values are used as follows:
   ;    msValue   = (userValue - translate) / scale
   ;    userValue = msValue * scale + translate
   ;
   ; The page number of the dialog sets the current page upon which
   ; all data in the dialog are located.  If you are using a single
   ; page embedded code, like B&G MS-I, then don't enter any value.
   ; See dual-table.ini for how it is used in a multi-page code.
   ;
   ; I've got no good way to handle a few of these things yet.
   ;
   ; Temperatures are fine, check out the Fielding IAC example.
   ;
   ; The TPS stuff is a problem, because we have to modify the ini file
   ; for each TPS installation and again whenever we move the TPS...
   ;----------------------------------------------------------------------------

   dialog = "-" ; Using just a dash creates a divider in the "Settings" menu.

   dialog = "&Idle Control", "Fielding 2-Wire Idle Control", 1
      ; Here's the layout for bit-edit comboboxes.  You need to supply
      ; the correct number of labels matching the number of bits you've
      ; specified: one bit requires 2 values, two bits requires 4 values
      ; and so on.  Bits are numbered 0-7, the rightmost being bit zero
      ; (this corresponds to the bit editing instructions in Motorola's
      ; CPUs, but may be different in other manufacturer's processors).

      ;       "field label",  ofs[loBit:hiBit], "n-labels"
      field = "Algorithm",    118[4:4],         "B&G On-Off", "Fielding PWM"

      ; The next field definition provides an example where we translate
      ; from MS's internal units of raw ADC count for TPS into throttle
      ; position percentage.  To calculate the scale and translate values
      ; from ADC, use:
      ;
      ;    low       = lowest display value
      ;    high      = highest display value
      ;    scale     = (high-low)/(max-min)
      ;    translate = low-min
      ;
      ; So for my installation with TPS ADC values of 26 at idle and 225 at
      ; WOT, I calculate the values you see above as:
      ;    scale     = (100-0)/(225-26) = 0.502
      ;    translate = 0-26

      ; Here's the layout for scalar-edit fields:
      ;       "field label",             ofs, scale,  tra,  lo,  hi, digits
      field = "Throttle Threshold (%)",  127,0.502, -26.0, 0.0, 255, 1

   #if CELSIUS
      field = "Fast Idle Temp (C)",     121,0.555, -72.0, -40, 102, 1
   #else
      field = "Fast Idle Temp (F)",     121,  1.0, -40.0, -40, 215, 0
   #endif

Configurable Data Mapping
-------------------------
The new [Constants] block allows you to configure how memory is
stored on the controller.  You may specify the size of each page,
how it is read, how it is written and how it is made permanent
(burned) on the controller.

   [Constants] ; Dual table definitions.
      nPages          = 2
      burnCommand     = "B"
      pageSize        = 128,          128
      pageActivate    = "",           ""
      pageReadCommand = "P\000V",     "P\001V"
      pageValueWrite  = "P\000W%o%v", "P\001W%o%v"

??? FORMATS

User Defined 3D Tuning Dialog
-----------------------------
The tuning dialog is now user configurable.  As you add more
"table" entries, you get more buttons under the "Tuning" menu.
You can have up to 20 tuning dialogs, the order in which you
mention them is the order in which they will appear under Tuning.

??? all data are bytes! word/dword support is forthcoming. ???
??? auto switching of load from MAP to TPS is not yet supported with the switch to ALPHA-N... ???

   [TableEditor]
      table = "menu", "title", offset, scale, translate, page-number, "X-or-Y-order"
         xBins = x-offset, x-scale, x-translate, x-count, x-variable, "x units"
         yBins = y-offset, y-scale, y-translate, y-count, y-variable, "y units"

   menu   - The character string that appears under the "Tuning"
            menu.
   title  - The character string displayed at the top of the
            dialog box.
   offset - The memory offset in the page at which the table
            data begins.
   scale  - Multiplier to convert from internal value into user
            value (same as "field" in UserDefined dialogs).
   translate - Translation for internal value.  The displayed
            value is (internalValue + translate) * scale.
   page   - Page number on which all the data for this table
            appears.  The xBin and yBin data must also be stored
            in the same page.
   order  - "X" means that the data is ordered such that x changes
            with each step, as in [x1,y1] [x2,y1] [x3,y1]...  "Y"
            means that the y index changes fastest, like this
            [x1,y1] [x1,y2] [x1,y3]...

For each x and y bin specification
   offset - Offset in memory of the bin data, must be on the
            same page as the table data.
   scale  - Multiplier to convert from internal value into user
            value (same as "field" in UserDefined dialogs).
   translate - Translation for internal value.  The displayed
            value is (internalValue + translate) * scale.
   count  - Number of values in this bin (and thereby this
            dimension of the table).
   variable - Name of the variable that is interpolated into
            this bin.
   units  - String name of the variable as you want it displayed
            in various places in the tuning dialog.

Here's an example extracted from the megasquirt-I.ini file, see
dual-table.ini for a multi-page example.

   [TableEditor]
      table = "&VE Table", "VE Table", 0, 1.0, 0.0, 1, "X"
         xBins = 100, 100.0, 0.0, 8, rpm, "RPM"
         yBins = 108,   1.0, 0.0, 8, map, "MAP"

User-Configurable Datalogging
-----------------------------
Datalogging is user configurable.  See the [Datalog] block in
the megatune.ini file for full details.  All those variables
that became available in release 2.20 are now allowed in the
definition of datalog entries, so anything you can measure you
can log.

The user-defined datalog recording is invoked via the menus,
or by the Alt-L shortcut; the default log file name now is
suffixed with an ISO-8601 standard date, so each file name
is unique without any user input.  Now rather than the rather
painful menu navigation to begin datalogging, you can simply
type Alt-L and Enter.

Datalog "marking" as suggested by Al Mitchell and refined a bit
by Mike Soultanian, is implemented on the runtime screens (any
thing with a gauge).  If you have a datalog running and you hit
the spacebar, then a "MARK NNN manual datestamp" is written to
the datalog and a beep is generated to verify that the mark was
made.  This can help you later pinpoint when a stumble or other
notable event occurs.  Log mark date stamps are also written in
ISO-8601 standard format.

There is an "auto mark" feature, enabled by setting a variable
reference in the "markOnTrue" property in the Datalog section of
the ini file.  Create a variable with a boolean value (0 means
false, anything else is true), then reference it like this:

   [OutputChannels]
      highLoad    = { rpm >= 3500 && throttle >= 50 }
   [Datalog]
      markOnTrue  = highLoad

The variable "highLoad" in this example changes from false to
true as the rpm and throttle change, whenever it makes a transition
from false to true, a datalog mark will be written and tagged with
the variable name to distinguish it from "manual" datalog marks.
(Processor resets generate an automatic mark, labelled "RESET n",
where n is the sequence number of the reset.)

Another Datalog property, "enableWrite", allows you to suppress
datalogging with a similar scheme.  Create another variable
that defines the conditions under which you'd like to record
datalogs and then reference it as follows:

   [OutputChannels]
      logging     = { rpm >= 2000 }
   [Datalog]
      enableWrite = logging

Beta build 334 or later -----------------------------------------

Bit spec has been augmented with an offset:

   nCylinders = bits,   U08,     116, [4:7+1]

This creates auto-labels that are sequenced "1", "2" and so
on.  The user values correspond to the auto-labels, but the
internal value will be 0...15 for the above value.


V 2.20 - 11 FEB 2004 ============================================
=================================================================

The biggest change in this release is in gauge functionality.
You can now map any gauge to any position on either of the front
or tuning pages.  Full details are too numerous to list here,
dig through the megatune.ini and find everything you want to
know.  You DO NOT need to know any of this to make MegaTune
work, but if you want to modify the interface, check it out.
(If you are writing your own embedded code, you really will
want to take a look at this, since you can now map those
blank spots to custom gauges.)

Backward compatibility of old gauge definitions in the tuning
section of megatune.ini was sacrificed for this release.  If
you had changed the default configuration for those gauges,
they will no longer have any effect.  The front page gauges
had fewer changes, so old gauge definitions still work for
them, but I'd still recommend using the new much more flexible
definitions (I'll probably ditch backward compatibility mode
sometime in the future, so be prepared).

Added another of Marc Piccioni's ideas: the log file now allows
user defined comments in the header.  You will find a new options
dialog accessible under File->Datalogging->Options..., which will
let you enter text to be placed at the top of the file and allows
you to toggle the writing of a full database dump at the head and
tail of the datalog.  The dump has the same format as Tools->Dump,
and records the current state of all the constants and tables at
that point in time, so if you do any tuning while the datalog is
being recorded, those changes will be evident as differences in
the two dumps.

WARNING!  Adding comments or dump output to the log files will
cause them to be unreadable by older versions of MST3K and MSLVV.
If you have problems, just edit the log file and delete all the
lines starting with quotation marks, as these will be the ones
that contain the comments.

I completely reworked the VE table contour plot, it is now resizable
and the color selection algorithm was re-written from scratch.  The
colors are now much more smoothly across the range, and they scale
from blue at the minimum VE to red at the maximum value, rather
than being fixed with blue = 0% and red = 255%.

Gauge aesthetics were another major focus of this release: the fonts,
colors and just about everything was massaged for a more pleasing
look.  I considered antialiasing the drawing routines, but decided
against it as the CPU load would be quite heavy and there are no
good fast libraries for our old win95 and win98 machines, so we'll
just have to live with zig-zags on the lines...

Added "faceColor = 255,255,255" to megatune.ini for default gauge
face color of white.  Note that the warning and danger colors are
xored with the base color, so they might seem incorrect unless you
know this.

The VE Table dialog has been "flipped" such that the low load
bins (MAP in speed-density mode and throttle position in
Alpha-N mode) are at the bottom of the screen and the high
values are at the top.  This is to make it correspond with
the VE plots and tuning screen.

Read through the megatune.ini file to see if there is anything
you wish to customize.  In particular, the AFR gauge can be
enabled and you'll probably want to select the proper include
file to make it work (NBafr100.inc for narrow band sensors and
WBafr100.inc for wideband).

V 2.16 - 04 JAN 2004 ============================================
=================================================================
This version has been tested with Mike Robert's MegaSquirt
Logfile Visual Viewer (MSLVV) version 2.16 (Mike has changed
his versioning scheme to jive with MT so as to make it easier
to know what works where).  See the files section of the
MegaSquirt yahoo group for the release code.

Bug Fixes
---------
Add Ben Stembridge's fix for the blurry gauges.

Fix rounding of TPS percentages in VE table and elsewhere.

Fix bug in Require Fuel calculator where nCylinders is garbage.

Lance Gardiner uncovered a bug in the Enrichments dialog that
mangled the O2 sensor settings.  If you started MT and displayed
the Enrichments screen before connecting to the MS, then the O2
sensor type (and Alpha-N) settings would be mangled.  All fixed
now.

Enhancements
------------
Two major enhancements appear in this release.

First, I merged in Steve Herz and Marc Piccioni's Warmup Wizard
from their MegaTuneCS variant, try it, you'll like it.  Find it
under Runtime -> Warmup Wizard; hit F1 for context sensitive help.

Second, there is now a user-defined dialog box that appears
in the Settings menu.  This is a very crude mechanism that allows
you to edit data anywhere in flashed ram by customizing the
contents of the megatune.ini file.  See that file and read
the help (hit F1 while displaying the dialog) for full details.
(Thanks to MiseryQ and Mike Soultanian for their testing of this
feature.)

IMPORTANT NOTE FOR USER-DEFINED DIALOG USERS!
---------------------------------------------
The standard code's V command only sends back 125 bytes, so MegaTune
will never show those last three values properly unless you change
the SCI routines.  Dave Jeal wanted to see all 128, so he changed
this part of the embedded code:

MODE_V:
        clr     txcnt
        lda     #$03
        sta     txmode
        lda     #$7E    <==== MAKE THIS #$81

I then made MT handle this as a general case (a couple releases back).
I suggest you make this change in your code, or you'll only ever
see garbage coming back into the user-defined dialog fields for
your extended variables.  (Sending the values to MS works fine,
only fetching them fails.)


A host of minor enhancements were included.

The serial data rate is now configurable via the communications
settings dialog, with allowed speeds of 9600 (default), 19,200
and 38,400 BPS.  UNLESS YOU HAVE MODIFIED YOUR EMBEDDED CODE TO
TAKE ADVANTAGE OF THIS, DO NOT DO NOT DO NOT CHANGE IT FROM 9600!
Mike Robert has tested this out in his code and it seems to work
for him, so if you need faster comm for higher resolution datalogs
or whatever, seek him out.  Did I say DO NOT CHANGE FROM 9600
without knowing what you are doing?

MT now allows gauge/meter values to be reversed, so as to
accomodate WB O2 interfaces that have rich at low voltage and
lean at high.  See megatune.ini for details.

The temperature scale setting in megatune.ini was previously
case sensitive, only upper case values were valid.  MT now
ignores case for these values so 'C' is the same as 'c'.

I added Per Andersen's colored indicators to the runtime
dialog's status bar.

Mike Robert requested that the "full" datalog get five new
columns to the far right.  These contain the two duty cycle
values, corresponding to PW1 and PW2, and the three raw data
values stored in the "blanks spots" of the runtime variables,
so if you are experimenting with the embedded code and want to
datalog some values, just write them into those last locations
and they will be logged.  Mike's Log View version 1.4 and later
supports display of these values.

Eric Aston's suggestion regarding locating the tuning spot and
cursor has been implemented in 3D tuning.  You now have optional
vertical and horizontal indicator lines for the two objects as
they move about the grid.

Several gauges now show telltale values, that is, the highest
reading of the gauge leaves a ghost image at that position.
This is behavior is currently hard coded, so you cannot modify
which gauges have telltales, or turn them off altogether, but
I'll probably put this in the megatune.ini file sometime.

Gauge behavior has changed a bit.  The old "redline LED" is gone,
replaced by a change in the background color for the whole gauge.
I never did like those little LEDs, as they were hard to see; the
new background color change is very obvious.  The colors used
for warning and danger are accessible in the megatune.ini file
as follows:

   backgroundColor = 202, 202, 202 ; Normal.
   bgWarningColor  = 255, 255, 190 ; Warning (light yellow).
   bgDangerColor   = 255, 160, 160 ; Danger (light red).

The limits for each gauge are set using a new form of the gauge
limit entries in megatune.ini.  The old form (which still works
just fine) had three values:

   gauge = lower, upper, redline

and the new form has six:

   gauge = lower, upper, low-danger, low-warning, high-warning, high-danger

When the gauge's displayed value is below low-danger or above
high-danger, then the background color is set to the bgDangerColor;
likewise when the needle value is outside the low-warning and
high-warning limits (but still inside the danger limits), the
background color is set to the warning color.  The old style
is interpreted as meaning "no warning limits, no lower danger,
upper danger = redline."

V 2.15 - 31 MAR 2003 ============================================
=================================================================
New command in Tuning suggested by Mike Lough, the "GO TO" mode command.
Type G to toggle it on or off.  When in "GO TO" mode, the cursor chases
the tuning spot.  Some might find this annoying, but give it a try, you
might like it.

Look in the megatune.ini, there is a new section GaugeColors, which
allows you to set every color used by the analog meters and LED bars.  I
don't suggest you change them, but if you cannot read the gauges because
colors dither or go to some wacky value due to a small color map, you'll
need to tweak them here.  NOTE: You need not add this block of values to
old megatune.ini files, as the default values are the same as they've
always been.

Likewise, down in the Tuning section of the .ini file are five new color
values for the tuning windows.  You can set all of the colors for the
cursor, spot, grid and so on.  A final value, gridOrient, allows you to
set the space-based 123 euler angles for orienting the 3D grid in its
perspective view (use the N and M keys to find something you like, then
copy the numbers from the status window into your .ini file).

Acceleration enrichment has two cold adjustments: the original
additive adjustment (Cold Accel Enrichment) and a new for
embedded code V2.0 code multiplier (Cold Accel Mult).  Access it
on the enrichments dialog.

V 2.14 - 26 JAN 2003 ============================================
=================================================================
Added raw datalog, all values are stored without transformation.
Notice that the sensor values are all in raw ADC counts, so
you'll have to pump most numbers through the appropriate transfer
function to make sense of them.

Dual table stuff: VE and PW are now page specific on the runtime
dialog.  Pop it up and type alt-1 and alt-2 to see it work.

The VE grid is now displayed as a 3D surface plot in the Tuning
dialog.  You can toggle between the surfact plot and the flat
view by pressing the 'Z' key repeatedly.  Note that the flat view
has been flipped such that low MAP values are at the bottom.  The
navigation keys have been reversed to work more intuitively with
the flipped view, up raises MAP, down lowers it (left still
lowers RPM and right raises it).  As a nice side effect, the
reworked plotting code eliminates the phantom dot and cursor that
arose occasionally with the previous implementation.

Prof.  Matthias Lindner pointed out a bunch of bugs with the
gauge and LED bar settings, MAT on front page had its lower bound
set to the MAP gauge's lower bound, the LED bars didn't pay very
much attention to the minimum value at all...  This is all fixed
now.

Matthias also suggested the color of the messages on the tuning
screen key into the cursor and the spot, so now they do.  The
cursor is red and so is the text which reports its position;
likewise for the spot and its new text values.

Someone tried to set deceleration enrichment above 100% and found
that MT limited this to the range 1-100%.  I've changed the range
to 0-200%, which should satisfy anyone.


V 2.13 - 09 NOV 2002 ============================================
=================================================================
Default gauge on tuning screen is now EGO correction, since this
is the most used number (by me, at least) while tuning.

Command line read of .msq files, just double click on one then
set the application to be MegaTune.exe.

Alt-V for VE table.

When a VEX or msq file is read, you are asked if you want to
download it to the MegaSquirt and burn the contents to FLASH RAM.

There are two datalog formats now, the "classic" format to
accomodate MST3k, and a full log with real time, and VE with
pulse width for both injector drivers.

A new entry in the megatune.ini file allows you to set the
default controller code version for off-line editing.
Previously, MT assumed 1.0 unless it was connected to a running
MS, so you could not modify any of the v2 or dual table options.
The new default is v2, set it to 0.1 for dual table code.

V 2.12 - 10 SEP 2002 ============================================
=================================================================
VEX Import had a bug which transposed the table values on input,
all fixed now and ready to rock with MST3k.

VE Table scaling can be accomplished by either clicking the
button on VE Table dialog or using the VE Scale command from the
Tools menu.  Enter a pair of actual ReqFuel values and the table
is scaled correctly, or just make up a couple of numbers that
scale it as you like.

V 2.11 - 04 SEP 2002 ============================================
=================================================================
Alpha N bug fix: MS uses raw ADC values internally, but MT uses
percentage values through out.  MT was not consistent, and sent
percentages to MS occasionally, screwing things up greatly.
Should be all fixed now.

Likewise, duty cycle had some problems that lingered, but should
be better now when more than one squirt per cycle is used.

Go to the tuning screen and look at the bottom of the screen.
There are now three sets of gauges available for display in the
lower right of the gauge panel: enrichments, pulse width for bank
one, or pulse width for bank two.

MT now has better support for different MAT and CT sensors.
Previous versions used the table in thermfactor.inc to convert
the raw ADC counts to temperature for display on the real time
display screen.  If you used thermistors with the same curves for
both, then things worked fine, but if you used, say, a GM MAT
sensor and a Bosch CTS, then your MAT values were probably
displayed way off (this in no way affected operation inside MS,
as it doesn't ever use actual MAT, just the density factor from
airdenfactor.inc).  You can now create a file named matfactor.inc
and put it in the same directory with thermfactor.inc and have
different thermistors with correctly displayed temperatures.  You
can use gentherm2 v 2.3 to generate a matfactor.inc directly, or
if you have a correct thermfactor.inc, just rename it
matfactor.inc and put it in the proper directory.

New key mappings
  Alt-C gone, replaced with Alt-S
  Ctrl-S saves
  F in tuning screen "finds" the intersection nearest the spot.

EGO LEDs on front page and tuning screen.  Driven from the
settings in the megatune.ini file, where there is better
documentation.

V 2.10 - 03 AUG 2002 ============================================
=================================================================
Lots of new stuff in 2.10, here's the list.

Installation
------------
Installation has changed, the mtCfg directory is the preferred
location for all the .inc, .ini and .cfg files.  The old location
(where megatune.exe resides) will still work, but if you create
the mtCfg directory  you can keep your installation cleaner.

Bug Fix
-------
All previous versions with meters on the front page have
consumed system resources without releasing them.  This would
ultimately cause the machine to either lock up or crash.  All
fixed in 2.10, thanks to Guy Hill for pointing this out to me.

Dual Table Mode Support
-----------------------
Speaking of Guy, this version supports dual table mode, which is
available in his highly modified controller code.  Dual table
mode controls the two injector drivers on MS completely
independent of one another.  This allows you to use one driver
for fuel injectors, and the other, say, for water injection (or
anything else you can dream up).  When you are using dual table
mode, you change the "page" that you are working on by either
clicking the spin control on the front page or by typing alt-1
and alt-2.  The page upon which you are working is not obvious
(I'm working on this), so pay attention to that little box on the
bottom of the front page.

Table Editor/Memory Viewer
--------------------------
The new table editor (on the Tools menu) allows you to edit the
raw memory inside your controller.  Make sure you know what you
are doing before you change anything here.  Those of you hacking
the assembler code will find this invaluable, because you can get
to every byte accessible to MT, including those unused bytes at
the end of the controller RAM.

The memory viewer is a read-only version of the table editor.  It
allows you to view any memory location in the controller, but is
only available with Guy's dual table code.  If you turn on
realtime updating, and set the base address to $0100, you can
watch the stack grow and shrink at the top end of the page.

Communications Logging
----------------------
The communications menu shows a new communcation logging
facility.  This dumps out all data communicated with MegaSquirt
into a text file named comm.log in the MT working directory.
This file shows all data as hex bytes, except for the command
character sent from MT to MS, which is shown in ASCII.

Hot Keys
--------
There are finally hot keys for navigating the commonly used
dialogs and functions.  Note that these are global hot keys, so
when you invoke one it doesn't matter what is going on, that hot
key jumps into action (so, if you are in the middle of the tuning
screen and need to change enrichments, type Alt-E and change
them, without leaving the tuning screen).  The keys are as
follows:

   Alt-1 - switch to page one in dual page mode.
   Alt-2 - switch to page two in dual page mode.
   Alt-C - pop up the constants dialog.
   Alt-E - pop up the enrichment dialog.

One peculiarity of this is that the Close button on all the
dialogs can no longer be invoked by Alt-C, since this now pops up
the constants dialog.

VE Table Exchange
-----------------
Darren Clark has come up with a standard called VEX for exchanging
VE information between various programs and has implemented it as
the file format for his MSTweak3000 (aka MST3K).  I've added a
like import and export facility in MT (and published the C++
objects as utlities), see VEX import and VEX export under the
File menu.  Go to the yahoo site and search for VEX and EVEME,
then look in the files section for some other goodies.

Dump
----
The dump command has been moved from the File menu to Tools.

Throttle Factor Table
---------------------
A generator for throttlefactor.inc can be found under the Tools
menu.  Either type in the raw ADC counts corresponding to closed
and full open throttle, or sit in the car, and use the "get"
buttons while holding the pedal in the proper position.  It
couldn't be easier, could it?  This is a .inc file, so adheres to
the rules for other .inc file with respect to location (read the
first entry for this release).

V 2.00 - 16 JUN 2002 ============================================
=================================================================
Enrichment window now 640x480 compatible.

Controller resets are reported with a Bing! and setting the
connected status bar entry to "RESET n" where n is the number of
resets detected since startup.

Barometric correction can now be disabled (v 2.0 controller code
only).  The toggle is on the constants page.

V 2.00beta - 07 JUN 2002 ============================================
=================================================================
Second beta fixes V2 detection, reduces biggest windows to 640x480.

The two major inputs are displayed in the first two gauges on the
front panel.  RPM is always displayed, and either MAP (in the case
of speed-density) or throttle position (in the case of alpha-N) is
next.

Updating of gauge values is much improved, and the type of gauge
should always reflect the metering algorithm.

The TPS values have all been changed to Throttle %, and the runtime
value is translated with a TPS->TP transfer function now.  This
function is defined in an include file with the same form as a the
other .inc files, and is read from throttlefactor.inc.  If this
file is not found, the map from ADC counts of 0-255 are mapped to
0-255 percent throttle values.  (Guy Hill's alpha-N version of the
controller code utilizes this file, allowing you to work in
engineering units rather than voltages or raw ADC counts.)

The non-sticking O2 switching voltage is fixed.

V 1.61 - 14 MAY 2002 ============================================
=================================================================
All constants are fully initialized, so you get a reasonable
starting point without downloading from the controller.

There are now two algorithms for injection control: the original
speed density (MAP-based load) and a new alpha-N (TPS-based)
system.  Alpha-N is only implemented in the v.2.0 and later
controller codes, and the setting will have no effect in versions
older than that.

The version 2.0 code also allows setting of EGO sensor
parameters, namely EGO type (traditional 0-1v narrow band or wide
band).  Once you've specified the sensor type, you should also
set the switch point for the sensor (0.5 v for nB and 2.5 for
DIY-WB; other WB sensors may have different switch points).

The datalog has moved from the tuning screen and is now under the
file menu!  Once enabled, datalogging occurs as long as MT is
displaying the top window, the runtime window or the tuning
window.

The comm port initialization bug is fixed.

V 1.60 - 13 MAY 2002 ============================================
=================================================================
Wacky new front page.

Dump command added to File menu.  It writes out the contents of
constants array and VE table into the file MegaTune.dmp in the
directory in which MT is run.

Bug fix for constants page which zeroed out all the values on the
left side of the dialog box.

Comm verification added.

V 1.52 - 01 MAY 2002 ============================================
=================================================================
Made comm handling a lot more robust and added "connected" status
to both runtime and tuning dialogs.  Still not perfect but much
better.

Fixed bug on enrichment dialog where illegal value in 160 degree
warmup enrichment bin would lock MT into a loop.

Added duty cycle to runtime output.

V 1.51 - 22 APR 2002 ============================================
=================================================================
MSCOMM is now obsolete!  This version uses the Win95 serial port
calls, so it appears to be completely robust with respect to data
communications.  I've been running the timer interval at 50 ms,
on a 233 mHz PII laptop with Win98, and have seen zero errors
in many tens of minutes of datalogging.  If you do see errors
report them to me (efahl@adams.com) immediately!

Comm settings are auto saved, so when you change comm ports, that
port value is written to the megatune.cfg (which is also no
longer needed at startup, it defaults to com1 and 200 ms timer
interval).

Two new fields have been added to the Enrichments.  Both fields
are only active for version 2.0 and later of the MS controller
code, so if you want to take advantage of them, you will need to
update your MS.

The new Priming Pulse field allows you to specify the duration of
a priming pulse applied when MS is powered up.  The EGO Active
Above RPM field allows you to set the RPM below which closed loop
operation is disabled.  See the help for the enrichment dialog
for more.

Database files now store parameters from ReqFuel calculator,
notably engine displacement, injector flow and AFR.  This allows
you to see where that funny number came from.

V 1.50 - 13 APR 2002 ============================================
=================================================================
This is the first release of the modified B&G code.

Help is implemented across all dialogs, just hit F1 wherever you
want help.

At startup all of configuration tables are read from the startup
directory, so you need to select the right versions of
kpafactor.inc and barofactor.inc installed (see Installation,
above).

All commands have keyboard mappings, there is no need to ever use
the mouse.  Either type the underlined letter on the button, or
"alt-letter" and the button will be pressed just like all other
MFC-based applications.

Settings file save and load are added, the default directory is
the startup directory.  Files contain version info, allowing
future versions to do conversion.

Required fuel calculator now allows metric or English units.

Bar charting on run time screen, units added.

VE Tuning key mappings include arrows for moving cursor and
shift-up/down to scale VE.  Bar between gauges and tuning map
shows magnitude of VE.

VE Tuning screen scales properly with large fonts.

"Esc" exits anything now.  Two screens require confirmation
before editing: the VE Tuning and the top-level MegaTune dialog.
When bouncing down the road, hitting "Esc" twice will return you
to either of these two screens.
