Example #1
0
 public PokeysDriver()
     : base()
 {
     currentPokeysSwitchValues  = new bool[128];
     previousPokeysSwitchValues = new bool[128];
     currentPokeysAnalogValues  = new int[7];
     previousPokeysAnalogValues = new int[7];
     device = new PoKeysDevice_DLL.PoKeysDevice();
 }
        public bool IsEnabled(PoKeysDevice_DLL.PoKeysDevice poKeysDevice)
        {
            byte auxilaryBusEnabled = 0;

            if (!poKeysDevice.AuxilaryBusGetData(ref auxilaryBusEnabled))
            {
                return(false);
            }

            return(auxilaryBusEnabled == 1);
        }
        public bool ClearAll(PoKeysDevice_DLL.PoKeysDevice poKeysDevice, bool invert)
        {
            switch (Id)
            {
            case Ids.MatrixLed1: return(poKeysDevice.MatrixLED1ClearAll(invert));

            case Ids.MatrixLed2: return(poKeysDevice.MatrixLED2ClearAll(invert));

            default: return(false);
            }
        }
        public bool SetPixel(PoKeysDevice_DLL.PoKeysDevice poKeysDevice, byte row, byte column, bool value)
        {
            switch (Id)
            {
            case Ids.MatrixLed1: return(poKeysDevice.MatrixLED1SetPixel(row, column, value));

            case Ids.MatrixLed2: return(poKeysDevice.MatrixLED2SetPixel(row, column, value));

            default: return(false);
            }
        }
Example #5
0
 public TestDriver()
 {
     //pokeys bulk pin get uses 55 values
     // pokeys bulk matrix pin get is 128 values
     client = new UdpClient();
     // http://code.google.com/p/hogkeys/issues/detail?id=3
     currentPokeysSwitchValues  = new bool[128];
     previousPokeysSwitchValues = new bool[128];
     currentPokeysAnalogValues  = new int[7];
     previousPokeysAnalogValues = new int[7];
     device = new PoKeysDevice_DLL.PoKeysDevice();
 }
        public bool IsOutputEnabled(PoKeysDevice_DLL.PoKeysDevice poKeysDevice, int deviceId, char pinId)
        {
            if (deviceId < 1 || deviceId > 10)
            {
                return(false);
            }

            if (pinId < 'A' || pinId > 'H')
            {
                return(false);
            }

            return(IsEnabled(poKeysDevice));
        }
        public bool SetOutput(PoKeysDevice_DLL.PoKeysDevice poKeysDevice, int deviceId, char pinId, bool outputState)
        {
            int pinMask = 1 << ('H' - pinId);

            if (outputState)
            {
                dataBytes[10 - deviceId] |= (byte)pinMask;
            }
            else
            {
                dataBytes[10 - deviceId] &= (byte)~pinMask;
            }

            return(poKeysDevice.AuxilaryBusSetData(1, dataBytes));
        }
Example #8
0
        public void updateStatus()
        {
            if (owner == null)
            {
                return;
            }

            if (!PinId.HasValue)
            {
                Error = null;
            }
            else if (!owner.PokeysIndex.HasValue)
            {
                Error = null;
            }
            else
            {
                PoKeysDevice_DLL.PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice;

                if (!poKeysDevice.ConnectToDevice(owner.PokeysIndex.Value))
                {
                    Error = Translations.Main.PokeysConnectError;
                }
                else
                {
                    byte pinFunction = 0;
                    if (!poKeysDevice.GetPinData((byte)(PinId.Value - 1), ref pinFunction))
                    {
                        Error = Translations.Main.DigitalOutputErrorGetIOType;
                    }
                    else
                    {
                        if ((pinFunction & 0x4) == 0)
                        {
                            Error = Translations.Main.DigitalOutputErrorBadIOType;
                        }
                        else
                        {
                            Error = null;
                        }
                    }

                    poKeysDevice.DisconnectDevice();
                }
            }

            writeOutputState();
        }
        private void writeOutputState()
        {
            if (string.IsNullOrEmpty(Error) && owner != null && owner.PokeysIndex.HasValue && MatrixLedConfig != null)
            {
                PoKeysDevice_DLL.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();
                }
            }
        }
        public void updateStatus()
        {
            if (owner == null)
            {
                return;
            }

            if (MatrixLedConfig == null)
            {
                Error = null;
            }
            else if (!owner.PokeysIndex.HasValue)
            {
                Error = null;
            }
            else
            {
                PoKeysDevice_DLL.PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice;

                if (!poKeysDevice.ConnectToDevice(owner.PokeysIndex.Value))
                {
                    Error = Translations.Main.PokeysConnectError;
                }
                else
                {
                    if (!MatrixLed.IsEnabled())
                    {
                        Error = Translations.Main.MatrixLedErrorNotEnabled;
                    }
                    else
                    {
                        Error = null;
                    }

                    poKeysDevice.DisconnectDevice();
                }
            }

            setOutputStateDirty();
            writeOutputState();
        }
