public SpdtSwitchApp() { spdtSwitch = new SpdtSwitch(Device.CreateDigitalInputPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.PullDown)); spdtSwitch.Changed += SpdtSwitchChanged; Console.WriteLine("Initial switch state, isOn: " + spdtSwitch.IsOn.ToString()); }
public MeadowApp() { Console.WriteLine("Initializing..."); spdtSwitch = new SpdtSwitch(Device.CreateDigitalInputPort(Device.Pins.D15, InterruptMode.EdgeBoth, ResistorMode.PullDown)); spdtSwitch.Changed += (s, e) => { Console.WriteLine(spdtSwitch.IsOn ? "Switch is on" : "Switch is off"); }; Console.WriteLine("SpdtSwitch ready..."); }
public void InitHardware() { redLed = Device.CreateDigitalOutputPort(Device.Pins.OnboardLEDRed, false); blueLed = Device.CreateDigitalOutputPort(Device.Pins.OnboardLEDBlue, false); greenLed = Device.CreateDigitalOutputPort(Device.Pins.OnboardLEDGreen, false); spdtSwitch = new SpdtSwitch(Device, Device.Pins.D14, InterruptMode.EdgeBoth, ResistorMode.Disabled); spdtSwitch.Changed += SpdtSwitch_Changed; display = new Lcd2004(App.Device, Device.Pins.D05, Device.Pins.D07, Device.Pins.D08, Device.Pins.D09, Device.Pins.D10, Device.Pins.D11, 2, 16); blueLed.State = true; }
public static void Main() { var spdtSwitch = new SpdtSwitch(N.Pins.GPIO_PIN_D5); Debug.Print("Initial switch state, isOn: " + spdtSwitch.IsOn.ToString()); spdtSwitch.Changed += (s, e) => { Debug.Print("Switch Changed"); Debug.Print("Switch on: " + spdtSwitch.IsOn.ToString()); }; Thread.Sleep(Timeout.Infinite); }
private void InitializePeripherals() { leds[0] = new Led(N.Pins.GPIO_PIN_D4); leds[1] = new Led(N.Pins.GPIO_PIN_D5); leds[2] = new Led(N.Pins.GPIO_PIN_D6); leds[3] = new Led(N.Pins.GPIO_PIN_D7); buttons[0] = new PushButton(N.Pins.GPIO_PIN_D10, Netduino.Foundation.CircuitTerminationType.High); buttons[1] = new PushButton(N.Pins.GPIO_PIN_D11, Netduino.Foundation.CircuitTerminationType.High); buttons[2] = new PushButton(N.Pins.GPIO_PIN_D12, Netduino.Foundation.CircuitTerminationType.High); buttons[3] = new PushButton(N.Pins.GPIO_PIN_D13, Netduino.Foundation.CircuitTerminationType.High); speaker = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D3); spdt = new SpdtSwitch(N.Pins.GPIO_PIN_D2); graphics = new GraphicsLibrary(display = new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x64)); display.IgnoreOutOfBoundsPixels = true; SetAllLEDs(false); }
public MeadowApp() { this.spdtSwitch = new SpdtSwitch(Device.CreateDigitalInputPort(Device.Pins.D04, InterruptMode.EdgeBoth)); this.displayInCelcius = this.spdtSwitch.IsOn; this.spdtSwitch.Changed += this.SpdtSwitch_Changed; this.st7789 = InitializeLcdScreen(out this.displayWidth, out this.displayHeight, out this.graphics); this.analogTemperature = InitializeAnalogTemperatureSensor(this.AnalogTemperatureUpdated); this.mcp9808 = InitializeMcp9808TemperatureSensor(); this.Display9808Temperature(this.mcp9808.GetTemperature()); this.mcp9808.Subscribe(new FilterableChangeObserver <AtmosphericConditionChangeResult, AtmosphericConditions>( this.Mcp9808TemperatureUpdated, e => Math.Abs(e.Delta.Temperature.Value) > 0.1 )); this.mcp9808.StartUpdating(); OnboardLed led = new OnboardLed(Device); led.SetColor(RgbColor.Green); }
private void InitializePeripherals() { leds[0] = new Led(N.Pins.GPIO_PIN_D4); leds[1] = new Led(N.Pins.GPIO_PIN_D5); leds[2] = new Led(N.Pins.GPIO_PIN_D6); leds[3] = new Led(N.Pins.GPIO_PIN_D7); buttons[0] = new InterruptPort(N.Pins.GPIO_PIN_D10, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth); buttons[1] = new InterruptPort(N.Pins.GPIO_PIN_D11, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth); buttons[2] = new InterruptPort(N.Pins.GPIO_PIN_D12, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth); buttons[3] = new InterruptPort(N.Pins.GPIO_PIN_D13, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth); buttons[0].OnInterrupt += OnButton0; buttons[1].OnInterrupt += OnButton1; buttons[2].OnInterrupt += OnButton2; buttons[3].OnInterrupt += OnButton3; speaker = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D3); spdt = new SpdtSwitch(N.Pins.GPIO_PIN_D2); display = new GraphicsLibrary(new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x64)); SetAllLEDs(false); }