Exemple #1
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--;
            }
        }
        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);
            }
        }
Exemple #3
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);
            }
        }
        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;
        }
Exemple #5
0
        private static void initializeLCD(I2CBus bus)
        {
            // Use I2C provider
            // Default configuration coresponds to Adafruit's LCD backpack
            // Initialize provider (multiple devices can be attached to same bus)
            var lcdProvider = new MCP23008LcdTransferProvider(_bus);

            // Create the LCD interface
            LCD = new Lcd(lcdProvider);
            // Set the LCD Color property = Led.  This is for cleaner code only.
            //LCD.Color = Led;
            // Set up the LCD's number of columns and rows:
            LCD.Begin(20, 4);
            // Clear the LCD
            LCD.Clear();
        }
Exemple #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...   #");
        }
        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);
            }
        }
Exemple #8
0
        public LCD()
        {
            //Switched to shift register solution on 5/31/2011
            //var lcdProvider = new GpioLcdTransferProvider(
            //    Pins.GPIO_PIN_D12,  // RS
            //    Pins.GPIO_NONE,     // RW
            //    Pins.GPIO_PIN_D11,  // enable
            //    Pins.GPIO_PIN_D9,   // d0
            //    Pins.GPIO_PIN_D8,   // d1
            //    Pins.GPIO_PIN_D7,   // d2
            //    Pins.GPIO_PIN_D6,   // d3
            //    Pins.GPIO_PIN_D5,   // d4
            //    Pins.GPIO_PIN_D4,   // d5
            //    Pins.GPIO_PIN_D3,   // d6
            //    Pins.GPIO_PIN_D2);  // d7

            var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_D10);

            // create the LCD interface
            lcd = new Lcd(lcdProvider);

            // set up the number of columns and rows:
            lcd.Begin(16, 2);
        }
        public static void Main()
        {
            var bus = new I2CBus();

            var lcdProvider = new MCP23008LcdTransferProvider(bus);
            var lcd         = new Lcd(lcdProvider);

            lcd.Begin(16, 2);
            lcd.Backlight = true;
            lcd.Write("Payload McPayload Face v1.0");
            for (int i = 0; i < 12; i++)
            {
                lcd.ScrollDisplayLeft();
                Thread.Sleep(200);
            }
            Thread.Sleep(1000);
            lcd.Clear();
            LCDFinish(lcd, "ACC DemoSat 2016");

            //THIS SECTION CREATES / INITIALIZES THE SERIAL LOGGER
            Debug.Print("Flight computer started successfully. Beginning INIT.");

            //Lcd = new LiquidCrystalI2C(0x01, 16, 2);
            //Lcd.write("Testing!");
            lcd.Write("Starting logger.");
            var logger = new Logger();

            Debug.Print("Starting logger.");
            logger.Start();
            LCDFinish(lcd, "Done.");


            lcd.Write("Starting clock...");
            Rebug.Print("Starting clock.");
            Clock.Instance.Start();
            LCDFinish(lcd, "Done.");

            //THIS SECTION CREATES/INITIALIZES THE PRESSURE SENSOR
            //lcd.Write("Init BMP sensor.");
            //Rebug.Print("Initializing BMP Sensor ");
            //var bmploop = new PressureTempAltitudeUpdater(bus, delay: 1000);
            //LCDFinish(lcd);

            //THIS SECTION CREATES/INITIALIZES THE SERIAL BNO 100HZ UPDATER
            lcd.Write("Init BNO sensor...");
            Rebug.Print("Initializing BNO Sensor ");
            var bno     = new SerialBno(SerialPorts.COM1, 5000, 5000, SerialBno.Bno055OpMode.OperationModeNdof);
            var bnoloop = new SerialBnoUpdater(bno, delay: 1000);

            LCDFinish(lcd, "Done.");

            ////Starts up the expensive mag
            lcd.Write("Init exp. mag...");
            Rebug.Print("Initializing expensive magnetometer on com3");
            var expensiveMagLoop = new ExpensiveMagUpdater(delay: 1000);

            LCDFinish(lcd, "Done.");

            lcd.Write("Init calib disp.");
            Rebug.Print("Initializing BNO calibration display loop");
            var printBnoCalib = new BNOCalibUpdate(bno, lcd, delay: 1000);

            LCDFinish(lcd, "Done.");

            //////THIS SECTION CREATES/INITIALIZES THE MAGNETOMETER UPDATER
            var mag_dump_size = 18432;

            lcd.Write("Init fast mag...");
            Rebug.Print("Initializing fast mag dump collector with a size of " + mag_dump_size + "bytes.");
            var customMagLoop = new CustomMagUpdater(mag_dump_size, AnalogChannels.ANALOG_PIN_A0);

            LCDFinish(lcd, "Done.");

            //Thread.Sleep(5000);
            lcd.Write("Init complete...");
            Rebug.Print("Flight computer INIT Complete. Continuing with boot.");
            LCDFinish(lcd, "Continuing boot.");

            //THIS SECTION INITIALIZES AND STARTS THE MEMORY MONITOR
            lcd.Write("Start memory monitor...");
            Rebug.Print("Starting memory monitor...");
            MemoryMonitor.Instance.Start(ref logger);
            LCDFinish(lcd, "Done.");

            ////THIS STARTS THE Mag dump update
            lcd.Write("Start f.mag loop...");
            Rebug.Print("Starting fast mag dump...");
            customMagLoop.Start();
            LCDFinish(lcd, "Done.");

            ////THIS STARTS THE BNO SENSOR UPDATE
            lcd.Write("Start bno loop...");
            Rebug.Print("Starting bno sensor updates...");
            bnoloop.Start();
            LCDFinish(lcd, "Done.");

            //THIS STARTS THE BNO SENSOR UPDATE
            //lcd.Write("Start bmp loop");
            //Rebug.Print("Starting bmp sensor updates...");
            //bmploop.Start();
            //LCDFinish(lcd);

            //THIS STARTS THE EXPENSIVE MAG UPDATE
            lcd.Write("Start e.mag loop...");
            Rebug.Print("Starting expensive mag updates...");
            expensiveMagLoop.Start();
            LCDFinish(lcd, "Done.");

            lcd.Write("Boot successful!");
            LCDFinish(lcd, "Entering run state.");

            Rebug.Print("Flight computer boot successful.");
            printBnoCalib.Start();
        }
Exemple #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++;
            }
        }
Exemple #11
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);
                }
            }
        }
Exemple #12
0
 /// <summary>
 /// Set LCD dimensions
 /// </summary>
 /// <param name="lcdRows"></param>
 /// <param name="lcdCols"></param>
 public void SetScreenSize(byte lcdRows, byte lcdCols)
 {
     numRows = lcdRows;
     numCols = lcdCols;
     lcd.Begin(lcdCols, lcdRows);
 }