예제 #1
0
        public Form1()
        {
            InitializeComponent();

            var     assembly = System.Reflection.Assembly.GetExecutingAssembly();
            Version version  = assembly.GetName().Version;

            Icon = Icon.ExtractAssociatedIcon(assembly.Location);
            Text = String.Format("AVRDUDESS v{0}.{1}", version.Major, version.Minor);

            enableClientAreaDrag(Controls);

            // Update COM ports
            cmbPort.DropDown += new System.EventHandler(this.cbPort_DropDown);

            // Drag and drop
            gbFlashFile.AllowDrop  = true;
            gbFlashFile.DragEnter += new DragEventHandler(event_DragEnter);
            gbFlashFile.DragDrop  += new DragEventHandler(event_DragDrop);

            // Drag and drop
            gbEEPROMFile.AllowDrop  = true;
            gbEEPROMFile.DragEnter += new DragEventHandler(event_DragEnter);
            gbEEPROMFile.DragDrop  += new DragEventHandler(event_DragDrop);

            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";

            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";

            fileFormats.Add(new FileFormat("a", "Auto (writing only)"));
            fileFormats.Add(new FileFormat("i", "Intel Hex"));
            fileFormats.Add(new FileFormat("s", "Motorola S-record"));
            fileFormats.Add(new FileFormat("r", "Raw binary"));
            fileFormats.Add(new FileFormat("d", "Decimal (reading only)"));
            fileFormats.Add(new FileFormat("h", "Hexadecimal (reading only)"));
            fileFormats.Add(new FileFormat("b", "Binary (reading only)"));

            cmdLine      = new CmdLine(this);
            presets      = new Presets(this);
            savePreset   = new FormPresetSave(this);
            deletePreset = new FormPresetDelete(this);
            avrdude      = new Avrdude(this);
        }
예제 #2
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Presets export = new Presets(saveFileDialog1.FileName, true);

                for (int i = 0; i < clbExport.Items.Count; i++)
                {
                    if (clbExport.GetItemChecked(i))
                    {
                        PresetData p = (PresetData)clbExport.Items[i];
                        if (p != null)
                        {
                            export.add(p);
                            Util.consoleWriteLine("_EXPORTINGPRESETS", p.name);
                        }
                    }
                }

                export.save();

                Util.consoleWriteLine("_EXPORTCOMPLETE");
            }
        }
예제 #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();
        }