示例#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;
            }
        }
示例#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);
        }
示例#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();
 }
        public MCP23008LcdTransferProvider(I2CBus bus, ushort address, ShifterSetup setup)
            : base(setup)
        {
            _expander = new MCP23008Expander(bus, address);
            Thread.Sleep(10); // make sure bus initializes

            _expander.SetPinMode(setup.Enable, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.RS, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D4, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D5, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D6, MCP23008Expander.PinMode.Output);
            _expander.SetPinMode(setup.D7, MCP23008Expander.PinMode.Output);

            if (setup.RW != ShifterPin.None)
                _expander.SetPinMode(setup.RW, MCP23008Expander.PinMode.Output);

            if (setup.BL != ShifterPin.None)
                _expander.SetPinMode(setup.BL, MCP23008Expander.PinMode.Output);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
0
 /// <summary>Creates a new instance of an <see cref="I2CDeviceDriver"/></summary>
 /// <param name="Bus"><see cref="I2CBus" /> the device is connected to</param>
 /// <param name="Address">Address of the device on the bus</param>
 /// <param name="ClockRateKhz">Clock rate for this device in Khz</param>
 protected I2CDeviceDriver( I2CBus Bus, ushort Address, int ClockRateKhz )
 {
     this.Config = new I2CDevice.Configuration( Address, ClockRateKhz );
     this.Bus = Bus;
     this._TimeOut = 2000; // 1000;
 }
 public MCP23008LcdTransferProvider(I2CBus bus)
     : this(bus, 0, DefaultSetup)
 {
 }
示例#9
0
 /// <summary>Creates a new instance of an <see cref="I2CDeviceDriver"/></summary>
 /// <param name="Bus"><see cref="I2CBus" /> the device is connected to</param>
 /// <param name="Address">Address of the device on the bus</param>
 /// <param name="ClockRateKhz">Clock rate for this device in Khz</param>
 protected I2CDeviceDriver(I2CBus Bus, ushort Address, int ClockRateKhz)
 {
     this.Config   = new I2CDevice.Configuration(Address, ClockRateKhz);
     this.Bus      = Bus;
     this._TimeOut = 2000; // 1000;
 }
示例#10
0
 public MCP23008Expander(I2CBus bus, ushort address)
     : base(bus, (ushort)(AddressMask | address), ClockRateKhz)
 {
     Reset();
 }
示例#11
0
 public MCP23008Expander(I2CBus bus)
     : this(bus, 0)
 {
 }
 public DS1307RealTimeClock(I2CBus bus)
     : base(bus, DS1307_Address, DS1307_ClockRateKhz)
 {
 }
示例#13
0
 public static I2CBus GetSingleton()
 {
     return _singleton ?? (_singleton = new I2CBus());
 }
示例#14
0
 /// <summary>
 /// Constructor
 /// </summary>
 public DS1307(I2CBus i2CBus)
 {
     _i2CBus = i2CBus;
 }