예제 #1
0
        private void btnWrite_Click(Object eventSender, EventArgs eventArgs)
        {
            byte   ControlValue       = 0;
            string EEPROMPhraseString = "";
            string ButtonString       = "";

            btnWrite.Enabled = false;
            Cursor           = Cursors.WaitCursor;
            Application.DoEvents();

            // Shut the SpeakJet up - just in case.
            string ProgramString = "\\0RX";

            // Calculate the Control Values for the 16 Button functions
            for (byte X = 0; X <= 15; X = (byte)(X + 1))
            {
                // Add up the Binary Bit values for each Button Control Byte
                ControlValue = Convert.ToByte(Convert.ToInt32((Convert.ToInt32(Double.Parse(txtPhrase[X].Text)) & 15).ToString()));
                if (chRestart[X].CheckState == CheckState.Unchecked)
                {
                    ControlValue = (byte)(ControlValue + 16);
                }
                if (chInt[X].CheckState == CheckState.Checked)
                {
                    ControlValue = (byte)(ControlValue + 32);
                }
                if (chClear[X].CheckState == CheckState.Unchecked)
                {
                    ControlValue = (byte)(ControlValue + 64);
                }
                if (chPlay[X].CheckState == CheckState.Unchecked)
                {
                    ControlValue = (byte)(ControlValue + 128);
                }
                // Send the Button Control Byte to the EEPROM
                ProgramString = ProgramString + "\\0";
                ProgramString = ProgramString + (X + 240).ToString() + "J";
                ProgramString = ProgramString + "32" + "H";
                ProgramString = ProgramString + Module1.dhex(ControlValue) + "N";
            }

            // Caclulate the Control Value for the Startup Phrase
            ControlValue = Convert.ToByte(Convert.ToInt32((Convert.ToInt32(Double.Parse(txtPhrase[16].Text)) & 15).ToString()));
            ControlValue = (byte)(ControlValue + 16);
            ControlValue = (byte)(ControlValue + 32);
            ControlValue = (byte)(ControlValue + 64);
            if (chPlay[16].CheckState == CheckState.Unchecked)
            {
                ControlValue = (byte)(ControlValue + 128);
            }
            // Send the Control Byte to the EEPROM
            ProgramString = ProgramString + "\\0";
            ProgramString = ProgramString + "237" + "J";
            ProgramString = ProgramString + "32" + "H";
            ProgramString = ProgramString + Module1.dhex(ControlValue) + "N";

            // Caclulate the Control Value for the PCtrl, Auto Silence, RC/TTL Mode
            ControlValue = 0;
            if (optIO[4].Checked)
            {
                ControlValue = (byte)(ControlValue + 1);
            }
            if (optIO[6].Checked)
            {
                ControlValue = (byte)(ControlValue + 2);
            }
            if (optIO[8].Checked)
            {
                ControlValue = (byte)(ControlValue + 4);
            }
            if (chAutoSil.CheckState == CheckState.Checked)
            {
                ControlValue = (byte)(ControlValue + 8);
            }
            if (optIO[0].Checked)
            {
                ControlValue = (byte)(ControlValue + 16);
            }
            if (optIO[2].Checked)
            {
                ControlValue = (byte)(ControlValue + 32);
            }
            ControlValue = (byte)(ControlValue + 64);
            ControlValue = (byte)(ControlValue + 128);
            // Send the Control Byte to the EEPROM
            ProgramString = ProgramString + "\\0";
            ProgramString = ProgramString + "238" + "J";
            ProgramString = ProgramString + "32" + "H";
            ProgramString = ProgramString + Module1.dhex(ControlValue) + "N";

            // Caclulate the Control Value for the SCP-node, POut
            ControlValue = 0;
            if (optIO[10].Checked)
            {
                ControlValue = (byte)(ControlValue + 1);
            }
            if (optIO[12].Checked)
            {
                ControlValue = (byte)(ControlValue + 2);
            }
            if (optIO[14].Checked)
            {
                ControlValue = (byte)(ControlValue + 4);
            }
            ControlValue = (byte)(ControlValue + 8);
            ControlValue = (byte)(ControlValue + ((Convert.ToInt32(txtSCPNode.Text) & 7) * 16));
            ControlValue = (byte)(ControlValue + 128);
            // Send the Control Byte to the EEPROM
            ProgramString = ProgramString + "\\0";
            ProgramString = ProgramString + "239" + "J";
            ProgramString = ProgramString + "32" + "H";
            ProgramString = ProgramString + Module1.dhex(ControlValue) + "N";

            // Do a hard reset of the chip
            ProgramString = ProgramString + "\\0W";

            // Send some pauses just to wait for the reset to finish
            ProgramString = ProgramString + Strings.Chr(Module1.cvP0).ToString() + Strings.Chr(Module1.cvP0).ToString() + Strings.Chr(Module1.cvP0).ToString() + Strings.Chr(Module1.cvP0).ToString() + Strings.Chr(Module1.cvP0).ToString();

            // Say "READY"
            ProgramString = ProgramString + "\\0VX";

            // Send all that to the SpeakJet
            Module1.SendDataToSpeakJet(ProgramString, false);

            Cursor           = Cursors.Default;
            btnWrite.Enabled = true;
            Application.DoEvents();
        }
