void InitializePeripherals() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); var i2CBus = Device.CreateI2cBus(); display = new Ssd1306(i2CBus, 60, Ssd1306.DisplayType.OLED128x32); graphics = new GraphicsLibrary(display); graphics.Rotation = GraphicsLibrary.RotationType._180Degrees; rowPorts[0] = Device.CreateDigitalInputPort(Device.Pins.D15, InterruptMode.EdgeRising, ResistorMode.InternalPullDown, 0, 50); rowPorts[1] = Device.CreateDigitalInputPort(Device.Pins.D14, InterruptMode.EdgeRising, ResistorMode.InternalPullDown, 0, 50); rowPorts[2] = Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeRising, ResistorMode.InternalPullDown, 0, 50); rowPorts[3] = Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeRising, ResistorMode.InternalPullDown, 0, 50); columnPorts[0] = Device.CreateDigitalOutputPort(Device.Pins.D01); columnPorts[1] = Device.CreateDigitalOutputPort(Device.Pins.D02); columnPorts[2] = Device.CreateDigitalOutputPort(Device.Pins.D03); columnPorts[3] = Device.CreateDigitalOutputPort(Device.Pins.D04); currentColumn = 0; led.SetColor(RgbLed.Colors.Green); }
void InitializePeripherals() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); var i2CBus = Device.CreateI2cBus(); display = new Ssd1306(i2CBus, 60, Ssd1306.DisplayType.OLED128x32); graphics = new GraphicsLibrary(display); graphics.Rotation = RotationType._180Degrees; DisplayText("MUSIC PLAYER", 16); Thread.Sleep(1000); DisplayText("Song.mp3"); btnNext = new PushButton(Device, Device.Pins.D02, ResistorMode.InternalPullUp); btnNext.Clicked += BtnNextClicked; btnPrevious = new PushButton(Device, Device.Pins.D03, ResistorMode.InternalPullUp); btnPrevious.Clicked += BtnPreviousClicked; btnPlayPause = new PushButton(Device, Device.Pins.D04, ResistorMode.InternalPullUp); btnPlayPause.Clicked += BtnPlayPauseClicked; led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { var onRgbLed = new RgbLed( device: Device, redPin: Device.Pins.OnboardLedRed, greenPin: Device.Pins.OnboardLedGreen, bluePin: Device.Pins.OnboardLedBlue); onRgbLed.SetColor(RgbLed.Colors.Red); leds = new List <Led> { new Led(Device.CreateDigitalOutputPort(Device.Pins.D00, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D01, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D02, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D03, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D04, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D05, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D06, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D07, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D08, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D09, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D10, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D11, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D12, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D13, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D14, false)), new Led(Device.CreateDigitalOutputPort(Device.Pins.D15, false)) }; onRgbLed.SetColor(RgbLed.Colors.Green); TestLeds(); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); IDigitalOutputPort[] ports = { Device.CreateDigitalOutputPort(Device.Pins.D05), Device.CreateDigitalOutputPort(Device.Pins.D06), Device.CreateDigitalOutputPort(Device.Pins.D07), Device.CreateDigitalOutputPort(Device.Pins.D08), Device.CreateDigitalOutputPort(Device.Pins.D09), Device.CreateDigitalOutputPort(Device.Pins.D10), Device.CreateDigitalOutputPort(Device.Pins.D11), Device.CreateDigitalOutputPort(Device.Pins.D12), Device.CreateDigitalOutputPort(Device.Pins.D13), Device.CreateDigitalOutputPort(Device.Pins.D14) }; ledBarGraph = new LedBarGraph(ports); capacitive = new Capacitive ( Device.CreateAnalogInputPort(Device.Pins.A00), MINIMUM_VOLTAGE_CALIBRATION, MAXIMUM_VOLTAGE_CALIBRATION ); led.SetColor(RgbLed.Colors.Green); StartReading(); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3); st7789 = new St7789 ( device: Device, spiBus: Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config), chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); displayWidth = Convert.ToInt32(st7789.Width); displayHeight = Convert.ToInt32(st7789.Height); graphics = new GraphicsLibrary(st7789); graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; led.SetColor(RgbLed.Colors.Green); //DrawShapes(); //DrawTexts(); DrawClock(); }
/// <summary> /// Initializes the hardware. /// </summary> void Initialize() { var rgbLed = new RgbLed( Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue ); rgbLed.SetColor(RgbLed.Colors.Red); Console.WriteLine("Initialize hardware..."); // Analog Temp Sensor Console.WriteLine("Initializing analog temp sensor"); analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); // display this.displayController = new DisplayController(); // WiFi adapter Console.WriteLine("Initializaing wifi adapter."); Device.InitWiFiAdapter().Wait(); rgbLed.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); mcp = new Mcp23x08(Device.CreateI2cBus(), true, true, true); IDigitalOutputPort[] ports = { Device.CreateDigitalOutputPort(Device.Pins.D01), Device.CreateDigitalOutputPort(Device.Pins.D00), mcp.CreateDigitalOutputPort(mcp.Pins.GP7, false, OutputType.PushPull), mcp.CreateDigitalOutputPort(mcp.Pins.GP6, false, OutputType.PushPull), mcp.CreateDigitalOutputPort(mcp.Pins.GP5, false, OutputType.PushPull), mcp.CreateDigitalOutputPort(mcp.Pins.GP4, false, OutputType.PushPull), mcp.CreateDigitalOutputPort(mcp.Pins.GP3, false, OutputType.PushPull), mcp.CreateDigitalOutputPort(mcp.Pins.GP2, false, OutputType.PushPull), mcp.CreateDigitalOutputPort(mcp.Pins.GP1, false, OutputType.PushPull), mcp.CreateDigitalOutputPort(mcp.Pins.GP0, false, OutputType.PushPull), }; ledBarGraph = new LedBarGraph(ports); led.SetColor(RgbLed.Colors.Green); ledBarGraph.Percentage = 1; //CycleLeds(); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); servo = new Servo(Device.CreatePwmPort(Device.Pins.D08), NamedServoConfigs.SG90); servo.RotateTo(0); rotaryEncoder = new RotaryEncoder(Device, Device.Pins.D02, Device.Pins.D03); rotaryEncoder.Rotated += (s, e) => { if (e.Direction == Meadow.Peripherals.Sensors.Rotary.RotationDirection.Clockwise) { angle++; } else { angle--; } if (angle > 180) { angle = 180; } else if (angle < 0) { angle = 0; } servo.RotateTo(angle); }; led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); var config = new SpiClockConfiguration(10000000, SpiClockConfiguration.Mode.Mode0); ISpiBus spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); radio = new Nrf24l01( device: Device, spiBus: spiBus, chipEnablePin: Device.Pins.D13, chipSelectLine: Device.Pins.D12, interruptPin: Device.Pins.D00); radio.SetChannel(76); radio.OpenReadingPipe(0, Encoding.UTF8.GetBytes(address)); radio.SetPALevel(0); radio.StartListening(); led.SetColor(RgbLed.Colors.Green); byte[] text = new byte[32]; while (true) { if (radio.IsAvailable()) { radio.Read(text, (byte)text.Length); Thread.Sleep(1000); } } }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); shiftRegister = new x74595(Device, Device.CreateSpiBus(), Device.Pins.D00, 8); shiftRegister.Clear(); IDigitalOutputPort[] ports = { Device.CreateDigitalOutputPort(Device.Pins.D14), Device.CreateDigitalOutputPort(Device.Pins.D15), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP0,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP1,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP2,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP3,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP5,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP6,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP7,false, OutputType.PushPull), }; ledBarGraph = new LedBarGraph(ports); ledBarGraph.Percentage = 1; rotaryEncoder = new RotaryEncoder(Device, Device.Pins.D02, Device.Pins.D03); //Device.CreateDigitalInputPort(Device.Pins.D02, InterruptMode.EdgeRising, ResistorMode.InternalPullUp, 0, 5), //Device.CreateDigitalInputPort(Device.Pins.D03, InterruptMode.EdgeRising, ResistorMode.InternalPullUp, 0, 5)); rotaryEncoder.Rotated += RotaryEncoderRotated; led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { var led = new RgbLed( Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); up = new PwmLed(Device, Device.Pins.D13, TypicalForwardVoltage.Red); down = new PwmLed(Device, Device.Pins.D10, TypicalForwardVoltage.Red); left = new PwmLed(Device, Device.Pins.D11, TypicalForwardVoltage.Red); right = new PwmLed(Device, Device.Pins.D12, TypicalForwardVoltage.Red); up.IsOn = down.IsOn = left.IsOn = right.IsOn = false; var motorLeft = new HBridgeMotor ( a1Pin: Device.CreatePwmPort(Device.Pins.D05), a2Pin: Device.CreatePwmPort(Device.Pins.D06), enablePin: Device.CreateDigitalOutputPort(Device.Pins.D07) ); var motorRight = new HBridgeMotor ( a1Pin: Device.CreatePwmPort(Device.Pins.D02), a2Pin: Device.CreatePwmPort(Device.Pins.D03), enablePin: Device.CreateDigitalOutputPort(Device.Pins.D04) ); carController = new CarController(motorLeft, motorRight); led.SetColor(RgbLed.Colors.Green); TestCar(); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); leds[0] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D10)); leds[1] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D09)); leds[2] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D08)); leds[3] = new Led(Device.CreateDigitalOutputPort(Device.Pins.D07)); pushButtons[0] = new PushButton(Device.CreateDigitalInputPort(Device.Pins.D01, InterruptMode.EdgeBoth, ResistorMode.Disabled)); pushButtons[0].Clicked += ButtonRedClicked; pushButtons[1] = new PushButton(Device.CreateDigitalInputPort(Device.Pins.D02, InterruptMode.EdgeBoth, ResistorMode.Disabled)); pushButtons[1].Clicked += ButtonGreenClicked; pushButtons[2] = new PushButton(Device.CreateDigitalInputPort(Device.Pins.D03, InterruptMode.EdgeBoth, ResistorMode.Disabled)); pushButtons[2].Clicked += ButtonBlueClicked; pushButtons[3] = new PushButton(Device.CreateDigitalInputPort(Device.Pins.D04, InterruptMode.EdgeBoth, ResistorMode.Disabled)); pushButtons[3].Clicked += ButtonYellowClicked; speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D11)); Console.WriteLine("Welcome to Simon"); SetAllLEDs(true); game.OnGameStateChanged += OnGameStateChanged; game.Reset(); led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); rtc = new Ds1307(Device.CreateI2cBus()); // Uncomment only when setting the time // rtc.SetTime(new DateTime(2019, 11, 23, 22, 55, 20)); display = new CharacterDisplay ( device: Device, pinRS: Device.Pins.D15, pinE: Device.Pins.D14, pinD4: Device.Pins.D13, pinD5: Device.Pins.D12, pinD6: Device.Pins.D11, pinD7: Device.Pins.D10 ); led.SetColor(RgbLed.Colors.Green); StartCountdown(); }
void PushbuttonClicked(object sender, EventArgs e) { Console.WriteLine($"PushButton Clicked!"); led.SetColor(RgbLed.Colors.Magenta); Thread.Sleep(100); led.SetColor(RgbLed.Colors.Red); }
public MeadowApp() { led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); var config = new SpiClockConfiguration(10000000, SpiClockConfiguration.Mode.Mode0); ISpiBus spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); radio = new Nrf24l01( device: Device, spiBus: spiBus, chipEnablePin: Device.Pins.D13, chipSelectLine: Device.Pins.D12, interruptPin: Device.Pins.D00); radio.SetChannel(76); radio.OpenWritingPipe(Encoding.UTF8.GetBytes(address)); radio.SetPALevel(0); radio.StopListening(); led.SetColor(RgbLed.Colors.Green); while (true) { string helloWorld = "Hello World"; radio.Write(Encoding.UTF8.GetBytes(helloWorld), (byte)(helloWorld.Length)); Console.WriteLine($"Sending: {helloWorld} \n"); Thread.Sleep(1000); } }
public MeadowApp() { Console.WriteLine("Start..."); var rgbLed = new RgbLed( Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); rgbLed.SetColor(RgbLed.Colors.Red); Console.Write("Initializing I2C..."); displayI2C = new Ssd1306(Device.CreateI2cBus(), 60, Ssd1306.DisplayType.OLED128x32); graphicsI2C = new GraphicsLibrary(displayI2C); graphicsI2C.CurrentFont = new Font8x12(); graphicsI2C.Clear(); graphicsI2C.Stroke = 1; graphicsI2C.DrawRectangle(0, 0, 128, 32); graphicsI2C.DrawText(5, 12, "I2C WORKING"); graphicsI2C.Show(); Console.WriteLine("done"); Console.Write("Initializing SPI..."); displaySPI = new Ili9163( device: Device, spiBus: Device.CreateSpiBus(), chipSelectPin: Device.Pins.D14, dcPin: Device.Pins.D11, resetPin: Device.Pins.D10, width: 128, height: 160); graphicsSPI = new GraphicsLibrary(displaySPI); graphicsSPI.Rotation = GraphicsLibrary.RotationType._90Degrees; graphicsSPI.Clear(); graphicsSPI.Stroke = 1; graphicsSPI.DrawRectangle(0, 0, 160, 128); graphicsSPI.CurrentFont = new Font8x12(); graphicsSPI.DrawText(7, 7, "SPI WORKING!", Color.White); graphicsSPI.Show(); Console.WriteLine("done"); temperatures = new List <AnalogTemperature> { new AnalogTemperature(Device, Device.Pins.A00, AnalogTemperature.KnownSensorType.LM35), new AnalogTemperature(Device, Device.Pins.A01, AnalogTemperature.KnownSensorType.LM35), new AnalogTemperature(Device, Device.Pins.A02, AnalogTemperature.KnownSensorType.LM35), new AnalogTemperature(Device, Device.Pins.A03, AnalogTemperature.KnownSensorType.LM35), new AnalogTemperature(Device, Device.Pins.A04, AnalogTemperature.KnownSensorType.LM35), new AnalogTemperature(Device, Device.Pins.A05, AnalogTemperature.KnownSensorType.LM35), }; rgbLed.SetColor(RgbLed.Colors.Green); TestTemperatures(); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); servo = new Servo(Device.CreatePwmPort(Device.Pins.D03), NamedServoConfigs.SG90); servo.RotateTo(0); Thread.Sleep(1000); servo.RotateTo(180); button = new PushButton(Device, Device.Pins.D04); button.Clicked += ButtonClicked; led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { Console.WriteLine("Initializing..."); led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); pushButtons = new List <PushButton> { new PushButton(Device, Device.Pins.D00, Meadow.Hardware.ResistorMode.PullUp), // <- Not working (D00 - D04) (D00 - D07) (*) new PushButton(Device, Device.Pins.D01, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D02, Meadow.Hardware.ResistorMode.PullUp), // <- (*) new PushButton(Device, Device.Pins.D03, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D04, Meadow.Hardware.ResistorMode.PullUp), // <- (*) new PushButton(Device, Device.Pins.D05, Meadow.Hardware.ResistorMode.PullUp), // <- Not working (D04 - D07) (D00 - D07) (*) new PushButton(Device, Device.Pins.D06, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D07, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D08, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D09, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D10, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D11, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D12, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D13, Meadow.Hardware.ResistorMode.PullUp), new PushButton(Device, Device.Pins.D14, Meadow.Hardware.ResistorMode.PullUp), // <- Not working (D12 - D15) (D08 - D15) (*) new PushButton(Device, Device.Pins.D15, Meadow.Hardware.ResistorMode.PullUp) }; for (int i = 0; i < pushButtons.Count; i++) { pushButtons[i].Clicked += PushbuttonClicked; } Console.WriteLine("PushButton ready!!!.."); }
public MeadowApp() { Console.WriteLine("Initializing..."); led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); pushButtons = new List <PushButton> { new PushButton(Device, Device.Pins.D00, Meadow.Hardware.ResistorMode.PullUp), // <- GS09 //new PushButton(Device, Device.Pins.D01, Meadow.Hardware.ResistorMode.PullUp), // <- GS new PushButton(Device, Device.Pins.D02, Meadow.Hardware.ResistorMode.PullUp), // <- GS06 //new PushButton(Device, Device.Pins.D03, Meadow.Hardware.ResistorMode.PullUp), // <- GS08 //new PushButton(Device, Device.Pins.D04, Meadow.Hardware.ResistorMode.PullUp), // <- GS09 //new PushButton(Device, Device.Pins.D05, Meadow.Hardware.ResistorMode.PullUp), // <- GS07 new PushButton(Device, Device.Pins.D06, Meadow.Hardware.ResistorMode.PullUp), // <- GS00 //new PushButton(Device, Device.Pins.D07, Meadow.Hardware.ResistorMode.PullUp), // <- GS07 //new PushButton(Device, Device.Pins.D08, Meadow.Hardware.ResistorMode.PullUp), // <- GS06 new PushButton(Device, Device.Pins.D09, Meadow.Hardware.ResistorMode.PullUp), // <- GS01 //new PushButton(Device, Device.Pins.D10, Meadow.Hardware.ResistorMode.PullUp), // <- GS //new PushButton(Device, Device.Pins.D11, Meadow.Hardware.ResistorMode.PullUp), // <- GS09 new PushButton(Device, Device.Pins.D12, Meadow.Hardware.ResistorMode.PullUp), // <- GS14 //new PushButton(Device, Device.Pins.D13, Meadow.Hardware.ResistorMode.PullUp), // <- GS15 new PushButton(Device, Device.Pins.D14, Meadow.Hardware.ResistorMode.PullUp), // <- GS03 //new PushButton(Device, Device.Pins.D15, Meadow.Hardware.ResistorMode.PullUp) // <- GS03 }; for (int i = 0; i < pushButtons.Count; i++) { pushButtons[i].Clicked += PushbuttonClicked; } Console.WriteLine("PushButton ready!!!.."); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); stopwatch = new Stopwatch(); startStop = new PushButton( device: Device, inputPin: Device.Pins.D12, resistorMode: Meadow.Hardware.ResistorMode.InternalPullUp); startStop.Clicked += StartStopClicked; reset = new PushButton( device: Device, inputPin: Device.Pins.D13, resistorMode: Meadow.Hardware.ResistorMode.InternalPullUp); reset.Clicked += ResetClicked; display = new FourDigitSevenSegment ( portDigit1: Device.CreateDigitalOutputPort(Device.Pins.D00), portDigit2: Device.CreateDigitalOutputPort(Device.Pins.D03), portDigit3: Device.CreateDigitalOutputPort(Device.Pins.D04), portDigit4: Device.CreateDigitalOutputPort(Device.Pins.D06), portA: Device.CreateDigitalOutputPort(Device.Pins.D01), portB: Device.CreateDigitalOutputPort(Device.Pins.D05), portC: Device.CreateDigitalOutputPort(Device.Pins.D08), portD: Device.CreateDigitalOutputPort(Device.Pins.D10), portE: Device.CreateDigitalOutputPort(Device.Pins.D11), portF: Device.CreateDigitalOutputPort(Device.Pins.D02), portG: Device.CreateDigitalOutputPort(Device.Pins.D07), portDecimal: Device.CreateDigitalOutputPort(Device.Pins.D09), isCommonCathode: true ); display.SetDisplay("0000".ToCharArray()); led.SetColor(RgbLed.Colors.Green); while (true) { string time = stopwatch.Elapsed.Minutes.ToString("D2") + stopwatch.Elapsed.Seconds.ToString("D2"); display.SetDisplay(time.ToCharArray()); Thread.Sleep(1000); } }
void ButtonUpClicked(object sender, EventArgs e) { led.SetColor(RgbLed.Colors.Red); if (selectedIndex + 1 > 2) { selectedIndex = 0; } else { selectedIndex++; } DisplayJPG(); led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { Console.WriteLine("Initializing..."); led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); // Important note: You can only use on Push Button per Group Set (GSXX) pushButtons = new List <PushButton> { new PushButton(Device, Device.Pins.A04, Meadow.Hardware.ResistorMode.PullUp), // <- GS00 //new PushButton(Device, Device.Pins.D06, Meadow.Hardware.ResistorMode.PullUp), // <- GS00 new PushButton(Device, Device.Pins.A05, Meadow.Hardware.ResistorMode.PullUp), // <- GS01 //new PushButton(Device, Device.Pins.D09, Meadow.Hardware.ResistorMode.PullUp), // <- GS01 new PushButton(Device, Device.Pins.A02, Meadow.Hardware.ResistorMode.PullUp), // <- GS03 //new PushButton(Device, Device.Pins.D14, Meadow.Hardware.ResistorMode.PullUp), // <- GS03 //new PushButton(Device, Device.Pins.D15, Meadow.Hardware.ResistorMode.PullUp) // <- GS03 new PushButton(Device, Device.Pins.A00, Meadow.Hardware.ResistorMode.PullUp), // <- GS04 new PushButton(Device, Device.Pins.A01, Meadow.Hardware.ResistorMode.PullUp), // <- GS05 //new PushButton(Device, Device.Pins.ESP_MOSI, Meadow.Hardware.ResistorMode.PullUp), // <- GS05 new PushButton(Device, Device.Pins.D02, Meadow.Hardware.ResistorMode.PullUp), // <- GS06 //new PushButton(Device, Device.Pins.D08, Meadow.Hardware.ResistorMode.PullUp), // <- GS06 new PushButton(Device, Device.Pins.A03, Meadow.Hardware.ResistorMode.PullUp), // <- GS07 //new PushButton(Device, Device.Pins.D05, Meadow.Hardware.ResistorMode.PullUp), // <- GS07 //new PushButton(Device, Device.Pins.D07, Meadow.Hardware.ResistorMode.PullUp), // <- GS07 new PushButton(Device, Device.Pins.D03, Meadow.Hardware.ResistorMode.PullUp), // <- GS08 new PushButton(Device, Device.Pins.D00, Meadow.Hardware.ResistorMode.PullUp), // <- GS09 //new PushButton(Device, Device.Pins.D04, Meadow.Hardware.ResistorMode.PullUp), // <- GS09 //new PushButton(Device, Device.Pins.D11, Meadow.Hardware.ResistorMode.PullUp), // <- GS09 new PushButton(Device, Device.Pins.D10, Meadow.Hardware.ResistorMode.PullUp), // <- GS10 new PushButton(Device, Device.Pins.ESP_MISO, Meadow.Hardware.ResistorMode.PullUp), // <- GS11 new PushButton(Device, Device.Pins.D01, Meadow.Hardware.ResistorMode.PullUp), // <- GS13 new PushButton(Device, Device.Pins.D12, Meadow.Hardware.ResistorMode.PullUp), // <- GS14 new PushButton(Device, Device.Pins.D13, Meadow.Hardware.ResistorMode.PullUp), // <- GS15 }; for (int i = 0; i < pushButtons.Count; i++) { pushButtons[i].Clicked += PushbuttonClicked; //pushButtons[i].PressStarted += PushbuttonPressStarted; //pushButtons[i].PressEnded += PushbuttonPressEnded; } Console.WriteLine("PushButton(s) ready!!!"); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); shiftRegister = new x74595( device: Device, spiBus: Device.CreateSpiBus(), pinChipSelect: Device.Pins.D03, pins: 8); shiftRegister.Clear(true); TestX74595(); led.SetColor(RgbLed.Colors.Green); }
void Initialize() { led = new RgbLed( Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); ledUp = new PwmLed(Device, Device.Pins.D13, TypicalForwardVoltage.Red); ledDown = new PwmLed(Device, Device.Pins.D10, TypicalForwardVoltage.Red); ledLeft = new PwmLed(Device, Device.Pins.D11, TypicalForwardVoltage.Red); ledRight = new PwmLed(Device, Device.Pins.D12, TypicalForwardVoltage.Red); ledUp.IsOn = ledDown.IsOn = ledLeft.IsOn = ledRight.IsOn = true; var motorLeft = new HBridgeMotor ( device: Device, a1Pin: Device.Pins.D05, a2Pin: Device.Pins.D06, enablePin: Device.Pins.D07 ); var motorRight = new HBridgeMotor ( device: Device, a1Pin: Device.Pins.D02, a2Pin: Device.Pins.D03, enablePin: Device.Pins.D04 ); carController = new CarController(motorLeft, motorRight); led.SetColor(RgbLed.Colors.Blue); bleTreeDefinition = GetDefinition(); Device.BluetoothAdapter.StartBluetoothServer(bleTreeDefinition); up.ValueSet += UpValueSet; down.ValueSet += DownValueSet; left.ValueSet += LeftValueSet; right.ValueSet += RightValueSet; led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); up = new Led(Device.CreateDigitalOutputPort(Device.Pins.D15)); down = new Led(Device.CreateDigitalOutputPort(Device.Pins.D12)); left = new Led(Device.CreateDigitalOutputPort(Device.Pins.D14)); right = new Led(Device.CreateDigitalOutputPort(Device.Pins.D13)); mpu = new Mpu6050(Device.CreateI2cBus()); //mpu.AccelerationChangeThreshold = 0.05f; //mpu.Updated += MpuUpdated; //mpu.StartUpdating(100); up.IsOn = true; led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); x = y = 120; var config = new SpiClockConfiguration( speedKHz: 6000, mode: SpiClockConfiguration.Mode.Mode3); st7789 = new St7789( device: Device, spiBus: Device.CreateSpiBus( clock: Device.Pins.SCK, mosi: Device.Pins.MOSI, miso: Device.Pins.MISO, config: config), chipSelectPin: null, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240); graphics = new GraphicsLibrary(st7789); graphics.Clear(true); graphics.DrawRectangle(0, 0, 240, 240, Color.White, true); graphics.DrawPixel(x, y, Color.Red); graphics.Show(); rotaryX = new RotaryEncoderWithButton(Device, Device.Pins.A00, Device.Pins.A01, Device.Pins.A02); rotaryX.Rotated += RotaryXRotated; rotaryY = new RotaryEncoderWithButton(Device, Device.Pins.D02, Device.Pins.D03, Device.Pins.D04); rotaryY.Rotated += RotaryYRotated; rotaryY.Clicked += RotaryYClicked; led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { var rgbLed = new RgbLed( Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue ); rgbLed.SetColor(RgbLed.Colors.Red); var config = new SpiClockConfiguration( speedKHz: 6000, mode: SpiClockConfiguration.Mode.Mode3); display = new St7789 ( device: Device, spiBus: Device.CreateSpiBus( Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config), chipSelectPin: null, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); graphics = new GraphicsLibrary(display); graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; motionSensor = new ParallaxPir(Device, Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.Disabled, 5, 0); motionSensor.OnMotionStart += MotionSensorMotionStart; motionSensor.OnMotionEnd += MotionSensorMotionEnd; rgbLed.SetColor(RgbLed.Colors.Green); LoadScreen(); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); leds = new PwmLed[7]; leds[0] = new PwmLed(Device.CreatePwmPort(Device.Pins.D06), TypicalForwardVoltage.Red); // leds[1] = new PwmLed(Device.CreatePwmPort(Device.Pins.D07), TypicalForwardVoltage.Red); // [6] [5] leds[2] = new PwmLed(Device.CreatePwmPort(Device.Pins.D08), TypicalForwardVoltage.Red); // leds[3] = new PwmLed(Device.CreatePwmPort(Device.Pins.D09), TypicalForwardVoltage.Red); // [4] [3] [2] leds[4] = new PwmLed(Device.CreatePwmPort(Device.Pins.D10), TypicalForwardVoltage.Red); // leds[5] = new PwmLed(Device.CreatePwmPort(Device.Pins.D11), TypicalForwardVoltage.Red); // [1] [0] leds[6] = new PwmLed(Device.CreatePwmPort(Device.Pins.D12), TypicalForwardVoltage.Red); // button = new PushButton(Device, Device.Pins.D05); button.Clicked += ButtonClicked; led.SetColor(RgbLed.Colors.Green); ShuffleAnimation(); }
void InitializePeripherals() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); var i2CBus = Device.CreateI2cBus(); radio = new Tea5767(i2CBus); display = new Ssd1306(i2CBus, 60, Ssd1306.DisplayType.OLED128x32); graphics = new GraphicsLibrary(display); graphics.Rotation = GraphicsLibrary.RotationType._180Degrees; btnNext = new PushButton(Device, Device.Pins.D03, ResistorMode.InternalPullUp); btnNext.Clicked += BtnNextClicked; btnPrevious = new PushButton(Device, Device.Pins.D04, ResistorMode.InternalPullUp); btnPrevious.Clicked += BtnPreviousClicked; led.SetColor(RgbLed.Colors.Green); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); mcp = new Mcp23x08(Device.CreateI2cBus(), true, true, true); leds = new List <Led>(); leds.Add(new Led(mcp.CreateDigitalOutputPort(mcp.Pins.GP0))); leds.Add(new Led(mcp.CreateDigitalOutputPort(mcp.Pins.GP1))); leds.Add(new Led(mcp.CreateDigitalOutputPort(mcp.Pins.GP2))); leds.Add(new Led(mcp.CreateDigitalOutputPort(mcp.Pins.GP3))); leds.Add(new Led(mcp.CreateDigitalOutputPort(mcp.Pins.GP4))); leds.Add(new Led(mcp.CreateDigitalOutputPort(mcp.Pins.GP5))); leds.Add(new Led(mcp.CreateDigitalOutputPort(mcp.Pins.GP6))); leds.Add(new Led(mcp.CreateDigitalOutputPort(mcp.Pins.GP7))); led.SetColor(RgbLed.Colors.Green); CycleLeds(); }