Пример #1
0
        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();
        }
        void Initialize()
        {
            var config = new SpiClockConfiguration(
                speed: new Frequency(12000, Frequency.UnitType.Kilohertz),
                mode: SpiClockConfiguration.Mode.Mode0);
            var spiBus = Device.CreateSpiBus(
                clock: Device.Pins.SCK,
                copi: Device.Pins.MOSI,
                cipo: Device.Pins.MISO,
                config: config);

            display = new Ssd1309
                      (
                device: Device,
                spiBus: spiBus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                      );

            graphics             = new MicroGraphics(display);
            graphics.CurrentFont = new Font12x16();

            buttonLeft  = new PushButton(Device, Device.Pins.D11, ResistorMode.Disabled);
            buttonRight = new PushButton(Device, Device.Pins.D10, ResistorMode.Disabled);
            buttonUp    = new PushButton(Device, Device.Pins.D09, ResistorMode.Disabled);
            buttonDown  = new PushButton(Device, Device.Pins.D12, ResistorMode.Disabled);

            speaker = new PiezoSpeaker(Device, Device.Pins.D13);
        }
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            portLeft  = Device.CreateDigitalInputPort(Device.Pins.D13);
            portRight = Device.CreateDigitalInputPort(Device.Pins.D11);
            portDown  = Device.CreateDigitalInputPort(Device.Pins.D12);
            portReset = Device.CreateDigitalInputPort(Device.Pins.D07);

            speaker = new PiezoSpeaker(Device.CreatePwmPort(Device.Pins.D05));

            var config = new SpiClockConfiguration(
                speed: new Frequency(12000, Frequency.UnitType.Kilohertz),
                mode: SpiClockConfiguration.Mode.Mode0);
            var spiBus = Device.CreateSpiBus(
                clock: Device.Pins.SCK,
                copi: Device.Pins.MOSI,
                cipo: Device.Pins.MISO,
                config: config);
            var display = new Ssd1309
                          (
                device: Device,
                spiBus: spiBus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                          );

            graphics             = new MicroGraphics(display);
            graphics.CurrentFont = new Font4x8();
        }
Пример #7
0
        void Initialize()
        {
            portLeft  = Device.CreateDigitalInputPort(Device.Pins.D12);
            portUp    = Device.CreateDigitalInputPort(Device.Pins.D13);
            portRight = Device.CreateDigitalInputPort(Device.Pins.D07);
            portDown  = Device.CreateDigitalInputPort(Device.Pins.D11);

            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 Ssd1309
                          (
                device: Device,
                spiBus: spiBus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                          );

            graphics             = new MicroGraphics(display);
            graphics.CurrentFont = new Font4x8();
            graphics.Rotation    = RotationType._270Degrees;
        }
        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();
        }
Пример #9
0
        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()
        {
            var display = new Max7219(
                device: Device,
                spiBus: Device.CreateSpiBus(Max7219.DefaultSpiBusSpeed),
                csPin: Device.Pins.D01,
                deviceCount: 4,
                maxMode: Max7219.Max7219Type.Display);

            graphics             = new MicroGraphics(display);
            graphics.CurrentFont = new Font4x8();

            joystick = new AnalogJoystick(Device, Device.Pins.A01, Device.Pins.A02, null, true);
            joystick.StartUpdating(TimeSpan.FromMilliseconds(20));
        }
        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);

            var display = new Max7219(
                device: Device,
                spiBus: Device.CreateSpiBus(),
                csPin: Device.Pins.D01,
                deviceCount: 4,
                maxMode: Max7219.Max7219Type.Display);

            graphics             = new MicroGraphics(display);
            graphics.CurrentFont = new Font4x8();
            graphics.Rotation    = 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
                );

            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}");
            }

            onboardLed.StartPulse(Color.Green);
        }
        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);
        }
Пример #13
0
        public DisplayController(St7789 display)
        {
            graphics             = new MicroGraphics(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, ScaleFactor.X2);
            graphics.DrawText((240 - (monitor.Length * 24)) / 2, 130, monitor, Color.Black, ScaleFactor.X2);

            graphics.Show();
        }
Пример #14
0
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            ledDisplay = new Max7219(
                MeadowApp.Device,
                MeadowApp.Device.CreateSpiBus(),
                MeadowApp.Device.Pins.D00,
                deviceCount: 4,
                maxMode: Max7219.Max7219Type.Display);

            ledDisplay.IgnoreOutOfBoundsPixels = true;

            canvas             = new MicroGraphics(ledDisplay);
            canvas.Rotation    = RotationType._90Degrees;
            canvas.CurrentFont = new Font4x8();

            initialized = true;
        }
Пример #15
0
        public MeadowApp()
        {
            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: null,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00,
                width: 240, height: 240
                          );

            graphics          = new MicroGraphics(display);
            graphics.Rotation = RotationType._270Degrees;

            motionSensor = new ParallaxPir(Device, Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.Disabled, 5, 0);
            motionSensor.OnMotionStart += MotionSensorMotionStart;
            motionSensor.OnMotionEnd   += MotionSensorMotionEnd;

            onboardLed.SetColor(Color.Green);

            LoadScreen();
        }
Пример #16
0
        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);
        }
        public MeadowApp()
        {
            led = new RgbPwmLed(
                device: Device,
                redPwmPin: Device.Pins.OnboardLedRed,
                greenPwmPin: Device.Pins.OnboardLedGreen,
                bluePwmPin: Device.Pins.OnboardLedBlue);
            led.SetColor(Color.Red);

            buttonUp          = new PushButton(Device, Device.Pins.D03);
            buttonUp.Clicked += ButtonUpClicked;

            buttonDown          = new PushButton(Device, Device.Pins.D04);
            buttonDown.Clicked += ButtonDownClicked;

            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 Gc9a01
                          (
                device: Device,
                spiBus: spiBus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                          );

            graphics          = new MicroGraphics(display);
            graphics.Rotation = RotationType._90Degrees;

            DisplayJPG();

            led.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);

            analogTemperature = new AnalogTemperature(
                device: Device,
                analogPin: Device.Pins.A00,
                sensorType: AnalogTemperature.KnownSensorType.LM35
                );
            analogTemperature.TemperatureUpdated += AnalogTemperatureTemperatureUpdated; //+= AnalogTemperatureUpdated;

            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: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00,
                width: 240, height: 240);

            graphics          = new MicroGraphics(st7789);
            graphics.Rotation = RotationType._270Degrees;

            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);
            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.CurrentFont = new Font12x20();

            button          = Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeRising, ResistorMode.Disabled);
            button.Changed += Button_Changed;

            sensor          = new Bmp180(Device.CreateI2cBus());
            sensor.Updated += SensorUpdated;
            sensor.StartUpdating();

            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 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);

            graphics          = new MicroGraphics(st7789);
            graphics.Rotation = RotationType._270Degrees;

            onboardLed.SetColor(Color.Green);
        }