private void WriteOutputState()
        {
            if (string.IsNullOrEmpty(Error) && owner != null && owner.PoKeysIndex.HasValue && MatrixLedConfig != null)
            {
                PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice;

                if (!poKeysDevice.ConnectToDevice(owner.PoKeysIndex.Value))
                {
                    Error = Translations.Main.PoKeysConnectError;
                }
                else
                {
                    foreach (SevenSegmentDigit digit in SevenSegmentDigits)
                    {
                        for (int segmentPosition = 0; segmentPosition < 8; ++segmentPosition)
                        {
                            SevenSegmentDigitSegment segment = digit.Segments[segmentPosition];

                            if (segment.Dirty)
                            {
                                bool setPixelOk;

                                if (matrixLedConfig.DigitOnRow)
                                {
                                    setPixelOk = MatrixLed.SetPixel((byte)(digit.Index - 1), (byte)(MatrixLedConfig.SegmentIndexes[segmentPosition] - 1), segment.Value);
                                }
                                else
                                {
                                    setPixelOk = MatrixLed.SetPixel((byte)(MatrixLedConfig.SegmentIndexes[segmentPosition] - 1), (byte)(digit.Index - 1), segment.Value);
                                }

                                if (!setPixelOk)
                                {
                                    Error = Translations.Main.MatrixLedErrorWrite;
                                }

                                segment.Dirty = false;
                            }
                        }
                    }

                    poKeysDevice.DisconnectDevice();
                }
            }
        }
Exemple #2
0
        protected override void WriteOutputState()
        {
            if (string.IsNullOrEmpty(Error) && owner != null && owner.PoKeysIndex.HasValue && MatrixLed != null && Row.HasValue && Column.HasValue)
            {
                PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice;

                if (!poKeysDevice.ConnectToDevice(owner.PoKeysIndex.Value))
                {
                    Error = Translations.Main.PoKeysConnectError;
                }
                else
                {
                    if (!MatrixLed.SetPixel((byte)(Row.Value - 1), (byte)(Column.Value - 1), OutputState))
                    {
                        Error = Translations.Main.MatrixLedErrorWrite;
                    }

                    poKeysDevice.DisconnectDevice();
                }
            }
        }