private void ZendNul() { MPUSB.WriteDigitalOutPortD(0); MPUSB.WriteDigitalOutPortD(2); MPUSB.Wait(1); MPUSB.WriteDigitalOutPortD(0); }
private void ZendEen() { MPUSB.WriteDigitalOutPortD(0); MPUSB.WriteDigitalOutPortD(3); MPUSB.Wait(1); MPUSB.WriteDigitalOutPortD(0); }
private void btnTeller(object sender, RoutedEventArgs e) { for (short i = 0; i <= 255; i++) { MPUSB.WriteDigitalOutPortD(i); } }
private bool WriteLCD(byte data, bool instruction) { if (data > 0xFF) { return(false); } if (instruction) { EHoogInstructie(); } else { EHoogData(); } int x = MPUSB.ReadDigitalOutPortD(); int y = x & 0xF00;//datalijnen op 0 -> 1111 0000 0000 int z = y | data; MPUSB.WriteDigitalOutPortD((short)z); if (instruction) { ELaagInstructie(); } else { ELaagData(); } MPUSB.Wait(1); return(true); }
private void ELaagInstructie() { //E = 0, RS = 0, RW = 0 int x = MPUSB.ReadDigitalOutPortD(); int y = x & 0x0FF;//E, RW en RS op 0 -> & 0000 1111 1111 MPUSB.WriteDigitalOutPortD((short)y); }
public void TurnOffAllLeds() { MPUSB.WriteDigitalOutPortD(0x00); foreach (CheckBox c in checkboxes) { c.IsChecked = false; } }
public void TurnOnAllLeds() { MPUSB.WriteDigitalOutPortD(0xFF); foreach (CheckBox c in checkboxes) { c.IsChecked = true; } }
private void ELaagInstructie() { int value = MPUSB.ReadDigitalOutPortD(); value = value & 0x0FF; MPUSB.WriteDigitalOutPortD((short)value); MPUSB.Wait(25); }
private void ELaagData() { int value = MPUSB.ReadDigitalOutPortD(); value = value & 0x0FF; value = value | 0x400; MPUSB.WriteDigitalOutPortD((short)value); MPUSB.Wait(25); }
private void ELaagData() { //E = 0, RS = 1, RW = 0 int x = MPUSB.ReadDigitalOutPortD(); int y = x & 0x8FF; //E, RW en RS op 0 -> & 1000 1111 1111 int z = y | 0x400; //E op 0, RS op 1 -> | 0100 0000 0000 MPUSB.WriteDigitalOutPortD((short)z); }
private void EHoogData() { //E = 1, RS = 1, RW = 0 int x = MPUSB.ReadDigitalOutPortD(); int y = x & 0x0FF; //E, RW en RS op 0 -> & 0000 1111 1111 int z = y | 0x500; //E op 1, RS op 1 -> | 0101 0000 0000 MPUSB.WriteDigitalOutPortD((short)z); }
private void EHoogInstructie() { // E = 1 / RW = 0 / RS = 0 int x = MPUSB.ReadDigitalOutPortD(); int y = x & 0x8FF; //E, RW en RS op 0 -> & 1000 1111 1111 int z = y | 0x100; //E op 1 -> | 0001 0000 0000 MPUSB.WriteDigitalOutPortD((short)z); }
public void DecreaseTeller() { this.teller--; if (teller < 0) { teller = 0; } MPUSB.WriteDigitalOutPortD(teller); }
public void IncreaseTeller() { this.teller++; if (teller > Math.Pow(2, 8)) { teller = (Int16)Math.Pow(2, 8); } MPUSB.WriteDigitalOutPortD(teller); }
private void DataVeranderen(int data) { int value = MPUSB.ReadDigitalOutPortD(); value = value & 0xF00; value = value | data; MPUSB.WriteDigitalOutPortD((short)value); MPUSB.Wait(25); }
private void MoveLedsDown() { var value = (short)MPUSB.ReadDigitalOutPortD(); var newv = value >> 1; if (value % 2 == 1) { newv += 128; } MPUSB.WriteDigitalOutPortD((short)newv); }
private void Bw_ProgressChanged(object sender, ProgressChangedEventArgs e) { AnalogOutput AnalogData = (AnalogOutput)e.UserState; pgbIngang1.Value = AnalogData.Potent1; pgbIngang2.Value = AnalogData.Potent2; pgbLight.Value = AnalogData.LightSensor; double test = (double)AnalogData.LightSensor / 1024 * 256; MPUSB.WriteDigitalOutPortD((short)test); }
private void chkChanged(object sender, RoutedEventArgs e) { CheckBox chk = sender as CheckBox; int current = MPUSB.ReadDigitalOutPortD(); string currentString = Convert.ToString(current, 2).PadLeft(8, '0'); int change = (int)Math.Pow(2, (int)chk.Tag); string changeString = Convert.ToString(change, 2).PadLeft(8, '0'); int newValue = current ^ change; MPUSB.WriteDigitalOutPortD((short)newValue); }
private void MoveLedsUp() { var value = (short)MPUSB.ReadDigitalOutPortD(); short b128 = 128; var ish = value & b128; if (ish != 0) { value -= 128; } var newv = value << 1; if (ish != 0) { newv += 1; } MPUSB.WriteDigitalOutPortD((short)newv); Console.WriteLine(MPUSB.ReadDigitalOutPortD()); }
private void ParseAndExecuteCommand(string command) { bool bekend = true; // of het command bekend is // commands if (command == "ledsaan") { MPUSB.WriteDigitalOutPortD(0xFF); } else if (command == "ledsuit") { MPUSB.WriteDigitalOutPortD(0x00); } else if (new Regex("^(?:ledsaan )[0-7]*$").Match(command).Success) // ledsaan 0125 turns on leds 0, 1, 2 and 5 { var test = new Regex("^(?:ledsaan )[0-7]*$").Match(command); string leds = new Regex("^(?:ledsaan )[0-7]*$").Match(command).Value; string substring = leds.Substring(7); foreach (char c in substring) { int i = (int)Char.GetNumericValue(c); short status = (short)MPUSB.ReadDigitalOutPortD(); short toWrite = (short)(status | (short)(Math.Pow(2, i))); MPUSB.WriteDigitalOutPortD(toWrite); } } else { Console.WriteLine("Command niet herkend: " + command); bekend = false; } if (bekend) { this.Dispatcher.Invoke(new Action(() => lstCommands.Items.Add(command + " <gelukt>"))); } else { this.Dispatcher.Invoke(new Action(() => lstCommands.Items.Add(command + " <niet gekend>"))); } }
private void getAck() { MPUSB.WriteDigitalOutPortD(1); MPUSB.Wait(1); MPUSB.WriteDigitalOutPortD(3); MPUSB.Wait(1); byte data = MPUSB.ReadDigitalInPortB(); bool ack = (byte)(data & 32) != 0; if (ack) { lblStatus.Content = "Ack!"; } else { lblStatus.Content = "No Ack!!"; } }
public void SetLedStatus(byte status) { bool led1 = (status & 1) != 0; bool led2 = (status & 2) != 0; bool led3 = (status & 4) != 0; bool led4 = (status & 8) != 0; bool led5 = (status & 16) != 0; bool led6 = (status & 32) != 0; bool led7 = (status & 64) != 0; bool led8 = (status & 128) != 0; checkboxes[0].IsChecked = led1; checkboxes[1].IsChecked = led2; checkboxes[2].IsChecked = led3; checkboxes[3].IsChecked = led4; checkboxes[4].IsChecked = led5; checkboxes[5].IsChecked = led6; checkboxes[6].IsChecked = led7; checkboxes[7].IsChecked = led8; Console.WriteLine("Writing out " + status); MPUSB.WriteDigitalOutPortD(status); }
private void StopConditie() { MPUSB.WriteDigitalOutPortD(2); MPUSB.Wait(1); MPUSB.WriteDigitalOutPortD(3); }
private void btnLedsUit(object sender, RoutedEventArgs e) { MPUSB.WriteDigitalOutPortD(0); UpdateUI(); }