Пример #1
0
        /// <summary>
        /// Constructor for parallel LCD connection
        /// </summary>
        /// <param name="rs"></param>
        /// <param name="rw"></param>
        /// <param name="enable"></param>
        /// <param name="d4"></param>
        /// <param name="d5"></param>
        /// <param name="d6"></param>
        /// <param name="d7"></param>
        /// <param name="rows"></param>
        /// <param name="cols"></param>
        public clsLCD_MLC(Cpu.Pin rs, Cpu.Pin rw, Cpu.Pin enable, Cpu.Pin d4, Cpu.Pin d5, Cpu.Pin d6,
                          Cpu.Pin d7, byte rows, byte cols)
        {
            GpioLcdTransferProvider lcdProvider = new GpioLcdTransferProvider(rs, rw, enable, d4, d5, d6, d7);

            lcd = new Lcd(lcdProvider);
            lcd_begin(rows, cols);
        }
Пример #2
0
        public static void Main()
        {
            DateTime dt = Ds1307.GetDateTime();

            Utility.SetLocalTime(dt);

            var lcdProvider = new GpioLcdTransferProvider(Stm32F4Discovery.Pins.PD1,
                                                          Stm32F4Discovery.Pins.PD2,
                                                          Stm32F4Discovery.Pins.PD9,
                                                          Stm32F4Discovery.Pins.PD11,
                                                          Stm32F4Discovery.Pins.PD10,
                                                          Stm32F4Discovery.Pins.PD8);

            var lcd = new Lcd(lcdProvider);

            lcd.Begin(Columns, 2);

            var userButton = new InterruptPort(Stm32F4Discovery.ButtonPins.User,
                                               false, Port.ResistorMode.PullDown,
                                               Port.InterruptMode.InterruptEdgeLow);

            DateTime showUptimeMode = DateTime.MinValue;

            userButton.OnInterrupt += (d1, d2, t) => showUptimeMode = DateTime.Now.AddSeconds(ShowUptimeInterval);

            for (;;)
            {
                var now = DateTime.Now;

                string line1, line2;

                if (showUptimeMode > now)
                {
                    TimeSpan uptime    = GetUptime();
                    string   uptimeStr = uptime.ToString();
                    int      endIndex  = uptimeStr.LastIndexOf('.');
                    if (endIndex > Columns)
                    {
                        endIndex = Columns;
                    }

                    line1 = "Uptime:   ";
                    line2 = uptimeStr.Substring(0, endIndex);
                }
                else
                {
                    line1 = now.ToString("yyyy-MM-dd");
                    line2 = now.ToString("HH:mm:ss        ");
                }

                lcd.SetCursorPosition(0, 0);
                lcd.Write(line1);
                lcd.SetCursorPosition(0, 1);
                lcd.Write(line2);

                Thread.Sleep(100);
            }
        }
Пример #3
0
 public clsLCD_MLC(Cpu.Pin rs, Cpu.Pin rw, Cpu.Pin enable, Cpu.Pin d4, Cpu.Pin d5, Cpu.Pin d6,
                   Cpu.Pin d7, byte rows, byte cols)
 {
     lcdProvider = new GpioLcdTransferProvider(rs, rw, enable, d4, d5, d6, d7);
     lcd         = new Lcd(lcdProvider);
     SetScreenSize(rows, cols);
     lcd.Write("hello, world!");
     strBlankRow = new string(' ', cols);
 }
Пример #4
0
        public PinLcd(Cpu.Pin rs, Cpu.Pin enable, Cpu.Pin d4, Cpu.Pin d5, Cpu.Pin d6, Cpu.Pin d7)
        {
            var lcdProvider = new GpioLcdTransferProvider(
                FEZCerbuino.Pin.Digital.D7,   // RS
                FEZCerbuino.Pin.Digital.D8,   // enable
                FEZCerbuino.Pin.Digital.D9,   //d4
                FEZCerbuino.Pin.Digital.D10,  //d5
                FEZCerbuino.Pin.Digital.D11,  //d6
                FEZCerbuino.Pin.Digital.D12); // d7

            _display = new RawLcd(lcdProvider);
            Initialize();
        }
