Ejemplo n.º 1
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Presets import = new Presets(openFileDialog1.FileName, true);
                import.load();

                foreach (PresetData newPreset in import.presets)
                {
                    Util.consoleWriteLine("_IMPORTINGPRESETS", newPreset.name);

                    // If the imported preset name already exists then add the time in hex to the name
                    if (presets.presets.Find(s => s.name == newPreset.name) != null)
                    {
                        string oldName = newPreset.name;
                        newPreset.name = string.Format("{0} {1:X16}", newPreset.name, DateTime.UtcNow.Ticks);
                        Util.consoleWarning("_IMPORTALREADYEXISTS", oldName, newPreset.name);
                    }

                    presets.add(newPreset);
                }

                presets.save();
                reloadExportList();

                Util.consoleWriteLine("_IMPORTCOMPLETE");
            }
        }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Load programmers & MCUs
            loadConfig();

            // Sort alphabetically
            programmers.Sort();
            mcus.Sort();

            // Add default
            programmers.Insert(0, new Programmer("", "Select a programmer..."));
            mcus.Insert(0, new MCU("", "Select an MCU..."));

            // Set combo boxes

            cmbMCU.ValueMember   = null;
            cmbMCU.DataSource    = mcus;
            cmbMCU.DisplayMember = "fullName";

            cmbProg.ValueMember   = null;
            cmbProg.DataSource    = programmers;
            cmbProg.DisplayMember = "fullName";

            cmbFlashFormat.ValueMember   = null;
            cmbFlashFormat.DataSource    = new BindingSource(fileFormats, null);
            cmbFlashFormat.DisplayMember = "fullName";

            cmbEEPROMFormat.ValueMember   = null;
            cmbEEPROMFormat.DataSource    = new BindingSource(fileFormats, null);
            cmbEEPROMFormat.DisplayMember = "fullName";

            cmdVerbose.Items.Clear();
            for (byte i = 0; i < 5; i++)
            {
                cmdVerbose.Items.Add(i);
            }
            cmdVerbose.SelectedIndex = 0;

            // Load presets
            presets.load();
            presets.setDataSource(cmbPresets);

            // Tool tips
            ToolTip1.ReshowDelay  = 100;
            ToolTip1.UseAnimation = false;
            ToolTip1.UseFading    = false;
            ToolTip1.SetToolTip(cmbProg, "Programmer");
            ToolTip1.SetToolTip(cmbMCU, "MCU to program");
            ToolTip1.SetToolTip(cmbPort, "Set COM/LTP/USB port" + Environment.NewLine + "For LTP/USB ports you will have to type it in manually");
            ToolTip1.SetToolTip(txtBaudRate, "Port baud rate");
            ToolTip1.SetToolTip(txtBitClock, "Bit clock period (us)" + Environment.NewLine + "If you're having trouble programming with the USBasp try setting this to 32");
            ToolTip1.SetToolTip(txtFlashFile, "Hex file (.hex)" + Environment.NewLine + "You can also drag and drop files here");
            ToolTip1.SetToolTip(pFlashOp, "");
            ToolTip1.SetToolTip(txtEEPROMFile, "EEPROM file (.eep)" + Environment.NewLine + "You can also drag and drop files here");
            ToolTip1.SetToolTip(pEEPROMOp, "");
            ToolTip1.SetToolTip(cbForce, "Skip signature check");
            ToolTip1.SetToolTip(cbNoVerify, "Don't verify after writing");
            ToolTip1.SetToolTip(cbDisableFlashErase, "Don't erase flash before writing");
            ToolTip1.SetToolTip(cbEraseFlashEEPROM, "Erase both flash and EEPROM");
            ToolTip1.SetToolTip(cbDoNotWrite, "Don't write anything, used for debugging AVRDUDE");
            ToolTip1.SetToolTip(txtLFuse, "Low fuse");
            ToolTip1.SetToolTip(txtHFuse, "High fuse");
            ToolTip1.SetToolTip(txtEFuse, "Extended fuse");
            ToolTip1.SetToolTip(txtLock, "Lock bits");

            ready = true;

            updater = new UpdateCheck(this);
        }
Ejemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Load saved configuration
            Config.Prop.load();

            // Persist window location across sessions
            // Credits:
            // gl.tter
            if (Config.Prop.windowLocation != null && Config.Prop.windowLocation != new Point(0, 0))
            {
                Location = Config.Prop.windowLocation;
            }

            cmdLine = new CmdLine(this);
            avrdude = new Avrdude();
            avrsize = new Avrsize();

            avrdude.OnProcessStart  += avrdude_OnProcessStart;
            avrdude.OnProcessEnd    += avrdude_OnProcessEnd;
            avrdude.OnVersionChange += avrdude_OnVersionChange;
            avrdude.OnDetectedMCU   += avrdude_OnDetectedMCU;

            avrdude.load();
            avrsize.load();

            // Setup memory files/usage bars
            // Flash
            fileFlash              = new MemTypeFile(txtFlashFile, avrsize);
            fileFlash.sizeChanged += fileFlash_sizeChanged;
            pbFlashUsage.Width     = txtFlashFile.Width;
            pbFlashUsage.Height    = 3;
            pbFlashUsage.Location  = new Point(txtFlashFile.Location.X, txtFlashFile.Location.Y - pbFlashUsage.Height);
            pbFlashUsage.Image     = new Bitmap(pbFlashUsage.Width, pbFlashUsage.Height);
            memoryUsageBar(fileFlash, pbFlashUsage, 0);

            // EEPROM
            fileEEPROM              = new MemTypeFile(txtEEPROMFile, avrsize);
            fileEEPROM.sizeChanged += fileEEPROM_sizeChanged;
            pbEEPROMUsage.Width     = txtEEPROMFile.Width;
            pbEEPROMUsage.Height    = 3;
            pbEEPROMUsage.Location  = new Point(txtEEPROMFile.Location.X, txtEEPROMFile.Location.Y - pbEEPROMUsage.Height);
            pbEEPROMUsage.Image     = new Bitmap(pbEEPROMUsage.Width, pbEEPROMUsage.Height);
            memoryUsageBar(fileEEPROM, pbEEPROMUsage, 0);

            enableClientAreaDrag(Controls);

            // Update serial ports etc
            cmbPort.DropDown += cbPort_DropDown;

            // Drag and drop flash file
            gbFlashFile.AllowDrop  = true;
            gbFlashFile.DragEnter += event_DragEnter;
            gbFlashFile.DragDrop  += event_DragDrop;

            // Drag and drop EEPROM file
            gbEEPROMFile.AllowDrop  = true;
            gbEEPROMFile.DragEnter += event_DragEnter;
            gbEEPROMFile.DragDrop  += event_DragDrop;

            // Flash file
            openFileDialog1.Filter          = "Hex files (*.hex)|*.hex";
            openFileDialog1.Filter         += "|EEPROM files (*.eep)|*.eep";
            openFileDialog1.Filter         += "|All files (*.*)|*.*";
            openFileDialog1.CheckFileExists = false;
            openFileDialog1.FileName        = "";
            openFileDialog1.Title           = "Open flash file";

            // EEPROM file
            openFileDialog2.Filter          = "EEPROM files (*.eep)|*.eep";
            openFileDialog2.Filter         += "|Hex files (*.hex)|*.hex";
            openFileDialog2.Filter         += "|All files (*.*)|*.*";
            openFileDialog2.CheckFileExists = false;
            openFileDialog2.FileName        = "";
            openFileDialog2.Title           = "Open EEPROM file";

            // MCU & programmer combo box data source
            setComboBoxDataSource(cmbMCU, avrdude.mcus, "fullName");
            cmbMCU.SelectedIndexChanged += cmbMCU_SelectedIndexChanged;
            setComboBoxDataSource(cmbProg, avrdude.programmers, "fullName");
            cmbProg.SelectedIndexChanged += cmbProg_SelectedIndexChanged;

            // USBasp frequency settings
            cmbUSBaspFreq.Hide();
            setComboBoxDataSource(cmbUSBaspFreq, Avrdude.USBaspFreqs, "name");
            cmbUSBaspFreq.Width = txtBitClock.Width;
            cmbUSBaspFreq.Left  = txtBitClock.Left;
            cmbUSBaspFreq.Top   = txtBitClock.Top;

            // Flash & EEPROM file formats
            setComboBoxDataSource(cmbFlashFormat, Avrdude.fileFormats, "fullName");
            setComboBoxDataSource(cmbEEPROMFormat, Avrdude.fileFormats, "fullName");

            // Verbosity levels
            cmdVerbose.Items.Clear();
            for (byte i = 0; i < 5; i++)
            {
                cmdVerbose.Items.Add(i);
            }
            cmdVerbose.SelectedIndex = 0;

            // Tool tips
            ToolTips              = new ToolTip();
            ToolTips.ReshowDelay  = 100;
            ToolTips.UseAnimation = false;
            ToolTips.UseFading    = false;
            ToolTips.SetToolTip(cmbProg, "Programmer");
            ToolTips.SetToolTip(cmbMCU, "MCU to program");
            ToolTips.SetToolTip(cmbPort, "Set COM/LTP/USB port");
            ToolTips.SetToolTip(txtBaudRate, "Port baud rate");
            ToolTips.SetToolTip(txtBitClock, "Bit clock period (us)");
            ToolTips.SetToolTip(txtFlashFile, "Hex file (.hex)" + Environment.NewLine + "You can also drag and drop files here");
            ToolTips.SetToolTip(pFlashOp, "");
            ToolTips.SetToolTip(txtEEPROMFile, "EEPROM file (.eep)" + Environment.NewLine + "You can also drag and drop files here");
            ToolTips.SetToolTip(pEEPROMOp, "");
            ToolTips.SetToolTip(cbForce, "Skip signature check");
            ToolTips.SetToolTip(cbNoVerify, "Don't verify after writing");
            ToolTips.SetToolTip(cbDisableFlashErase, "Don't erase flash before writing" + Environment.NewLine + "Use this if you only want to update EEPROM");
            ToolTips.SetToolTip(cbEraseFlashEEPROM, "Erase both flash and EEPROM");
            ToolTips.SetToolTip(cbDoNotWrite, "Don't write anything, used for debugging AVRDUDE");
            ToolTips.SetToolTip(txtLFuse, "Low fuse");
            ToolTips.SetToolTip(txtHFuse, "High fuse");
            ToolTips.SetToolTip(txtEFuse, "Extended fuse");
            ToolTips.SetToolTip(txtLock, "Lock bits");
            ToolTips.SetToolTip(btnFlashGo, "Only write/read/verify flash");
            ToolTips.SetToolTip(btnEEPROMGo, "Only write/read/verify EEPROM");
            ToolTips.SetToolTip(btnWriteFuses, "Write fuses now");
            ToolTips.SetToolTip(btnWriteLock, "Write lock now");
            ToolTips.SetToolTip(btnReadFuses, "Read fuses now");
            ToolTips.SetToolTip(btnReadLock, "Read lock now");
            ToolTips.SetToolTip(cbSetFuses, "Write fuses when programming");
            ToolTips.SetToolTip(cbSetLock, "Write lock when programming");

            // Load saved presets
            presets = new Presets(this);
            presets.load();
            presets.setDataSource(cmbPresets);

            // Enable/disable tool tips based on saved config
            ToolTips.Active = Config.Prop.toolTips;

            ready = true;

            // If a preset has not been specified by the command line then use the last used preset
            // Credits:
            // Uwe Tanger (specifing preset in command line)
            // neptune (sticky presets)
            if (presetToLoad == null)
            {
                presetToLoad = Config.Prop.preset;
            }

            // Load preset
            PresetData p = presets.presets.Find(s => s.name == presetToLoad);

            cmbPresets.SelectedItem = (p != null) ? p : presets.presets.Find(s => s.name == "Default");

            // Check for updates
            UpdateCheck.check.checkNow();
        }