Exemplo n.º 1
0
        private void Main_Load(object sender, EventArgs e)
        {
            for (int j = 0; j < ledMatrix_row; j++)
            {
                ledPoint.Y = yLoc + 15;
                ledPoint.X = 0;
                xLoc       = 0;
                wSpace     = 5;

                for (int i = 0; i < ledMatrix_col; i++)
                {
                    loc = matrixLoc + 1;

                    if (i == 0)
                    {
                        yLoc = ledPoint.Y;
                    }

                    ledPoint.X = xLoc + 10 + wSpace;

                    RGBLed rgb_led = new RGBLed(loc);

                    rgb_led.Location = ledPoint;

                    wSpace = wSpace + 15;

                    ledPanel.Controls.Add(rgb_led);

                    matrixLoc++;
                }
            }
        }
Exemplo n.º 2
0
 public bool SetPorts(int red, int green, int blue)
 {
     if (_rgbLed == null)
     {
         _rgbLed = new RGBLed(red, green, blue);
     }
     else
     {
         _rgbLed.PinRed   = red;
         _rgbLed.PinGreen = red;
         _rgbLed.PinBlue  = red;
     }
     Console.WriteLine("Red: {0}, Green: {1}, Blue: {2}", _rgbLed.PinRed, _rgbLed.PinGreen, _rgbLed.PinBlue);
     return(true);
 }
Exemplo n.º 3
0
        async static Task Main(string[] args)
        {
            // Initialize
            // LED
            led = new Led(Gpio.Pin21);

            // RGB LED
            rgbLed = new RGBLed(Gpio.Pin28, Gpio.Pin29, Gpio.Pin03);

            // Relay
            relay = new Relay(Gpio.Pin04);

            CancellationTokenSource cts = null;

            // Button
            button        = new Button(Gpio.Pin22);
            button.Click += async(s, e) =>
            {
                cts = new CancellationTokenSource();
                StartBlinking(cts.Token);

                relay.State = true;

                if (Camera.IsBusy)
                {
                    Console.WriteLine("Camera is busy.");
                    return;
                }
                led.State = true;
                Console.WriteLine("Capturing image...");
                var result = await Camera.CaptureImageJpegAsync(3280, 2464, default);

                await File.WriteAllBytesAsync($"image-{DateTime.UtcNow.Ticks}.jpg", result);

                led.State = false;
                Console.WriteLine("Image captured.");

                await Task.Delay(3000);

                relay.State = false;

                cts.Cancel();
            };

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Exemplo n.º 4
0
        public MainPage()
        {
            this.InitializeComponent();

            m_trafficManager = new YaTrafficManager();
            m_trafficManager.OnDataChanged += OnTrafficDataChanged;

            try
            {
                m_rgbLed = new RGBLed(RED_PIN, GREED_PIN, BLUE_PIN);
            }
            catch (RGBLedException rgbLedEx)
            {
                switch (rgbLedEx.ErrorType)
                {
                case RGBLedError.E_GPIO_NOT_FOUND:
                    tbErrorMessage.Text = @"GPIO does not found on this device!";
                    break;

                case RGBLedError.E_OPEN_PIN_ERROR:
                    tbErrorMessage.Text = @"Opening pin error!";
                    break;

                default:
                    goto case RGBLedError.E_GPIO_NOT_FOUND;
                }
                tbErrorMessage.Visibility = Visibility.Visible;
                m_rgbLed = null;
            }

            m_timer          = new DispatcherTimer();
            m_timer.Interval = TimeSpan.FromMinutes(5.0);
            m_timer.Tick    += OnTimerTick;
            m_timer.Start();

            m_trafficManager.UpdateData(); // First run async
        }
Exemplo n.º 5
0
 public RGBLedService()
 {
     Console.WriteLine("Created new service instance.");
     _rgbLed = null;
 }