Пример #5
0
        public LcdDisplay()
        {
            var lcdProvider = new GpioLcdTransferProvider(Stm32F4Discovery.Pins.PD1, Stm32F4Discovery.Pins.PD2,
                                                          Stm32F4Discovery.Pins.PD9, Stm32F4Discovery.Pins.PD11,
                                                          Stm32F4Discovery.Pins.PD10, Stm32F4Discovery.Pins.PD8);

            _lcd = new Lcd(lcdProvider);

            _lcd.Begin(Columns, Rows);
            _lcd.Write("Wait...");

            //http://www.quinapalus.com/hd44780udg.html
            _lcd.CreateChar(0, new byte[] { 0x8, 0x14, 0x8, 0x3, 0x4, 0x4, 0x3, 0x0 });
            _lcd.Backlight = false;
        }
Пример #6
0
        public static void Main()
        {
            var lcdProvider = new GpioLcdTransferProvider(Stm32F4Discovery.Pins.PD1, Stm32F4Discovery.Pins.PD2,
                                                          Stm32F4Discovery.Pins.PD9, Stm32F4Discovery.Pins.PD11,
                                                          Stm32F4Discovery.Pins.PD10, Stm32F4Discovery.Pins.PD8);

            var lcd = new Lcd(lcdProvider);

            lcd.Begin(16, 2); //columns, rows

            //znaki specjalne
            //http://www.quinapalus.com/hd44780udg.html
            var customCharacters = new[]
            {
                new byte[] { 0x00, 0x0a, 0x15, 0x11, 0x11, 0x0a, 0x04, 0x00 },                         //serce
                new byte[] { 0x04, 0x02, 0x01, 0x1f, 0x01, 0x02, 0x04, 0x00 }                          //strzalka
            };

            //ladowanie znakow specjalnych
            for (int i = 0; i < customCharacters.Length; i++)
            {
                lcd.CreateChar(i, customCharacters[i]);
            }

            lcd.Clear();
            lcd.Write("* Hello World! *");
            Thread.Sleep(3000);

//            lcd.Clear();
//            lcd.Encoding = Encoding.UTF8;
//            lcd.Write("ĄąĆćĘꣳŃńÓ󌜯ż");
//            Thread.Sleep(3000);

            lcd.Clear();
            lcd.WriteByte(0); //pierwszy znak specjalny
            Thread.Sleep(2000);
            lcd.WriteByte(1); //drugi znak specjalny
            Thread.Sleep(3000);

            //nastepna linia
            lcd.SetCursorPosition(0, 1);
            lcd.Write("#     Bye...   #");
        }
