void Initialize() { onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); onboardLed.StartPulse(Color.Red); analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); displayController = new WeatherView(); Device.InitWiFiAdapter().Wait(); onboardLed.StartPulse(Color.Blue); var result = Device.WiFiAdapter.Connect(Secrets.WIFI_NAME, Secrets.WIFI_PASSWORD); if (result.ConnectionStatus != ConnectionStatus.Success) { throw new Exception($"Cannot connect to network: {result.ConnectionStatus}"); } onboardLed.StartPulse(Color.Green); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); Up = new PwmLed(Device.CreatePwmPort(Device.Pins.D07, 100, 0.0f), TypicalForwardVoltage.Red); Down = new PwmLed(Device.CreatePwmPort(Device.Pins.D04, 100, 0.0f), TypicalForwardVoltage.Red); Left = new PwmLed(Device.CreatePwmPort(Device.Pins.D02, 100, 0.0f), TypicalForwardVoltage.Red); Right = new PwmLed(Device.CreatePwmPort(Device.Pins.D03, 100, 0.0f), TypicalForwardVoltage.Red); joystick = new AnalogJoystick( Device.CreateAnalogInputPort(Device.Pins.A01), Device.CreateAnalogInputPort(Device.Pins.A00), null, true); joystick.SetCenterPosition(); joystick.Updated += JoystickUpdated; joystick.StartUpdating(TimeSpan.FromMilliseconds(100)); onboardLed.SetColor(Color.Green); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.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); onboardLed.SetColor(Color.Green); }
async Task Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); DisplayController.Current.Initialize(); displayController = DisplayController.Current; displayController.ShowSplashScreen(); var connectionResult = await Device.WiFiAdapter.Connect(Secrets.WIFI_NAME, Secrets.WIFI_PASSWORD); if (connectionResult.ConnectionStatus != ConnectionStatus.Success) { throw new Exception($"Cannot connect to network: {connectionResult.ConnectionStatus}"); } mapleServer = new MapleServer( Device.WiFiAdapter.IpAddress, 5417, true ); onboardLed.SetColor(Color.Green); }
async void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); onboardLed.SetColor(Color.Red); Console.WriteLine($"Connecting to WiFi Network Meadow"); Console.WriteLine("Connecting to WiFi Network Meadow"); Device.InitWiFiAdapter().Wait(); ScanForAccessPoints(); ConnectionResult result = Device.WiFiAdapter.Connect("Meadow", "testtest").Result; if (result.ConnectionStatus != ConnectionStatus.Success) { //if (Device.WiFiAdapter.Connect(Secrets.WIFI_NAME, Secrets.WIFI_PASSWORD).ConnectionStatus != ConnectionStatus.Success) { throw new Exception($"Cannot connect to network: {result.ConnectionStatus}"); } Console.WriteLine("Connection request completed."); Console.WriteLine("Connection request completed."); onboardLed.SetColor(Color.Green); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); var i2CBus = Device.CreateI2cBus(); radio = new Tea5767(i2CBus); var display = new Ssd1306(i2CBus, 60, Ssd1306.DisplayType.OLED128x32); graphics = new MicroGraphics(display); graphics.Rotation = RotationType._180Degrees; btnNext = new PushButton(Device, Device.Pins.D03); btnNext.Clicked += BtnNextClicked; btnPrevious = new PushButton(Device, Device.Pins.D04); btnPrevious.Clicked += BtnPreviousClicked; onboardLed.SetColor(Color.Green); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.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 ); onboardLed.SetColor(Color.Green); }
void Initialize() { var onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); displayController = new DisplayControllers(); piezo = new PiezoSpeaker(Device, Device.Pins.D09); button = new PushButton(device: Device, Device.Pins.D04); button.PressStarted += ButtonPressStarted; button.PressEnded += ButtonPressEnded; stopWatch = new Stopwatch(); timer = new Timer(2000); timer.Elapsed += TimerElapsed; LoadMorseCode(); ShowLetterQuestion(); onboardLed.SetColor(Color.Green); }
async Task Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f); onboardLed.SetColor(Color.Red); // initialize the wifi adpater if (!Device.InitWiFiAdapter().Result) { throw new Exception("Could not initialize the WiFi adapter."); } // connnect to the wifi network. Console.WriteLine($"Connecting to WiFi Network {Secrets.WIFI_NAME}"); var connectionResult = await Device.WiFiAdapter.Connect(Secrets.WIFI_NAME, Secrets.WIFI_PASSWORD); if (connectionResult.ConnectionStatus != ConnectionStatus.Success) { throw new Exception($"Cannot connect to network: {connectionResult.ConnectionStatus}"); } Console.WriteLine($"Connected. IP: {Device.WiFiAdapter.IpAddress}"); // create our maple web server mapleServer = new MapleServer(Device.WiFiAdapter.IpAddress, 5417, true); mapleServer.Start(); onboardLed.SetColor(Color.Green); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); var config = new SpiClockConfiguration( speed: new Frequency(48000, Frequency.UnitType.Kilohertz), mode: SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus( clock: Device.Pins.SCK, copi: Device.Pins.MOSI, cipo: Device.Pins.MISO, config: config); var display = new St7789( device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240); graphics = new MicroGraphics(display); graphics.Rotation = RotationType._180Degrees; graphics.CurrentFont = new Font12x16(); sensor = new Mpr121(Device.CreateI2cBus(I2cBusSpeed.Standard), 90, 100); sensor.ChannelStatusesChanged += SensorChannelStatusesChanged; onboardLed.SetColor(Color.Green); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); notes = new float[] { 261.63f, 329.63f, 392, 523.25f }; game = new SimonGame(); leds = new PwmLed[4]; leds[0] = new PwmLed(Device, Device.Pins.D10, TypicalForwardVoltage.Red); leds[1] = new PwmLed(Device, Device.Pins.D09, TypicalForwardVoltage.Green); leds[2] = new PwmLed(Device, Device.Pins.D08, TypicalForwardVoltage.Blue); leds[3] = new PwmLed(Device, Device.Pins.D07, TypicalForwardVoltage.Yellow); buttons = new PushButton[4]; buttons[0] = new PushButton(Device, Device.Pins.MISO); buttons[0].Clicked += ButtonRedClicked; buttons[1] = new PushButton(Device, Device.Pins.D02); buttons[1].Clicked += ButtonGreenClicked; buttons[2] = new PushButton(Device, Device.Pins.D03); buttons[2].Clicked += ButtonBlueClicked; buttons[3] = new PushButton(Device, Device.Pins.D04); buttons[3].Clicked += ButtonYellowClicked; speaker = new PiezoSpeaker(Device, Device.Pins.D12); onboardLed.SetColor(Color.Green); }
void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); var config = new SpiClockConfiguration(3000, SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); button = Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeRising, ResistorMode.Disabled); button.Changed += Button_Changed; //display display = new St7789( device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240); graphics = new GraphicsLibrary(display); graphics.CurrentFont = new Font12x20(); sensor = new Bmp180(Device.CreateI2cBus()); sensor.Updated += Sensor_Updated; sensor.StartUpdating(); }
void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); Console.WriteLine("Create Display with SPI..."); var config = new Meadow.Hardware.SpiClockConfiguration(12000, Meadow.Hardware.SpiClockConfiguration.Mode.Mode0); var bus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); ssd1309 = new Ssd1309 ( device: Device, spiBus: bus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00 ); Console.WriteLine("Create GraphicsLibrary..."); display = new GraphicsLibrary(ssd1309) { CurrentFont = new Font8x12(), // Rotation = GraphicsLibrary.RotationType._270Degrees }; Console.WriteLine("Load menu data..."); var menuData = LoadResource("menu.json"); Console.WriteLine($"Data length: {menuData.Length}..."); Console.WriteLine("Create buttons..."); var encoder = new RotaryEncoderWithButton(Device, Device.Pins.D13, Device.Pins.D14, Device.Pins.D15); // next = new PushButton(Device, Device.Pins.D15); // select = new PushButton(Device, Device.Pins.D12); // previous = new PushButton(Device, Device.Pins.D11); Console.WriteLine("Create menu..."); // menu = new Menu(display, next, previous, select, menuData, false); menu = new Menu(display, encoder, menuData, false); Console.WriteLine("Enable menu..."); menu.Enable(); }
void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); var spiBus = Device.CreateSpiBus(); display = new ZXBox.MeadowApp.Display.Ssd1351( device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D00, dcPin: Device.Pins.D02, resetPin: Device.Pins.D01, width: 128, height: 127); //graphics.Clear(); //graphics.Show(); speccy = new ZXSpectrum(true, true, 32, 32, 0); speccy.Reset(); graphics = new GraphicsLibrary(display); display.Clear(true); display.ClearScreen(1); display.InvertDisplay(false); graphics.DrawRectangle(0, 0, 127, 127, Color.FromHex("#00cdcd"), true); graphics.Show(); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); var i2CBus = Device.CreateI2cBus(); var display = new Ssd1306(i2CBus, 60, Ssd1306.DisplayType.OLED128x32); graphics = new MicroGraphics(display); graphics.Rotation = 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; onboardLed.SetColor(Color.Green); }
void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); Console.WriteLine("Create Display with SPI..."); var config = new Meadow.Hardware.SpiClockConfiguration(6000, Meadow.Hardware.SpiClockConfiguration.Mode.Mode0); var bus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); display = new Ssd1309 ( device: Device, spiBus: bus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00 ); Console.WriteLine("Create Graphics Library..."); graphics = new GraphicsLibrary(display); graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; graphics.CurrentFont = new Font8x12(); graphics.Clear(); graphics.DrawText(0, 0, "Hello"); graphics.Show(); Console.WriteLine("Create buttons..."); portLeft = Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.PullDown); portUp = Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.PullDown); portRight = Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.PullDown); portDown = Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.PullDown); portRight.Changed += PortRight_Changed; portLeft.Changed += PortLeft_Changed; portUp.Changed += PortUp_Changed; portDown.Changed += PortDown_Changed; /* btnUp = new PushButton(Device, Device.Pins.D13); * btnLeft = new PushButton(Device, Device.Pins.D12); * btnDown = new PushButton(Device, Device.Pins.D11); * btnRight = new PushButton(Device, Device.Pins.D10); * * btnUp.Clicked += BtnUp_Clicked; * btnLeft.Clicked += BtnLeft_Clicked; * btnDown.Clicked += BtnDown_Clicked; * btnRight.Clicked += BtnRight_Clicked; */ }
void TestMultiplePorts() { led = new RgbPwmLed( Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(Color.Red); // Important note: You can only use on Push Button per Group Set (GSXX) pushButtons = new List <PushButton> { //new PushButton(Device, Device.Pins.A04), // <- GS00 new PushButton(Device, Device.Pins.D06), // <- GS00 //new PushButton(Device, Device.Pins.A05), // <- GS01 new PushButton(Device, Device.Pins.D09), // <- GS01 //new PushButton(Device, Device.Pins.A02), // <- GS03 new PushButton(Device, Device.Pins.D14), // <- GS03 //new PushButton(Device, Device.Pins.D15) // <- GS03 new PushButton(Device, Device.Pins.A00), // <- GS04 //new PushButton(Device, Device.Pins.A01), // <- GS05 new PushButton(Device, Device.Pins.MOSI), // <- GS05 new PushButton(Device, Device.Pins.D02), // <- GS06 //new PushButton(Device, Device.Pins.D08), // <- GS06 //new PushButton(Device, Device.Pins.A03), // <- GS07 new PushButton(Device, Device.Pins.D05), // <- GS07 //new PushButton(Device, Device.Pins.D07), // <- GS07 new PushButton(Device, Device.Pins.D03), // <- GS08 new PushButton(Device, Device.Pins.D00), // <- GS09 //new PushButton(Device, Device.Pins.D04), // <- GS09 //new PushButton(Device, Device.Pins.D11), // <- GS09 new PushButton(Device, Device.Pins.MISO), // <- GS11 new PushButton(Device, Device.Pins.D12), // <- GS14 new PushButton(Device, Device.Pins.D13), // <- GS15 }; foreach (var pushButton in pushButtons) { pushButton.Clicked += PushButtonClicked; pushButton.PressStarted += PushButtonPressStarted; pushButton.PressEnded += PushButtonPressEnded; pushButton.LongPressClicked += PushButtonLongPressClicked; } led.SetColor(Color.Green); }
public MeadowApp() { rgbPwmLed = new RgbPwmLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); PulseRgbPwmLed(); }
public RgbPwmLedApp() { rgbPwmLed = new RgbPwmLed( Device.CreatePwmPort(Device.Pins.D11), Device.CreatePwmPort(Device.Pins.D05), Device.CreatePwmPort(Device.Pins.D02)); TestRgbPwmLed(); }
public void ConfigurePeripherals() { Console.WriteLine("Creating peripherals..."); this._onboard = new RgbPwmLed( Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue, commonType: CommonType.CommonAnode); }
void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); Console.WriteLine("Create Display with SPI..."); var config = new SpiClockConfiguration(12000, SpiClockConfiguration.Mode.Mode0); var bus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); ssd1309 = new Ssd1309 ( device: Device, spiBus: bus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00 ); Console.WriteLine("Create GraphicsLibrary..."); graphics = new GraphicsLibrary(ssd1309) { CurrentFont = new Font8x12(), }; graphics.Clear(); graphics.DrawText(0, 0, "Loading Menu"); graphics.Show(); CreateMenu(graphics); Console.WriteLine("Create buttons..."); up = new PushButton(Device, Device.Pins.D14, ResistorMode.Disabled); up.Clicked += Up_Clicked; left = new PushButton(Device, Device.Pins.D11, ResistorMode.Disabled); left.Clicked += Left_Clicked; right = new PushButton(Device, Device.Pins.D10, ResistorMode.Disabled); right.Clicked += Right_Clicked; down = new PushButton(Device, Device.Pins.D12, ResistorMode.Disabled); down.Clicked += Down_Clicked; menu.Enable(); }
void Initialize() { onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); onboardLed.SetColor(Color.Red); var config = new SpiClockConfiguration( speedKHz: 12000, mode: SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus( clock: Device.Pins.SCK, mosi: Device.Pins.MOSI, miso: Device.Pins.MISO, config: config); st7789 = new St7789 ( device: Device, spiBus: spiBus, chipSelectPin: null, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); graphics = new GraphicsLibrary(st7789) { CurrentFont = new Font12x20(), }; graphics.Clear(); var menuData = LoadFromJson("menu.json"); //var menuData = LoadFromCode(); menu = new Menu(graphics, menuData, false); next = new PushButton(Device, Device.Pins.D03, ResistorMode.InternalPullUp); next.Clicked += (s, e) => { menu.Next(); }; select = new PushButton(Device, Device.Pins.D04, ResistorMode.InternalPullUp); select.Clicked += (s, e) => { menu.Select(); }; previous = new PushButton(Device, Device.Pins.D02, ResistorMode.InternalPullUp); previous.Clicked += (s, e) => { menu.Previous(); }; onboardLed.SetColor(Color.Green); menu.Enable(); }
public MeadowApp() { Console.WriteLine("Initializing..."); rgbPwmLed = new RgbPwmLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); MainLoop(); }
void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); var config = new SpiClockConfiguration( speed: new Frequency(48000, Frequency.UnitType.Kilohertz), mode: SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus( clock: Device.Pins.SCK, copi: Device.Pins.MOSI, cipo: Device.Pins.MISO, config: config); var st7789 = new St7789 ( device: Device, spiBus: spiBus, chipSelectPin: null, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); graphics = new MicroGraphics(st7789) { CurrentFont = new Font12x20(), }; graphics.Clear(); var menuData = LoadFromJson("menu.json"); //var menuData = LoadFromCode(); menu = new Menu(graphics, menuData, false); next = new PushButton(Device, Device.Pins.D03, ResistorMode.InternalPullUp); next.Clicked += (s, e) => { menu.Next(); }; select = new PushButton(Device, Device.Pins.D04, ResistorMode.InternalPullUp); select.Clicked += (s, e) => { menu.Select(); }; previous = new PushButton(Device, Device.Pins.D02, ResistorMode.InternalPullUp); previous.Clicked += (s, e) => { menu.Previous(); }; onboardLed.SetColor(Color.Green); menu.Enable(); }
public void Init() { Console.WriteLine("Init..."); sensor = new Bh1745(Device.CreateI2cBus()); rgbLed = new RgbPwmLed( Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue, commonType: CommonType.CommonAnode); }
async Task Initialize() { RgbPwmLed onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); onboardLed.StartPulse(Color.Red); display = new Max7219( device: Device, spiBus: Device.CreateSpiBus(), csPin: Device.Pins.D01, deviceCount: 4, maxMode: Max7219.Max7219Type.Display); graphics = new GraphicsLibrary(display); graphics.CurrentFont = new Font4x8(); graphics.Rotation = GraphicsLibrary.RotationType._180Degrees; graphics.Clear(); graphics.DrawText(0, 1, "WI"); graphics.DrawText(0, 9, "FI"); graphics.DrawText(0, 17, "TI"); graphics.DrawText(0, 25, "ME"); graphics.Show(); pushButton = new PushButton(Device, Device.Pins.D04, ResistorMode.InternalPullUp); pushButton.Clicked += PushButtonClicked; analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); Device.InitWiFiAdapter().Wait(); onboardLed.StartPulse(Color.Blue); var result = await Device.WiFiAdapter.Connect(Secrets.WIFI_NAME, Secrets.WIFI_PASSWORD); if (result.ConnectionStatus != ConnectionStatus.Success) { onboardLed.StartPulse(Color.Magenta); throw new Exception($"Cannot connect to network: {result.ConnectionStatus}"); } onboardLed.StartPulse(Color.Green); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); onboardLed.SetColor(Color.Green); }
void Initialize() { Console.WriteLine("Initialize hardware..."); Console.WriteLine("Onboard LED"); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); // configure our BME280 on the I2C Bus Console.WriteLine("BME280"); var i2c = Device.CreateI2cBus(); bme280 = new Bme280( i2c, Bme280.I2cAddress.Adddress0x76 ); // configure our AnalogTemperature sensor Console.WriteLine("Analog Temp"); anlgTemp = new AnalogTemperature( device: Device, analogPin: Device.Pins.A02, sensorType: AnalogTemperature.KnownSensorType.TMP35 ); //a02 = Device.CreateAnalogInputPort(Device.Pins.A02); Console.WriteLine("Relays"); relays[0] = new Relay(Device, Device.Pins.D04); // Fan relays[1] = new Relay(Device, Device.Pins.D09); // Heat 1 relays[2] = new Relay(Device, Device.Pins.D10); // Heat 2 relays[3] = new Relay(Device, Device.Pins.D06); // Cool 1 relays[4] = new Relay(Device, Device.Pins.D05); // Cool 2 Console.WriteLine("Display"); var config = new SpiClockConfiguration(48000, SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); display = new St7789( device: Device, spiBus: spiBus, chipSelectPin: null, dcPin: Device.Pins.D00, resetPin: Device.Pins.D02, width: 240, height: 240); canvas = new GraphicsLibrary(display); }
protected void InitializePeripherals() { var rgbPwmLed = new RgbPwmLed ( N.PWMChannels.PWM_PIN_D11, N.PWMChannels.PWM_PIN_D10, N.PWMChannels.PWM_PIN_D9, 1.05f, 1.5f, 1.5f, false ); _rgbController = new RgbLedController(rgbPwmLed); }