コード例 #1
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);
            }
        }
コード例 #2
0
 //public static LiquidCrystalI2C Lcd;
 private static void LCDFinish(Lcd lcd, string message)
 {
     lcd.SetCursorPosition(0, 1);
     lcd.Write(message);
     Thread.Sleep(600);
     lcd.Clear();
 }
コード例 #3
0
        public LCDTest()
        {
            // RS,RW,E,D4,D5,D6,D7
            RaspPiGPIOMemLcdTransferProvider lcdProvider = new RaspPiGPIOMemLcdTransferProvider(
                GPIOPins.Pin_P1_07,
                GPIOPins.Pin_P1_22,
                GPIOPins.Pin_P1_11,
                GPIOPins.Pin_P1_12,
                GPIOPins.Pin_P1_15,
                GPIOPins.Pin_P1_16,
                GPIOPins.Pin_P1_18);

            string meintext = "Hello World, how are you?";
            Lcd    lcd      = new Lcd(lcdProvider);

            lcd.Begin(16, 2);
            lcd.Clear();
            lcd.Backlight = false;
            lcd.SetCursorPosition(0, 0);
            lcd.Write(meintext);
            //System.Threading.Thread.Sleep (3);
            //lcd.Clear();
            //lcd.Write("Ahoj Bernie?!");
            System.Threading.Thread.Sleep(2000);
            int anzahl = meintext.Length;

            while (anzahl > 0)
            {
                lcd.ScrollDisplayLeft();
                System.Threading.Thread.Sleep(200);
                anzahl--;
            }
        }
コード例 #4
0
        public static void Main()
        {
            var setup = new BaseShifterLcdTransferProvider.ShifterSetup
            {
                BL     = ShifterPin.GP7,
                RS     = ShifterPin.GP1,
                RW     = ShifterPin.None,
                Enable = ShifterPin.GP2,
                D4     = ShifterPin.GP6,
                D5     = ShifterPin.GP5,
                D6     = ShifterPin.GP4,
                D7     = ShifterPin.GP3
            };
            var lcdBus = new Shifter74Hc595LcdTransferProvider(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D3,
                                                               Shifter74Hc595LcdTransferProvider.BitOrder.MSBFirst,
                                                               setup);
            var lcd = new Lcd(lcdBus);

            lcd.Begin(16, 2);
            lcd.Write("Hello, world!");
            while (true)
            {
                lcd.SetCursorPosition(0, 1);
                lcd.Write((Utility.GetMachineTime().Ticks / 10000).ToString());
                Microsoft.SPOT.Debug.Print("here");
                Thread.Sleep(100);
            }
        }
コード例 #5
0
        private void UpdateCalib()
        {
            var time = Clock.Instance.ElapsedMilliseconds / 1000;
            var test = _bno.GetCalibration();

            _lcd.Clear();
            _lcd.Write("S:" + test[0] + " G:" + test[1] + " A:" + test[2] + " M:" + test[3]);
            _lcd.SetCursorPosition(0, 1);
            _lcd.Write("T+ " + time + " s");
            Thread.Sleep(_delay);
        }
コード例 #6
0
        public void ShowTemperature(float temperature)
        {
            _lcd.SetCursorPosition(0, 0);
            const string txt     = "Temperatura:";
            int          padsCnt = Columns - txt.Length;

            _lcd.Write(txt + new string(' ', padsCnt));

            _lcd.SetCursorPosition(0, 1);

            string tempStr = temperature.ToString("F2");

            padsCnt = Columns - tempStr.Length;
            _lcd.Write(tempStr);
            _lcd.WriteByte(0); //znak specjalny

            if (padsCnt > 0)
            {
                var pads = new String(' ', padsCnt);
                _lcd.Write(pads);
            }
        }
コード例 #7
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...   #");
        }