Example #11
0
        protected override void writeOutputState()
        {
            if (string.IsNullOrEmpty(Error) && owner != null && owner.PokeysIndex.HasValue && DeviceId.HasValue && PinId.HasValue)
            {
                PoKeysDevice_DLL.PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice;

                if (!poKeysDevice.ConnectToDevice(owner.PokeysIndex.Value))
                {
                    Error = Translations.Main.PokeysConnectError;
                }
                else
                {
                    if (!owner.PoExtBus.SetOutput(DeviceId.Value, PinId.Value, OutputState))
                    {
                        Error = Translations.Main.PoExtBusErrorWrite;
                    }

                    poKeysDevice.DisconnectDevice();
                }
            }
        }
        protected override void writeOutputState()
        {
            if (string.IsNullOrEmpty(Error) && owner != null && owner.PokeysIndex.HasValue && MatrixLed != null && Row.HasValue && Column.HasValue)
            {
                PoKeysDevice_DLL.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();
                }
            }
        }
Example #13
0
        public void updateStatus()
        {
            if (owner == null)
            {
                return;
            }

            if (!DeviceId.HasValue || !PinId.HasValue)
            {
                Error = null;
            }
            else if (!owner.PokeysIndex.HasValue)
            {
                Error = null;
            }
            else
            {
                PoKeysDevice_DLL.PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice;

                if (!poKeysDevice.ConnectToDevice(owner.PokeysIndex.Value))
                {
                    Error = Translations.Main.PokeysConnectError;
                }
                else
                {
                    if (!owner.PoExtBus.IsOutputEnabled(DeviceId.Value, PinId.Value))
                    {
                        Error = Translations.Main.PoExtBusErrorNotEnabled;
                    }
                    else
                    {
                        Error = null;
                    }

                    poKeysDevice.DisconnectDevice();
                }
            }

            writeOutputState();
        }
        public void updateStatus()
        {
            if (owner == null)
            {
                return;
            }

            if (MatrixLed == null || !Row.HasValue || !Column.HasValue)
            {
                Error = null;
            }
            else if (!owner.PokeysIndex.HasValue)
            {
                Error = null;
            }
            else
            {
                PoKeysDevice_DLL.PoKeysDevice poKeysDevice = PoKeysEnumerator.Singleton.PoKeysDevice;

                if (!poKeysDevice.ConnectToDevice(owner.PokeysIndex.Value))
                {
                    Error = Translations.Main.PokeysConnectError;
                }
                else
                {
                    if (!MatrixLed.IsPixelEnabled((byte)(Row.Value - 1), (byte)(Column.Value - 1)))
                    {
                        Error = string.Format(Translations.Main.MatrixLedPixelErrorNotEnabled, Row, Column);
                    }
                    else
                    {
                        Error = null;
                    }

                    poKeysDevice.DisconnectDevice();
                }
            }

            writeOutputState();
        }
        private bool IsEnabled(PoKeysDevice_DLL.PoKeysDevice poKeysDevice, byte?row, byte?column)
        {
            bool enabled1 = false;
            byte rows1    = 0;
            byte cols1    = 0;
            bool enabled2 = false;
            byte rows2    = 0;
            byte cols2    = 0;

            if (!poKeysDevice.MatrixLEDGetSettings(ref enabled1, ref rows1, ref cols1, ref enabled2, ref rows2, ref cols2))
            {
                return(false);
            }

            switch (Id)
            {
            case Ids.MatrixLed1: return(enabled1 && (!row.HasValue || row.Value <= rows1) && (!column.HasValue || column.Value <= cols1));

            case Ids.MatrixLed2: return(enabled2 && (!row.HasValue || row.Value <= rows2) && (!column.HasValue || column.Value <= cols2));

            default: return(false);
            }
        }
 public bool IsPixelEnabled(PoKeysDevice_DLL.PoKeysDevice poKeysDevice, byte row, byte column)
 {
     return(IsEnabled(poKeysDevice, row, column));
 }
 public bool IsEnabled(PoKeysDevice_DLL.PoKeysDevice poKeysDevice)
 {
     return(IsEnabled(poKeysDevice, null, null));
 }