private void numericUpDown1_ValueChanged_1(object sender, EventArgs e) { value = System.Convert.ToDouble(numericUpDown1.Value); if (PCon == true) { ParallelPort.Output(0x378, System.Convert.ToInt16(value / System.Convert.ToDouble(PCMaxPsi.Value) * 256 * 2)); //ParallelPort.Output(0x378, System.Convert.ToInt16(value/12.5*256)); cur.Text = System.Convert.ToString(value); pBar1.Value = System.Convert.ToInt16(value * 4); } }
public static int WriteData(int portaddress, int A, int RW, int port, int reg, double percentage) { int clock = 0, outvalue = 0; long value = 0; int port2 = portnumconv(port); int data2 = voltageconv(percentage); ParallelPort.Output(portaddress, 2); //sets SYNC to HIGH, clears previous data System.Threading.Thread.Sleep(1); ParallelPort.Output(portaddress, 0); //sets SYNC to LOW (falling edge starts input sequence) value += A; value = value << 1; value += RW; value = value << 6; value += port2; value = value << 2; value += reg; value = value << 14; value += data2; for (int i = 0; i < 24; i++) { outvalue = (int)(value & (1 << (24 - i))); outvalue = outvalue >> (24 - i); outvalue = outvalue << 2; clock = 1; outvalue += clock; //xor them to write the clock in the string bit ParallelPort.Output(portaddress, outvalue); //put the value on the port System.Threading.Thread.Sleep(1); outvalue -= clock; ParallelPort.Output(portaddress, outvalue); //falling edge of the clock } ParallelPort.Output(portaddress, 2); //sets SYNC to HIGH, clears previous data return(0); }
private void btnOnOff_Click(object sender, EventArgs e) { if (PCon == false) { ParallelPort.Output(0x378, System.Convert.ToInt16(value / System.Convert.ToDouble(PCMaxPsi.Value) * 256 * 2)); btnOnOff.BackColor = Color.Transparent; btnOnOff.Text = "Turn Off"; pBar1.Value = System.Convert.ToInt16(value * 4); cur.Text = System.Convert.ToString(value); PCon = true; } else { ParallelPort.Output(0x378, 0); btnOnOff.BackColor = Color.Red; btnOnOff.Text = "Turn On"; pBar1.Value = 0; cur.Text = "0"; PCon = false; } }
private void btnExit_Click(object sender, EventArgs e) { ParallelPort.Output(0x378, 0); Application.Exit(); }
private void Form1_FormClosing() { ParallelPort.Output(0x378, 0); }
private void Form1_Load(object sender, EventArgs e) { ParallelPort.Output(0x378, 0); }