コード例 #8
0
        public static void Main()
        {
            Debug.Print("Application started OK.");

            Debug.Print("Initialising the display");
            var setup = new BaseShifterLcdTransferProvider.ShifterSetup()
            {
                BL     = ShifterPin.GP7,
                RS     = ShifterPin.GP1,
                RW     = ShifterPin.None,
                Enable = ShifterPin.GP2,
                D4     = ShifterPin.GP6,
                D5     = ShifterPin.GP5,
                D6     = ShifterPin.GP4,
                D7     = ShifterPin.GP3
            };

            Debug.Print("Shifter setup correctly.");

            var lcdBus = new Shifter74Hc595LcdTransferProvider(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D3,
                                                               Shifter74Hc595LcdTransferProvider.BitOrder.MSBFirst, setup);

            Debug.Print("LCD Bus created.");

            var lcd = new Lcd(lcdBus);

            Debug.Print("LCD Created");

            lcd.Begin(16, 2);
            Debug.Print("Starting the application loop.");
            lcd.Write("Hello, world!");
            int count = 0;

            while (true)
            {
                count++;
                Debug.Print("Pass: " + count.ToString());
                lcd.SetCursorPosition(0, 1);
                lcd.Write((Utility.GetMachineTime().Ticks / 10000).ToString());
                Thread.Sleep(100);
            }
        }
コード例 #9
0
        public static void Main()
        {
            _bus = new I2CBus();

            initializeLCD(_bus);

            NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];

            LCD.CreateChar(0, new byte[] { 0xFF, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0xFF });
            LCD.CreateChar(1, new byte[] { 0xFF, 0x11, 0x11, 0x11, 0x11, 0x11, 0xFF, 0x00 });
            LCD.CreateChar(2, new byte[] { 0xFF, 0x11, 0x11, 0x11, 0x11, 0xFF, 0x00, 0x00 });
            LCD.CreateChar(3, new byte[] { 0xFF, 0x11, 0x11, 0x11, 0xFF, 0x00, 0x00, 0x00 });
            // Write out messages
            //LCD.Print(Lcd.Position.ROW_1, Lcd.Position.COLUMN_1, Lcd.FillRow(" Tony and Jessie's   "));
            LCD.Print(Lcd.Position.ROW_2, Lcd.Position.COLUMN_1, Lcd.FillRow("     Laser Tag!  "));
            LCD.Print(Lcd.Position.ROW_3, Lcd.Position.COLUMN_1, Lcd.FillRow("     Press Button  "));
            LCD.Print(Lcd.Position.ROW_4, Lcd.Position.COLUMN_1, Lcd.FillRow("     To Start Game  "));
            LCD.SetCursorPosition(0, 0);
            LCD.WriteByte(0x00);
            LCD.WriteByte(0x01);
            LCD.WriteByte(0x02);
            LCD.WriteByte(0x03);
        }