예제 #2
0
 private void btnShutUp_Click(Object eventSender, EventArgs eventArgs)
 {
     Module1.gSerialDataBeingSent = "";
     Module1.SendDataToSpeakJet("\\0RX" + Strings.Chr(Module1.cvRESET).ToString() + Strings.Chr(Module1.cvP0).ToString(), false);
 }
예제 #3
0
 private void cmdTestSerialPort_Click(Object eventSender, EventArgs eventArgs)
 {
     Module1.SendDataToSpeakJet(Strings.Chr(Module1.cvRESET).ToString() + "\\0VX", false);
 }
예제 #4
0
        private void lbs_Click(Object eventSender, EventArgs eventArgs)
        {
            int Index = Array.IndexOf(this.lbs, eventSender);

            Module1.SendDataToSpeakJet(Strings.Chr(Module1.cvPLAY).ToString() + Strings.Chr(Index).ToString(), true);
        }
예제 #5
0
        private void Command1_Click(Object eventSender, EventArgs eventArgs)
        {
            int    Index   = Array.IndexOf(this.Command1, eventSender);
            string SayData = "";

            Cursor = Cursors.WaitCursor;
            Application.DoEvents();

            if (Module1.gLastWasRepeat)
            {
                Module1.gLastWasRepeat = false;
            }
            else
            {
                if (chkApplyControlsBeforeSounds.CheckState == CheckState.Checked)
                {
                    SayData = GetControlCodes();
                    //Else
                    //SayData = Chr$(cvRESET)
                }
            }

            int SoundCode = Module1.GetSoundCode("\\" + Command1[Index].Text);

            if (SoundCode == Module1.cvWAIT)
            {
                if (MessageBox.Show("This control code will cause set the SpeakJet to stop until restarted." + Environment.NewLine + "To restart the SpeakJet you must do one of the following;" + Environment.NewLine + Environment.NewLine + " 1. Activate an event that has been tied to the Restart function." + Environment.NewLine + " 2. Send an SCP Restart command." + Environment.NewLine + " 3. Reset the SpeakJet with the Reset line. " + Environment.NewLine + " 4. Reset the SpeakJet with the SCP Reset command." + Environment.NewLine + "       Note that the \"Shut Up\" Button in the phrase editor" + Environment.NewLine + "       sends the SCP Reset command." + Environment.NewLine + Environment.NewLine + "-OR-" + Environment.NewLine + Environment.NewLine + " Press the Cancel button to not send this command to the SpeakJet.", "Notice", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                {
                    Cursor = Cursors.Default;
                    return;
                }
            }

            if (SoundCode == Module1.cvRESET)
            {
                SetDefaults();
            }

            if (SoundCode < 256)
            {
                SayData = SayData + Strings.Chr(SoundCode).ToString();
            }
            else
            {
                scPitch.Value = Module1.GetNoteFreq(SoundCode);
                SayData       = SayData + Strings.Chr(Module1.cvPITCH).ToString() + Strings.Chr(scPitch.Value).ToString();
            }

            switch (SoundCode)
            {
            case Module1.cvREPEAT:
                SayData = SayData + Strings.Chr(Convert.ToInt32(txtRepeat.Text)).ToString();
                Module1.gLastWasRepeat = true;
                break;

            case Module1.cvCALL:
                SayData = SayData + Strings.Chr(Convert.ToInt32(txtCall.Text)).ToString();
                break;

            case Module1.cvDELAY:
                SayData = SayData + Strings.Chr(Convert.ToInt32(TxtDelay.Text)).ToString();
                break;

            case Module1.cvPLAY:
                SayData = SayData + Strings.Chr(Convert.ToInt32(txtPlay.Text)).ToString();
                break;

            case Module1.cvPCTRL:
                SayData = SayData + Strings.Chr(Convert.ToInt32(txtPCtrl.Text)).ToString();
                break;

            case Module1.cvPOUT:
                SayData = SayData + Strings.Chr(Convert.ToInt32(txtPOut.Text)).ToString();
                break;
            }

            Module1.SendDataToSpeakJet(SayData, true);

            Cursor = Cursors.Default;
            Application.DoEvents();
        }
예제 #6
0
 private void btnSendSyncChar_Click(Object eventSender, EventArgs eventArgs)
 {
     Module1.SendDataToSpeakJet(Strings.Chr(85).ToString(), false);
 }