Ejemplo n.º 1
0
        public static void Main()
        {
            // Option 1: Use I2C provider.
            // Default configuration coresponds to Adafruit's LCD backpack

            // initialize i2c bus (only one instance is allowed)
            var bus = new I2CBus();

            // initialize provider (multiple devices can be attached to same bus)
            var lcdProvider = new MCP23008LcdTransferProvider(bus);

            /*
            // Option 2: Adafruit's LCD backup can also work in SIP mode.
            // this setup enabled this pinout.
            var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, Pins.GPIO_PIN_D10,
                Shifter74Hc595LcdTransferProvider.BitOrder.MSBFirst,
                new Shifter74Hc595LcdTransferProvider.ShifterSetup
                {
                    RS = ShifterPin.GP0,
                    RW = ShifterPin.None,
                    Enable = ShifterPin.GP1,
                    D4 = ShifterPin.GP5,
                    D5 = ShifterPin.GP4,
                    D6 = ShifterPin.GP3,
                    D7 = ShifterPin.GP2,
                    BL = ShifterPin.GP6
                });
            */

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

            // set up the LCD's number of columns and rows:
            lcd.Begin(16, 2);

            // Print a message to the LCD.
            lcd.Write("hello, world!");

            Stopwatch sw = Stopwatch.StartNew();

            while (true)
            {
                sw.Start();

                // set the cursor to column 0, line 1
                lcd.SetCursorPosition(0, 1);

                // print the number of seconds since reset:
                lcd.Write((Utility.GetMachineTime().Ticks / 10000).ToString());

                Debug.Print(sw.ElapsedMilliseconds.ToString());
                sw.Reset();

                Thread.Sleep(100);

            //    lcd.Backlight = !lcd.Backlight;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor for SPI LCD connection (Adafruit I2C LCD backpack)
        /// </summary>
        public clsLCD_MLC(byte rows, byte cols)
        {
            // initialize i2c bus (only one instance is allowed)
            I2CBus bus = new I2CBus();

            // initialize provider (multiple devices can be attached to same bus)
            MCP23008LcdTransferProvider lcdProvider = new MCP23008LcdTransferProvider(bus);
            lcd = new Lcd(lcdProvider);
            lcd_begin(rows, cols);
        }
Ejemplo n.º 3
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();
 }
Ejemplo n.º 4
0
        public static void Main()
        {
            // initialize i2c bus (only one instance is allowed)
            _bus = new I2CBus();

            // initialize provider (multiple devices can be attached to same bus)
            var lcdProvider = new MCP23008LcdTransferProvider(_bus);

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

            // set up the LCD's number of columns and rows:
            _lcd.Begin(16, 2);

            // Print a message to the LCD.
            _lcd.Write("Netduino clock");

            // initialize RTC clock
            _clock = new DS1307RealTimeClock(_bus);

            // TODO: Do this only once to set your clock
            // clock.SetClock(new DateTime(2010,11,25,8,17,32));

            _clock.SetLocalTimeFromRTC();
            Debug.Print("The RTC time is: " + DateTime.Now);

            // set timer to update display
            _lcdTimer = new Timer(UpdateDisplay, null, 500, 500);

            // update time now and then every 15 minutes
            _ntpTimer = new Timer(UpdateTime, null, TimeSpan.Zero, new TimeSpan(0, ClockUpdateMinutes, 0));

            // subscribe to network change events
            NetworkChange.NetworkAvailabilityChanged += OnNetworkAvailabilityChanged;

            // end of main
            Thread.Sleep(Timeout.Infinite);
        }