コード例 #10
0
        public static void Main()
        {
            serialPort.ReadTimeout = 0;

            string InitMessage = "Initializing...";

            // set up the LCD's number of columns and rows:
            lcd.Begin(columns: 16, lines: 2);
            lcd.Backlight = true;
            lcd.Clear();
            lcd.Clear();
            lcd.SetCursorPosition(0, 0);

            // Print a message to the LCD.
            lcd.Write(" *** ARMING ***");
            Thread.Sleep(250);

            lcd.SetCursorPosition(column: 0, row: 1);
            lcd.Write("HomeAlarmPlus Pi");
            Thread.Sleep(1600);
            lcd.Clear();
            lcd.SetCursorPosition(column: 0, row: 0);
            lcd.Write(InitMessage);
            Thread.Sleep(1600);

            for (int i = 0; i < InitMessage.Length; i++)
            {
                lcd.ScrollDisplayLeft();
                Thread.Sleep(85);
            }

            lcd.Clear();
            lcd.SetCursorPosition(column: 0, row: 0);
            lcd.Write("HomeAlarmPlus Pi");

            MonitorZonesDelegate monitorZones = new MonitorZonesDelegate(MonitorZones);

            MonitorMotionSensorDelegate monitorMotion = new MonitorMotionSensorDelegate(MonitorSensors);

            SdCardEventLogger.parseConfigFileContents(Alarm.User_Definitions.Constants.ALARM_CONFIG_FILE_PATH);
            syncHttpEvents = Stopwatch.StartNew();

            InitArrays();
            IPAddress = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress;
            Console.DEBUG_ACTIVITY(IPAddress);
            lcd.SetCursorPosition(column: 0, row: 1);
            lcd.Write("IP: " + IPAddress + "       ");

            Thread.Sleep(1000);
            SdCardEventLogger.SDCardAccess();

            lcd.SetCursorPosition(column: 0, row: 1);
            lcd.Write("Port: " + Alarm.ConfigDefault.Data.Http_port + "        ");
            Thread.Sleep(1000);

            new Thread(Alarm.WebServer.startHttp).Start();

            //Time from Raspberry Pi
            Debug.Print("Setting Date and Time from Network");
            lcd.SetCursorPosition(column: 0, row: 1);
            lcd.Write("Finding RPi-srvr");
            Notification.PushingBox.Connect("vPUSHINGBOX");

            //Let's notify Pushover
            //With extension.replace spaces are replaced with %20 so that is recognized by PHP when posting parameters.
            string time  = DateTime.Now.ToString();
            string ttime = Extension.Replace(time, " ", "%20");

            Notification.Pushover.Connect(ttime, Extension.Replace("Netduino Plus Time set", " ", "%20"), Extension.Replace("Time set from Raspberry Pi", " ", "%20"), false);

            LastResetCycle  = DateTime.Now.ToString("ddd, d MMM yyyy hh:mm:ss tt\r\n");
            dLastResetCycle = DateTime.Now;
            Thread.Sleep(2000);

            lcd.SetCursorPosition(column: 0, row: 0);
            lcd.Write("Syncing data           ");
            lcd.SetCursorPosition(column: 0, row: 1);
            lcd.Write("Wunderground       ");
            parseWeatherData(ttime);
            Thread.Sleep(2000);

            lcd.Clear();
            lcd.SetCursorPosition(column: 0, row: 0);
            lcd.Write("HomeAlarmPlus Pi");
            lcd.SetCursorPosition(column: 0, row: 1);
            lcd.Write("Temp: " + Alarm.Common.Weather_Info.current_temperature + "      ");
            Thread.Sleep(2000);

            lcd.SetCursorPosition(column: 0, row: 1);
            lcd.Write("SYSTEM READY           ");
            Debug.Print("ARMED!");
            Thread.Sleep(560);
            ATTINYx5.Write(true);

            lcd.Clear();

            int count = 0, sub_count = 0;

            while (true)
            {
                Console.DEBUG_ACTIVITY("Main Method - Memory available: " + Debug.GC(true));
                monitorZones();
                //monitorMotion();

                lcd.Clear();
                if (count % 2 == 0)
                {
                    lcd.SetCursorPosition(column: 0, row: 0);
                    lcd.Write("  Date    Time");
                    lcd.SetCursorPosition(column: 0, row: 1);
                    lcd.Write(DateTime.Now.ToString("MMM dd/yy h:mmtt ").ToUpper());
                }
                else
                {
                    lcd.SetCursorPosition(column: 0, row: 0);
                    lcd.Write("  Current Temp");

                    lcd.SetCursorPosition(column: 0, row: 1);

                    if (sub_count % 2 == 0)
                    {
                        lcd.Write(Alarm.Common.Weather_Info.current_temperature + " " + Alarm.Common.Weather_Info.current_conditions);
                    }
                    else
                    {
                        lcd.Write("Hi: " + Alarm.Common.Weather_Info.today_high + " Lo: " + Alarm.Common.Weather_Info.today_low);
                    }

                    sub_count++;
                }

                Thread.Sleep(Alarm.Common.Alarm_Constants.ALARM_DELAY_TIME);

                double eHours = syncHttpEvents.ElapsedHours;
                if (eHours >= Alarm.ConfigDefault.Data.WUNDERGROUND_SYNC_FREQUENCY)
                {
                    parseWeatherData(Extension.Replace(DateTime.Now.ToString(), " ", "%20"));
                    syncHttpEvents = Stopwatch.StartNew();
                }

                count++;
            }
        }
コード例 #11
0
 public void SetCursorPosition(short column, short row)
 {
     lcd.SetCursorPosition(column, row);
 }
コード例 #12
0
ファイル: Program.cs プロジェクト: maximilianomathias/TempWar
        /// <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);
                }
            }
        }
コード例 #13
0
ファイル: clsLCD_MLC.cs プロジェクト: edesiocs/gigamega-micro
 /// <summary>
 /// Set the cursor to column 1 of the specified row, and optionally clear that row.
 /// </summary>
 /// <param name="intLine">row # (1-based)</param>
 /// <param name="blnClearLine">if true, blanks are written to the row to clear it</param>
 public void SelectLine(byte intLine, bool blnClearLine)
 {
     lcd.SetCursorPosition(0, intLine - 1);
     lcd.Write(strBlankRow);
     lcd.SetCursorPosition(0, intLine - 1);
 }