Esempio n. 1
0
        public static void Main(string[] args)
        {
            var config = ReadConfig();

            PwmService.BaseCommand = config.BaseCommand;
            PwmService.BaseArgs    = config.BaseArgs;
            PwmService.Verbose     = config.Verbose;

            // Initial PWM setup (all lamps off)
            PwmService.Invert = true;
            PwmService.Instance.WritePwmData().Wait();

            // Start web services
            SetupServices(config.Lamps);

            // Run until Ctrl+C
            var endEvent = new ManualResetEvent(false);

            Console.WriteLine("HippoPiPwmLedDaemon started");

            Console.CancelKeyPress += (sender, e) =>
            {
                Console.WriteLine("HippoPiPwmLedDaemon stopped");

                LightService.DisposeAll();                  // Stop all web servers

                endEvent.Set();
            };

            endEvent.WaitOne();
        }
Esempio n. 2
0
 public static void SetupServices(ConfigObject[] objects)
 {
     foreach (var o in objects)
     {
         var svc = new LightService(o.Name, o.Port, o.RedChannel);
         svc.StartWebserver();
         svc.RegisterMDNS();
     }
 }
        public void SetStatus(LampDataObject obj)
        {
            // TODO: partial response, not on/off and r,g,b always set simultaneously

            LightService svc = CurrentService;

            svc.On = obj.burn;
            svc.SetRGB(obj.red, obj.green, obj.blue).Wait();
        }
        public LampDataObject GetStatus()
        {
            LightService   svc = CurrentService;
            LampDataObject obj = new LampDataObject
            {
                burn  = svc.On,
                red   = svc.Red,
                blue  = svc.Blue,
                green = svc.Green
            };

            return(obj);
        }