Пример #1
0
 private void SetMem()
 {
     COM c = null;
     try
     {
         c = new COM(port, Baud);
         c.SendCmd(USB2LCD.Command.Remember, 1); //activate remembering
         if (checkDisplay.Checked)
             c.SendCmd(USB2LCD.Command.DisplayOn, radioOnAlways.Checked ? (byte)0 : (byte)numericOnFor.Value);
         else
             c.SendCmd(USB2LCD.Command.DisplayOff);
         c.SendCmd(checkBlink.Checked	? USB2LCD.Command.BlinkOn  : USB2LCD.Command.BlinkOff);
         c.SendCmd(checkCursor.Checked	? USB2LCD.Command.CursorOn : USB2LCD.Command.CursorOff);
         c.SendCmd(USB2LCD.Command.Contrast,  (byte)trackBarContrast.Value );
         c.SendCmd(USB2LCD.Command.Backlight, (byte)trackBarBacklight.Value);
         c.SendCmd(USB2LCD.Command.Remember, 0); //deactivate remembering
         c.SendCharacter(USB2LCD.Command.RememberCustom, 0, customChar1.GetData());
         c.SendCharacter(USB2LCD.Command.RememberCustom, 1, customChar2.GetData());
         c.SendCharacter(USB2LCD.Command.RememberCustom, 2, customChar3.GetData());
         c.SendCharacter(USB2LCD.Command.RememberCustom, 3, customChar4.GetData());
         c.SendCharacter(USB2LCD.Command.RememberCustom, 4, customChar5.GetData());
         c.SendCharacter(USB2LCD.Command.RememberCustom, 5, customChar6.GetData());
         c.SendCharacter(USB2LCD.Command.RememberCustom, 6, customChar7.GetData());
         c.SendCharacter(USB2LCD.Command.RememberCustom, 7, customChar8.GetData());
         c.SendCmd(USB2LCD.Command.SaveStartup);
         c.SendLine(textLine1.RealText, false);
         c.SendLine(textLine2.RealText, false);
         c.SendLine(textLine3.RealText, false);
         c.SendLine(textLine4.RealText, false);
     }
     catch (COMException ex)
     {
         ex.Show(this);
     }
     catch (Exception ex)
     {
         ShowErrorMessage("There was an error:\n"+ex.Message, "Error");
     }
     finally
     {
         if (c != null) { c.Close(); }
         EnableForm(true);
     }
 }
Пример #2
0
 private void SetCur()
 {
     Control.CheckForIllegalCrossThreadCalls = false;
     COM c = null;
     try
     {
         c = new COM(port, Baud);
         if (checkDisplay.Checked)
             c.SendCmd(USB2LCD.Command.DisplayOn, radioOnAlways.Checked ? (byte)0 : (byte)numericOnFor.Value);
         else
             c.SendCmd(USB2LCD.Command.DisplayOff);
         c.SendCmd(checkBlink.Checked	? USB2LCD.Command.BlinkOn  : USB2LCD.Command.BlinkOff);
         c.SendCmd(checkCursor.Checked	? USB2LCD.Command.CursorOn : USB2LCD.Command.CursorOff);
         c.SendCmd(USB2LCD.Command.Contrast,  (byte)trackBarContrast.Value );
         c.SendCmd(USB2LCD.Command.Backlight, (byte)trackBarBacklight.Value);
         c.SendCharacter(USB2LCD.Command.DefineCustom, 0, customChar1.GetData());
         c.SendCharacter(USB2LCD.Command.DefineCustom, 1, customChar2.GetData());
         c.SendCharacter(USB2LCD.Command.DefineCustom, 2, customChar3.GetData());
         c.SendCharacter(USB2LCD.Command.DefineCustom, 3, customChar4.GetData());
         c.SendCharacter(USB2LCD.Command.DefineCustom, 4, customChar5.GetData());
         c.SendCharacter(USB2LCD.Command.DefineCustom, 5, customChar6.GetData());
         c.SendCharacter(USB2LCD.Command.DefineCustom, 6, customChar7.GetData());
         c.SendCharacter(USB2LCD.Command.DefineCustom, 7, customChar8.GetData());
         c.SendCmd(USB2LCD.Command.Position, 1, 1);
         c.SendLine(textLine1.RealText, true);
         c.SendCmd(USB2LCD.Command.Position, 1, 2);
         c.SendLine(textLine2.RealText, true);
         c.SendCmd(USB2LCD.Command.Position, 1, 3);
         c.SendLine(textLine3.RealText, true);
         c.SendCmd(USB2LCD.Command.Position, 1, 4);
         c.SendLine(textLine4.RealText, true);
     }
     catch (COMException ex)
     {
         ex.Show(this);
     }
     catch (Exception ex)
     {
         ShowErrorMessage("There was an error:\n"+ex.Message, "Error");
     }
     finally
     {
         if (c != null) { c.Close(); }
         EnableForm(true);
     }
 }