Ejemplo n.º 1
0
 /// <summary>
 /// Turns on one LED and the rest off.
 /// </summary>
 /// <param name="pin">The LED to be turned on.</param>
 public static void SingleLED(StatusLED led)
 {
     foreach (KeyValuePair <StatusLED, GpioPin> pin in LEDs)
     {
         LEDWrite(led, pin.Key == led ? GpioPinValue.High : GpioPinValue.Low);
     }
 }
Ejemplo n.º 2
0
        private static void DevicePoll_Received(List <C4UFX.CANMessage> responses)
        {
            StatusUpdate?.Invoke("Querying names (1/3)...");


            foreach (C4UFX.CANMessage response in responses)
            {
                FndTnd address = CANInterface.IdToFndTnd(response.ID);
                if (address.FromDevice > 0)
                {
                    Node   currentNode = allResponses.First(x => x.NodeId == address.FromNode);
                    byte   fromNode    = CANInterface.IdToFndTnd(response.ID).FromNode;
                    byte   fromDevice  = CANInterface.IdToFndTnd(response.ID).FromDevice;
                    Device newDevice;
                    switch ((Signatures)response.Data[2])
                    {
                    case Signatures.MechanicalSwitch: newDevice = new MechanicalSwitch(fromNode, fromDevice); break;

                    case Signatures.StatusLED: newDevice = new StatusLED(fromNode, fromDevice); break;

                    case Signatures.InfraredInput: newDevice = new InfraredInput(fromNode, fromDevice); break;

                    case Signatures.DimmerOut: newDevice = new DimmerOut(fromNode, fromDevice); break;

                    case Signatures.LatLong: newDevice = new LatLong(fromNode, fromDevice); break;

                    case Signatures.TimerEvent: newDevice = new TimerEvent(fromNode, fromDevice); break;

                    case Signatures.Scene: newDevice = new Scene(fromNode, fromDevice); break;

                    case Signatures.RealTimeClock: newDevice = new RealTimeClock(fromNode, fromDevice); break;

                    default: newDevice = new UnknownDevice(fromNode, fromDevice); break;
                    }

                    currentNode.Devices.Add(newDevice);
                }
            }

            Dictionary <byte, List <byte> > sendList = new Dictionary <byte, List <byte> >();

            foreach (Node node in allResponses)
            {
                if (sendList.Keys.Contains(node.NodeId))
                {
                    break;
                }
                sendList.Add(node.NodeId, new List <byte>());
                for (byte i = 1; i < 127; i++)
                {
                    sendList[node.NodeId].Add(i);
                }
            }

            CANPing poll = new CANPing(Commands.CmdSysEName1, sendList);

            poll.ResponseReceived += Name1Poll_Received;
            PongsReceived?.Invoke(allResponses, false);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Writes a value to an LED.
 /// </summary>
 /// <param name="led">The LED in question.</param>
 /// <param name="value">The value to be written.</param>
 public static void LEDWrite(StatusLED led, GpioPinValue value)
 {
     try
     {
         Logger.LogInfo(string.Format("Setting {0} LED value to {1}", led, value));
         LEDs[led].Write(value);
     }
     catch (Exception ex)
     {
         Logger.LogException(string.Format("Failed to update the {0} LED.", led), ex);
     }
 }
Ejemplo n.º 4
0
 protected virtual void SetLEDColors()
 {
     // Set LEDs Color for each status
     if (chatdoll.IsError)
     {
         StageLED.SetColor(ErrorColor); StatusLED.SetColor(ErrorColor);
     }
     else if (voiceRequestProvider.IsListening)
     {
         StageLED.SetColor(ListeningColor); StatusLED.SetColor(ListeningColor);
     }
     else if (chatdoll.IsChatting)
     {
         StageLED.SetColor(ChattingColor); StatusLED.SetColor(ChattingColor);
     }
     else
     {
         StageLED.SetColor(DefaultColor); StatusLED.SetColor(DefaultColor);
     }
 }
Ejemplo n.º 5
0
 public static void TurnOff(StatusLED led)
 {
     LEDWrite(led, GpioPinValue.Low);
 }
Ejemplo n.º 6
0
 public static void TurnOn(StatusLED led)
 {
     LEDWrite(led, GpioPinValue.High);
 }