Beispiel #1
0
        protected void UpdateInfoScreen()
        {
            // if we're in the menu, get out.
            if (_inMenu)
            {
                return;
            }

            _display.Clear();
            _display.WriteLine("Super Coop 3000!", 0);
            _display.WriteLine("Current Temp: " + _tempSensor.Temperature.ToString("F1") + "C", 1);
            //_display.WriteLine("Target Temp: " + _targetTemp.ToString("F0") + "C", 2);
            _display.WriteLine("Click for more.", 3);
        }
Beispiel #2
0
        protected void UpdateInfoScreen()
        {
            // if we're in the menu, get out.
            if (_inMenu)
            {
                return;
            }

            _display.WriteLine("Current Temp: " + _tempSensor.Temperature.ToString("F1") + "C", 0);
            _display.WriteLine("Target Temp: " + _targetTemp.ToString("F0") + "C", 1);
            var remainingTime = _dehydrator.RunningTimeLeft;

            _display.WriteLine("Time: " + PadLeft(remainingTime.Hours.ToString(), '0', 2) + ":" + PadLeft(remainingTime.Minutes.ToString(), '0', 2), 2);
            _display.WriteLine("Click for more.", 3);
        }
Beispiel #3
0
        protected void InitializePeripherals()
        {
            // display
            //_display = new Lcd2004(new MCP23008());
            _display = new Lcd2004(N.Pins.GPIO_PIN_D8, N.Pins.GPIO_PIN_D9, N.Pins.GPIO_PIN_D10, N.Pins.GPIO_PIN_D11, N.Pins.GPIO_PIN_D12, N.Pins.GPIO_PIN_D13);
            _display.Clear();
            _display.WriteLine("Display up!", 0);

            // rotary encoder
            _encoder = new RotaryEncoderWithButton(N.Pins.GPIO_PIN_D4, N.Pins.GPIO_PIN_D5, N.Pins.GPIO_PIN_D7, CircuitTerminationType.CommonGround);

            // door stuff
            _doorServo          = new ContinuousRotationServo(N.PWMChannels.PWM_PIN_D6, NamedServoConfigs.IdealContinuousRotationServo);
            _openEndStopSwitch  = new PushButton(N.Pins.GPIO_PIN_D2, CircuitTerminationType.CommonGround);
            _closeEndStopSwitch = new PushButton(N.Pins.GPIO_PIN_D3, CircuitTerminationType.CommonGround);
            _display.WriteLine("Door stuff up!", 1);

            // temp stuff
            _heatLampRelay = new SoftPwm(N.Pins.GPIO_PIN_D0, 0, 1f / 60f);
            _tempSensor    = new AnalogTemperature(N.AnalogChannels.ANALOG_PIN_A0, AnalogTemperature.KnownSensorType.LM35, updateInterval: 5000, temperatureChangeNotificationThreshold: 1.0f);
            _display.WriteLine("Temp stuff up!", 2);

            //==== now wire up all the peripheral events
            // Analog Temp Sensor. Setup to notify at half a degree changes
            _tempSensor.TemperatureChanged += (object sender, SensorFloatEventArgs e) => {
                _currentTemp = e.CurrentValue;
                Debug.Print("Current Temp: " + _currentTemp.ToString("N1"));
                UpdateInfoScreen();
            };

            _encoder.Clicked += (s, e) =>
            {
                // if the menu isn't displayed, display it. otherwise
                // encoder click events are handled by menu
                if (!_inMenu)
                {
                    this.DisplayMenu();
                }
            };


            Debug.Print("Peripherals initialized.");
        }
Beispiel #4
0
        /// <summary>
        /// Configures the hardware perihperals (LCD, temp sensor, relays, etc.)
        /// so they can be used by the application.
        /// </summary>
        protected void InitializePeripherals()
        {
            // pushbutton (for testing)
            _pushButton = new PushButton(
                (H.Cpu.Pin) 0x15, CircuitTerminationType.Floating);

            // Rotary Encoder
            _encoder = new RotaryEncoderWithButton(
                N.Pins.GPIO_PIN_D7, N.Pins.GPIO_PIN_D6, N.Pins.GPIO_PIN_D5,
                CircuitTerminationType.CommonGround);

            // LCD
            //_display = new Lcd2004(new MCP23008());
            _display = new Lcd2004(N.Pins.GPIO_PIN_D8, N.Pins.GPIO_PIN_D9, N.Pins.GPIO_PIN_D10, N.Pins.GPIO_PIN_D11, N.Pins.GPIO_PIN_D12, N.Pins.GPIO_PIN_D13);
            _display.Clear();
            Debug.Print("Display up.");
            _display.WriteLine("Display up!", 0);

            // Analog Temp Sensor. Setup to notify at half a degree changes
            _tempSensor = new AnalogTemperature(N.AnalogChannels.ANALOG_PIN_A0,
                                                AnalogTemperature.KnownSensorType.LM35, temperatureChangeNotificationThreshold: 0.5F);
            Debug.Print("TempSensor up.");
            _display.WriteLine("Temp Sensor up!", 1);

            // Heater driven by Software PWM
            _heaterRelayPwm = new SoftPwm(N.Pins.GPIO_PIN_D2, 0.5f, 1.0f / 30.0f);
            Debug.Print("Heater PWM up.");
            _display.WriteLine("Heater PWM up!", 2);

            // Fan Relay
            _fanRelay = new Relay(N.Pins.GPIO_PIN_D3);
            Debug.Print("Fan up.");
            _display.WriteLine("Fan up!", 3);

            // output status
            Debug.Print("Peripherals up");
            _display.WriteLine("Peripherals online!", 0);
        }
