public MeadowApp() { 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; }
void Initialize() { Console.WriteLine("Initializing..."); var config = new SpiClockConfiguration(St7789.DefaultSpiBusSpeed, 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.D01, resetPin: Device.Pins.D00, width: displayWidth, height: displayHeight) { IgnoreOutOfBoundsPixels = true }; graphics = new MicroGraphicsEx(display) { Rotation = RotationType._270Degrees, Stroke = 1 }; allocated = GC.GetAllocatedBytesForCurrentThread(); graphics.Clear(); }
void Initialize() { Console.WriteLine("Initializing hardware..."); Console.WriteLine("Initialize SPI bus"); var config = new SpiClockConfiguration(12000, SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); Console.WriteLine("Initialize display driver instance"); St7789 display = new St7789(device: Device, spiBus: spiBus, chipSelectPin: null, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240); Console.WriteLine("Create graphics library"); canvas = new GraphicsLibrary(display) { CurrentFont = new Font12x20() }; canvas.DrawRectangle(0, 0, 240, 240, Color.Black, true); canvas.Clear(true); Console.WriteLine("Initialize distance sensor"); var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus); distanceSensor = new Vl53l0x(Device, i2cBus); }
public void Init() { Console.WriteLine("Init..."); sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100); sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged; Console.WriteLine("Create Spi bus"); var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); Console.WriteLine("Create display driver instance"); display = new St7789(device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 135, height: 240); Console.WriteLine("Create graphics lib"); graphics = new GraphicsLibrary(display); graphics.Rotation = GraphicsLibrary.RotationType._90Degrees; graphics.CurrentFont = new Font12x16(); }
void Initialize() { Console.WriteLine("Initialize hardware..."); Console.WriteLine("Create Spi bus"); var config = new SpiClockConfiguration(24000, SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); Console.WriteLine("Create display driver instance"); display = new St7789(device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 135, height: 240); Console.WriteLine("Create graphics lib"); graphics = new GraphicsLibrary(display); graphics.CurrentFont = new Font12x20(); graphics.Rotation = GraphicsLibrary.RotationType._90Degrees; Console.WriteLine("Create time of flight sensor"); var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus); sensor = new Vl53l0x(Device, i2cBus); sensor.StartUpdating(200); Console.WriteLine("Create servo"); }
void Initialize() { Console.WriteLine("Initialize hardware..."); portLeft = Device.CreateDigitalInputPort(Device.Pins.D02); portRight = Device.CreateDigitalInputPort(Device.Pins.D03); portDown = Device.CreateDigitalInputPort(Device.Pins.D04); portReset = Device.CreateDigitalInputPort(Device.Pins.D05); speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D06)); var config = new SpiClockConfiguration( speed: new Frequency(6000, 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.D10, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240); Console.WriteLine("Create graphics library"); graphics = new MicroGraphics(display); graphics.CurrentFont = new Font12x16(); }
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(); }
public MeadowApp() { Console.WriteLine("Initializing..."); this.analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); this.analogTemperature.Updated += AnalogTemperatureUpdated; var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3); this.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 ); this.displayWidth = Convert.ToInt32(this.st7789.Width); this.displayHeight = Convert.ToInt32(this.st7789.Height); this.graphics = new GraphicsLibrary(this.st7789); this.graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; this.LoadScreen(); this.analogTemperature.StartUpdating(); this.unitsTimer.AutoReset = true; this.unitsTimer.Elapsed += UnitsTimer_Elapsed; this.unitsTimer.Start(); }
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 config = new SpiClockConfiguration( new Frequency(48000, Frequency.UnitType.Kilohertz), SpiClockConfiguration.Mode.Mode3); var spiBus = MeadowApp.Device.CreateSpiBus( clock: MeadowApp.Device.Pins.SCK, copi: MeadowApp.Device.Pins.MOSI, cipo: MeadowApp.Device.Pins.MISO, config: config); var display = new St7789 ( device: MeadowApp.Device, spiBus: spiBus, chipSelectPin: null, dcPin: MeadowApp.Device.Pins.D01, resetPin: MeadowApp.Device.Pins.D00, width: 240, height: 240, displayColorMode: ColorType.Format16bppRgb565 ); graphics = new MicroGraphics(display) { Stroke = 1, CurrentFont = new Font12x20(), Rotation = RotationType._270Degrees }; graphics.Clear(); graphics.Show(); }
/// <summary> /// intializes the physical display peripheral, as well as the backing /// graphics library. /// </summary> protected void InitializeDisplay() { // our display needs mode3 var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3); // new up the actual display on the SPI bus display = new St7789 ( device: MeadowApp.Device, spiBus: MeadowApp.Device.CreateSpiBus(MeadowApp.Device.Pins.SCK, MeadowApp.Device.Pins.MOSI, MeadowApp.Device.Pins.MISO, config), chipSelectPin: null, dcPin: MeadowApp.Device.Pins.D01, resetPin: MeadowApp.Device.Pins.D00, width: 240, height: 240 ); // create our graphics surface that we'll draw onto and then blit // to the display with. graphics = new GraphicsLibrary(display) // my display is upside down // Rotation = GraphicsLibrary.RotationType._180Degrees, { CurrentFont = new Font12x20(), }; Console.WriteLine("Clear display"); // finally, clear the display so it's ready for action graphics.Clear(true); //Render(); }
private static St7789 InitializeLcdScreen(out int displayWidth, out int displayHeight, out GraphicsLibrary graphicsLibrary) { Console.WriteLine("Initializing LCD screen..."); SpiClockConfiguration config = new SpiClockConfiguration( speedKHz: 6000, SpiClockConfiguration.Mode.Mode3); ISpiBus spiBus = Device.CreateSpiBus( Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); St7789 st7789 = new St7789( device: Device, spiBus: spiBus, 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); graphicsLibrary = new GraphicsLibrary(st7789) { Rotation = GraphicsLibrary.RotationType._270Degrees }; LoadScreen(graphicsLibrary, displayWidth, displayHeight); return(st7789); }
void Initialize() { Console.WriteLine("Initialize hardware..."); portLeft = Device.CreateDigitalInputPort(Device.Pins.D02); portRight = Device.CreateDigitalInputPort(Device.Pins.D03); portDown = Device.CreateDigitalInputPort(Device.Pins.D04); portReset = Device.CreateDigitalInputPort(Device.Pins.D05); speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D06)); var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); Console.WriteLine("Create display driver instance"); display = new St7789(device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D10, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240); Console.WriteLine("Create graphics library"); graphics = new GraphicsLibrary(display); graphics.CurrentFont = new Font12x16(); }
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(); }
public MeadowApp() { Console.WriteLine("Start..."); //buttonUp = new PushButton(Device, Device.Pins.D02); //buttonUp.Clicked += ButtonUpClicked; //buttonDown = new PushButton(Device, Device.Pins.D03); //buttonDown.Clicked += ButtonDownClicked; //buttonMode = new PushButton(Device, Device.Pins.D04); //buttonMode.Clicked += ButtonModeClicked; var config = new SpiClockConfiguration(48000, SpiClockConfiguration.Mode.Mode3); st7789 = new St7789 ( device: Device, spiBus: Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config), chipSelectPin: null, dcPin: Device.Pins.D00, resetPin: Device.Pins.D02, width: 240, height: 240 ); graphics = new GraphicsLibrary(st7789); //WelcomeScreen(); //MainScreen(); AdjustTemperatureScreen(); Console.WriteLine("End..."); }
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..."); this.red = new Led(Device.CreateDigitalOutputPort(Device.Pins.OnboardLedRed)); this.green = new Led(Device.CreateDigitalOutputPort(Device.Pins.OnboardLedGreen)); this.red.IsOn = true; this.buttonNext = new PushButton( Device.CreateDigitalInputPort( Device.Pins.D03, InterruptMode.EdgeBoth, ResistorMode.Disabled )); this.buttonNext.Clicked += this.ButtonNextClicked; this.buttonPrevious = new PushButton( Device.CreateDigitalInputPort( Device.Pins.D04, InterruptMode.EdgeBoth, ResistorMode.Disabled )); this.buttonPrevious.Clicked += this.ButtonPreviousClicked; var config = new SpiClockConfiguration( speedKHz: 6000, mode: SpiClockConfiguration.Mode.Mode3); this.display = 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 ); this.display.IgnoreOutOfBoundsPixels = true; this.graphics = new GraphicsLibrary(display); this.graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; this.ShowJpeg(); this.red.IsOn = false; this.green.IsOn = true; }
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(); }
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); }
public MeadowApp() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); x = y = 120; 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); 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; onboardLed.SetColor(Color.Green); }
public void ConfigurePorts() { _blueLED = Device.CreateDigitalOutputPort(Device.Pins.OnboardLedBlue); var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3); _spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); _display = new St7789(device: Device, spiBus: _spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 135, height: 240); _graphicsLib = new GraphicsLibrary(_display); _graphicsLib.CurrentFont = new Font8x8(); _graphicsLib.Clear(); _graphicsLib.Rotation = GraphicsLibrary.RotationType._90Degrees; _display.Clear(Meadow.Foundation.Color.Black, true); }
protected void InitializeDisplay() { var config = new SpiClockConfiguration(12000, SpiClockConfiguration.Mode.Mode3); Display = new St7789(device: MeadowApp.Device, spiBus: MeadowApp.Device.CreateSpiBus(MeadowApp.Device.Pins.SCK, MeadowApp.Device.Pins.MOSI, MeadowApp.Device.Pins.MISO, config), chipSelectPin: null, dcPin: MeadowApp.Device.Pins.D01, resetPin: MeadowApp.Device.Pins.D00, width: 240, height: 240); Graphics = new GraphicsLibrary(Display) { CurrentFont = new Font12x20() }; Graphics.Clear(true); }
public DisplayController(St7789 display) { graphics = new GraphicsLibrary(display); graphics.CurrentFont = new Font12x20(); graphics.Stroke = 3; graphics.Clear(); graphics.DrawRectangle(0, 0, 240, 240, Color.White, true); string plant = "Plant"; string monitor = "Monitor"; graphics.CurrentFont = new Font12x16(); graphics.DrawText((240 - (plant.Length * 24)) / 2, 80, plant, Color.Black, GraphicsLibrary.ScaleFactor.X2); graphics.DrawText((240 - (monitor.Length * 24)) / 2, 130, monitor, Color.Black, GraphicsLibrary.ScaleFactor.X2); graphics.Show(); }
public MeadowApp() { Console.WriteLine("Initializing..."); this.analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); this.analogTemperature.Updated += this.AnalogTemperatureUpdated; SpiClockConfiguration config = new SpiClockConfiguration( speedKHz: 6000, SpiClockConfiguration.Mode.Mode3); ISpiBus spiBus = Device.CreateSpiBus( Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); this.st7789 = new St7789( device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); this.displayWidth = Convert.ToInt32(this.st7789.Width); this.displayHeight = Convert.ToInt32(this.st7789.Height); this.graphics = new GraphicsLibrary(this.st7789) { Rotation = GraphicsLibrary.RotationType._270Degrees }; this.LoadScreen(); this.analogTemperature.StartUpdating(); OnboardLed led = new OnboardLed(Device); led.SetColor(RgbColor.Green); }
public HackKitDisplay() { var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3); _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.D01, resetPin: Device.Pins.D00, width: 240, height: 240); _graphics = new GraphicsLibrary(_display); // my display is upside down"s _graphics.Rotation = GraphicsLibrary.RotationType._180Degrees; Console.WriteLine("Clear display"); //_display.ClearScreen(250); //_display.Refresh(); _graphics.Clear(true); //Console.WriteLine("Draw lines"); //for (int i = 0; i < 30; i++) { // _display.DrawPixel(i, i, true); // _display.DrawPixel(30 + i, i, true); // _display.DrawPixel(60 + i, i, true); //} _graphics.CurrentFont = new Font12x16(); _graphics.DrawText(4, 4, "current temp: 26º", Color.FromHex("24abe3")); _graphics.DrawText(4, 20, "desired temp: 24º", Color.FromHex("EF7D3B")); _graphics.DrawText(4, 40, "all temps Canadian", Color.White); _graphics.Show(); //Console.WriteLine("Show()"); //_display.Show(); //Console.WriteLine("shown."); }
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); }
void Initialize() { Console.WriteLine("Initializing..."); 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.D01, resetPin: Device.Pins.D00, width: displayWidth, height: displayHeight); graphics = new GraphicsLibrary(display); graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; graphics.Stroke = 1; graphics.Clear(true); }
public MeadowAppText() { 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 ); graphics = new GraphicsLibrary(st7789); graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; DrawTexts(); }
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(); }
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( new Frequency(48000, Frequency.UnitType.Kilohertz), SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus( Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, 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.CurrentFont = new Font12x20(); graphics.Rotation = RotationType._270Degrees; var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus); sensor = new Vl53l0x(Device, i2cBus); sensor.StartUpdating(TimeSpan.FromMilliseconds(200)); servo = new Servo(Device.CreatePwmPort(Device.Pins.D05), NamedServoConfigs.SG90); servo.RotateTo(new Angle(0, AU.Degrees)); onboardLed.SetColor(Color.Green); }