Beispiel #1
0
        public Max7219(string SpiControllerName, int csPin, int deviceCount = 1, Max7219Type maxMode = Max7219Type.Display)

        {
            var cs = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.GetDefault().
                     OpenPin(csPin);

            // : this(SpiDevice, device.CreateDigitalOutputPort(csPin), deviceCount, 1, maxMode)
            Setup(SpiControllerName, cs, deviceCount, 1, maxMode);
        }
Beispiel #2
0
 /// <summary>
 /// Standard initialization routine.
 /// </summary>
 void Initialize(Max7219Type maxMode)
 {
     SetRegister(Register.DecodeMode, (byte)((maxMode == Max7219Type.Character)? 0xFF:0)); // use matrix(0) or digits
     SetRegister(Register.ScanLimit, 7);                                                   //show all 8 digits
     SetRegister(Register.DisplayTest, 0);                                                 // no display test
     SetRegister(Register.ShutDown, 1);                                                    // not shutdown mode
     SetBrightness(4);                                                                     //intensity, range: 0..15
     Clear();
 }
Beispiel #3
0
 public void SetMode(Max7219Type maxMode)
 {
     SetRegister(Register.DecodeMode, (byte)((maxMode == Max7219Type.Character) ? 0xFF : 0)); // use matrix(0) or digits
 }
Beispiel #4
0
 public Max7219(IIODevice device, ISpiBus spiBus, IPin csPin, int deviceCount = 1, Max7219Type maxMode = Max7219Type.Display)
     : this(spiBus, device.CreateDigitalOutputPort(csPin), deviceCount, 1, maxMode)
 {
 }
Beispiel #5
0
        public Max7219(ISpiBus spiBus, IDigitalOutputPort csPort, int deviceRows, int deviceColumns, Max7219Type maxMode = Max7219Type.Display)
        {
            spi            = (SpiBus)spiBus;
            chipSelectPort = csPort;

            max7219 = new SpiPeripheral(spiBus, csPort);

            DeviceRows    = deviceRows;
            DeviceColumns = deviceColumns;

            _buffer      = new byte[DeviceCount, NumDigits];
            _writeBuffer = new byte[2 * DeviceCount];
            _readBuffer  = new byte[2 * DeviceCount];

            Initialize(maxMode);
        }
Beispiel #6
0
 public Max7219(ISpiBus spiBus, IDigitalOutputPort csPort, int deviceCount = 1, Max7219Type maxMode = Max7219Type.Display)
     : this(spiBus, csPort, 8, 1, maxMode)
 {
 }
Beispiel #7
0
        void Setup(string SpiControllerName, GpioPin csPort, int deviceRows, int deviceColumns, Max7219Type maxMode = Max7219Type.Display)
        {
            var settings = new SpiConnectionSettings()
            {
                ChipSelectType = SpiChipSelectType.Gpio,
                ChipSelectLine = csPort,
                Mode           = SpiMode.Mode1,
                ClockFrequency = 4_000_000,
            };

            var controller = SpiController.FromName(SpiControllerName);

            max7219        = controller.GetDevice(settings);
            chipSelectPort = csPort;

            DeviceRows    = deviceRows;
            DeviceColumns = deviceColumns;

            _buffer      = new byte[DeviceCount, NumDigits];
            _writeBuffer = new byte[2 * DeviceCount];
            _readBuffer  = new byte[2 * DeviceCount];

            Initialize(maxMode);
        }
Beispiel #8
0
 public Max7219(string SpiControllerName, GpioPin csPort, int deviceRows, int deviceColumns, Max7219Type maxMode = Max7219Type.Display)
 {
     Setup(SpiControllerName, csPort, deviceRows, deviceColumns, maxMode);
 }
Beispiel #9
0
 public Max7219(string SpiControllerName, GpioPin csPort, int deviceCount = 1, Max7219Type maxMode = Max7219Type.Display)
     : this(SpiControllerName, csPort, 8, 1, maxMode)
 {
 }
Beispiel #10
0
        public Max7219(ISpiBus spiBus, IDigitalOutputPort csPort, int deviceCount = 1, Max7219Type maxMode = Max7219Type.Display)
        {
            max7219 = new SpiPeripheral(spiBus, csPort);

            DeviceCount = deviceCount;

            _buffer      = new byte[DeviceCount, NumDigits];
            _writeBuffer = new byte[2 * DeviceCount];

            Initialize(maxMode);
        }