Beispiel #5
0
        protected void ShowCurrentPage()
        {
            if (!IsEnabled)
            {
                Console.WriteLine("Render not enabled");
                return;
            }

            // clear the display
            display.ClearLines();

            // if there are no items to render, get out.
            if (currentMenuPage.MenuItems.Count <= 0)
            {
                return;
            }

            // if the scroll position is above the display area, move the display "window"
            if (currentMenuPage.ScrollPosition < topDisplayLine)
            {
                topDisplayLine = currentMenuPage.ScrollPosition;
            }

            // if the scroll position is below the display area, move the display "window"
            if (currentMenuPage.ScrollPosition > topDisplayLine + display.DisplayConfig.Height - 1)
            {
                topDisplayLine = currentMenuPage.ScrollPosition - display.DisplayConfig.Height + 1;
            }

            byte lineNumber = 0;

            MenuItem item;

            for (int i = topDisplayLine; i <= (topDisplayLine + display.DisplayConfig.Height - 1); i++)
            {
                if (i < currentMenuPage.MenuItems.Count)
                {
                    item = currentMenuPage.MenuItems[i];

                    // trim and add selection
                    string lineText = GetItemText(item, (i == currentMenuPage.ScrollPosition));
                    display.WriteLine(lineText, lineNumber);
                    lineNumber++;
                }
            }

            display.Show();
        }
Beispiel #6
0
        protected void RenderCurrentPage()
        {
            if (!IsEnabled)
            {
                return;
            }

            Console.WriteLine("ClearLines");
            // clear the display
            display.ClearLines();

            Console.WriteLine($"Count: {currentMenuPage.MenuItems.Count}");

            // if there are no items to render, get out.
            if (currentMenuPage.MenuItems.Count <= 0)
            {
                return;
            }

            // if the scroll position is above the display area, move the display "window"
            if (currentMenuPage.ScrollPosition < topDisplayLine)
            {
                topDisplayLine = currentMenuPage.ScrollPosition;
            }

            // if the scroll position is below the display area, move the display "window"
            if (currentMenuPage.ScrollPosition > topDisplayLine + display.DisplayConfig.Height - 1)
            {
                topDisplayLine = currentMenuPage.ScrollPosition - display.DisplayConfig.Height + 1;
            }

            Console.WriteLine("Scroll: " + currentMenuPage.ScrollPosition.ToString() + ", start: " + topDisplayLine.ToString() + ", end: " + (topDisplayLine + display.DisplayConfig.Height - 1).ToString());

            byte lineNumber = 0;

            for (int i = topDisplayLine; i <= (topDisplayLine + display.DisplayConfig.Height - 1); i++)
            {
                if (i < currentMenuPage.MenuItems.Count)
                {
                    IMenuItem item = currentMenuPage.MenuItems[i] as IMenuItem;

                    // trim and add selection
                    string lineText = GetItemText(item, (i == currentMenuPage.ScrollPosition));
                    display.WriteLine(lineText, lineNumber);
                    lineNumber++;
                }
            }
        }
Beispiel #7
0
        protected void RenderCurrentMenuPage()
        {
            if (!IsEnabled)
            {
                return;
            }

            // clear the display
            _display.ClearLines();

            // if there are no items to render, get out.
            if (_currentMenuPage.MenuItems.Count <= 0)
            {
                return;
            }

            // if the scroll position is above the display area, move the display "window"
            if (_currentMenuPage.ScrollPosition < _topDisplayLine)
            {
                _topDisplayLine = _currentMenuPage.ScrollPosition;
            }

            // if the scroll position is below the display area, move the display "window"
            if (_currentMenuPage.ScrollPosition > _topDisplayLine + _display.DisplayConfig.Height - 1)
            {
                _topDisplayLine = _currentMenuPage.ScrollPosition - _display.DisplayConfig.Height + 1;
            }

            Debug.WriteLine("Scroll: " + _currentMenuPage.ScrollPosition.ToString() + ", start: " + _topDisplayLine.ToString() + ", end: " + (_topDisplayLine + _display.DisplayConfig.Height - 1).ToString());

            byte lineNumber = 0;

            for (int i = _topDisplayLine; i <= (_topDisplayLine + _display.DisplayConfig.Height - 1); i++)
            {
                if (i < _currentMenuPage.MenuItems.Count)
                {
                    IMenuItem item = _currentMenuPage.MenuItems[i] as IMenuItem;

                    // trim and add selection
                    string lineText = GetItemText(item, (i == _currentMenuPage.ScrollPosition));
                    _display.WriteLine(lineText, lineNumber);
                    lineNumber++;
                }
            }
        }
Beispiel #8
0
 protected void UpdateInputLine(string text)
 {
     display.ClearLine(1);
     display.WriteLine(text, 1, true);
     display.Show();
 }