Пример #7
0
        /// <summary>
        /// Funcion encargada de 3 cosas: Leer el sensor, mostrar datos por LCD y controlar el encendido y apagado de los relays.
        /// </summary>
        private static void readTemp()
        {
            OneWire _oneWire = new OneWire(new OutputPort(Pins.GPIO_PIN_D0, false));

            var lcdProvider = new GpioLcdTransferProvider(
                Pins.GPIO_PIN_D11,            // RS
                         Pins.GPIO_NONE,      // RW
                         Pins.GPIO_PIN_D9,    // enable
                         Pins.GPIO_PIN_D2,    // d0
                         Pins.GPIO_PIN_D4,    // d1
                         Pins.GPIO_PIN_D6,    // d2
                         Pins.GPIO_PIN_D8,    // d3
                         Pins.GPIO_PIN_D7,    // d4
                         Pins.GPIO_PIN_D5,    // d5
                         Pins.GPIO_PIN_D3,    // d6
                         Pins.GPIO_PIN_D1);   // d7

            var lcd = new Lcd(lcdProvider);

            lcd.Begin(16, 2);
            // apagamos todos los compomentes externos.
            // Infinite loop that reads the temp and stores it in tempAct
            while (true)
            {
                Double rango     = Datos.tempMax - Datos.tempMin;
                Double limiteSup = 0.50 * rango;
                Double limiteInf = 0.20 * rango;

                try
                {
                    if (_oneWire.TouchReset() > 0)
                    {
                        _oneWire.WriteByte(0xCC);     // Skip ROM, only one device
                        _oneWire.WriteByte(0x44);     // Temp conversion

                        while (_oneWire.ReadByte() == 0)
                        {
                            ;                                //Loading
                        }
                        _oneWire.TouchReset();
                        _oneWire.WriteByte(0xCC);     // Skip ROM
                        _oneWire.WriteByte(0xBE);     // Read

                        ushort temperature = (byte)_oneWire.ReadByte();
                        temperature  |= (ushort)(_oneWire.ReadByte() << 8); // MSB
                        Datos.tempAct = temperature / 16.0;



                        if (Datos.competi && !Datos.finishBattle)
                        {
                            //Debug.Print("------------------------------DENTRO DE PROGRAM.170-------------------");
                            // tanto el secador como el ventilador, operan en FALSE - circuito cerrado
                            if (Datos.tempAct >= (Datos.tempMax - limiteSup))      // FRIO
                            {
                                Secador.Write(false);
                                Ventilador1.Write(true);
                                Ventilador2.Write(true);
                                ledCool.Write(true);
                            }
                            else if (Datos.tempAct <= (Datos.tempMin + limiteInf)) // CALOR
                            {
                                Secador.Write(true);
                                Ventilador1.Write(false);
                                Ventilador2.Write(false);
                            }
                            else                                                   // APAGAMOS TODO
                            {
                                off();
                            }


                            //Datos.tempAct = Microsoft.SPOT.Math.(Datos.tempAct, 1);
                            lcd.Clear();
                            lcd.SetCursorPosition(0, 0);
                            lcd.Write("[" + Datos.tempMin.ToString("N1") + "-" + Datos.tempMax.ToString("N1") + "]");

                            lcd.SetCursorPosition(12, 0);
                            lcd.Write(Datos.roundTime.ToString() + "s");

                            lcd.SetCursorPosition(0, 1);
                            lcd.Write(Datos.tempAct.ToString("N1") + "C [" + Datos.timeInRangeTemp.ToString() + "s" + "]");

                            lcd.SetCursorPosition(13, 1);
                            lcd.Write(Datos.timeLeft.ToString());

                            Thread.Sleep(Datos.refresh);
                        }
                        if (!Datos.competi && !Datos.coolerMode)
                        {
                            lcd.Clear();
                            lcd.SetCursorPosition(0, 0);
                            lcd.Write("Temp War Grupo 1");
                            lcd.SetCursorPosition(0, 1);
                            lcd.Write("[" + Datos.tempAct.ToString("N1") + "C] Pts:" + Datos.timeInRangeTemp + "s");
                            Thread.Sleep(Datos.displayRefresh);
                        }
                        if (Datos.coolerMode)
                        {
                            lcd.Clear();
                            lcd.SetCursorPosition(0, 0);
                            lcd.Write("Cooling Mode.");
                            lcd.SetCursorPosition(0, 1);
                            lcd.Write("Temp: " + Datos.tempAct.ToString("N1") + "C");
                            Thread.Sleep(Datos.displayRefresh);
                            lcd.SetCursorPosition(0, 0);
                            lcd.Write("Cooling Mode..");
                            Thread.Sleep(Datos.displayRefresh);
                            lcd.SetCursorPosition(0, 0);
                            lcd.Write("Cooling Mode...");
                        }
                    }
                    else
                    {
                        Debug.Print("Fallo de sensor");
                        //Could be that you read to fast after previous read. Include
                        Thread.Sleep(1000);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Print("ReadTemperatureToConsole " + ex.Message);
                }
            }
        }