public void TestVfd() { var pl = VfdWriter.EnumerateComPortName(); if (pl.Contains(ComPort)) { try { using (var w = new VfdWriterImpl(ComPort)) { var panel = new VfdPanel(w, Brightness); panel.Overwrite("Connected to", 0, 0); panel.Overwrite("Yuyushiki", 1, 11); panel.Update(); } } catch (Exception) { MessageBox.Show("Selected COM port is not ready.", "Yuyushiki", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { mainForm.ResetComPortComboBoxItems(); MessageBox.Show(ComPort + " is missing.", "Yuyushiki", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } mainForm.UpdateStatus(); }
private void comPortComboBox_SelectedIndexChanged(object sender, EventArgs e) { var pl = VfdWriter.EnumerateComPortName(); if (pl.Contains(comPortComboBox.SelectedItem)) { play.ComPort = (string)comPortComboBox.SelectedItem; } UpdateStatus(); }
public VfdPanel(VfdWriter w, int brightness) { writer = w; _Brightness = brightness; _BrightnessBefore = brightness; w.Send(new byte[] { 0x0c /* clear */ }); for (int i = 0; i < NUM_ROW; i++) { _Rows.Add(new List <char>(" ")); } foreach (var r in _Rows) { _RowsBefore.Add(new List <char>(r)); } w.Send(new byte[] { 0x1f, 0x58, (byte)(Brightness + 1) }); // brightness }
public void ResetComPortComboBoxItems() { var pl = VfdWriter.EnumerateComPortName(); var items = comPortComboBox.Items; items.Clear(); foreach (var s in pl) { items.Add(s); } comPortComboBox.SelectedIndex = pl.Contains(play.ComPort) ? items.IndexOf(play.ComPort) : -1; comPortComboBox.Enabled = (!play.IsPlaying) && (pl.Count > 0); if (planStatus == PlanStatus.ComPortNotReady) { OverwritePlanStatus(PlanStatus.Empty); } }