Ejemplo n.º 1
0
 public void Init(ITextDisplay display, IRotaryEncoder encoder, IButton buttonSelect)
 {
     _display      = display;
     _encoder      = encoder;
     _buttonSelect = buttonSelect;
     _isInit       = true;
 }
Ejemplo n.º 2
0
 public override void started(float timelineTime, Clock clock)
 {
     if (text != null)
     {
         finished    = false;
         textDisplay = TimelineController.showText(text, CameraName);
         if (textDisplay == null)
         {
             finished = true;
         }
         else
         {
             textDisplay.Position             = position;
             textDisplay.Size                 = size;
             textDisplay.FontName             = fontName;
             textDisplay.FontHeight           = fontHeight;
             textDisplay.TextAlign            = textAlign;
             textDisplay.ScenePoint           = scenePoint;
             textDisplay.PositionOnScenePoint = positionOnScenePoint;
         }
     }
     else
     {
         finished = true;
     }
 }
Ejemplo n.º 3
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            onboardLed = new RgbPwmLed(device: Device,
                                       redPwmPin: Device.Pins.OnboardLedRed,
                                       greenPwmPin: Device.Pins.OnboardLedGreen,
                                       bluePwmPin: Device.Pins.OnboardLedBlue,
                                       3.3f, 3.3f, 3.3f,
                                       Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode);

            Console.WriteLine("Create Display with SPI...");

            var config = new Meadow.Hardware.SpiClockConfiguration(12000, Meadow.Hardware.SpiClockConfiguration.Mode.Mode0);

            var bus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config);

            ssd1309 = new Ssd1309
                      (
                device: Device,
                spiBus: bus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                      );



            Console.WriteLine("Create GraphicsLibrary...");

            display = new GraphicsLibrary(ssd1309)
            {
                CurrentFont = new Font8x12(),
                //   Rotation = GraphicsLibrary.RotationType._270Degrees
            };

            Console.WriteLine("Load menu data...");

            var menuData = LoadResource("menu.json");

            Console.WriteLine($"Data length: {menuData.Length}...");

            Console.WriteLine("Create buttons...");
            var encoder = new RotaryEncoderWithButton(Device, Device.Pins.D13, Device.Pins.D14, Device.Pins.D15);

            //   next = new PushButton(Device, Device.Pins.D15);
            //   select = new PushButton(Device, Device.Pins.D12);
            //   previous = new PushButton(Device, Device.Pins.D11);

            Console.WriteLine("Create menu...");

            //     menu = new Menu(display, next, previous, select, menuData, false);


            menu = new Menu(display, encoder, menuData, false);

            Console.WriteLine("Enable menu...");

            menu.Enable();
        }
Ejemplo n.º 4
0
        public Menu(ITextDisplay display, byte[] menuJson, bool showBackOnRoot = false)
        {
            this.showBackOnRoot = showBackOnRoot;
            var items = ParseMenuData(menuJson);

            Init(display, CreateMenuPage(items, showBackOnRoot));
        }
Ejemplo n.º 5
0
        private void Init(ITextDisplay display, IRotaryEncoder encoder, IButton buttonNext, IButton buttonPrevious, IButton buttonSelect, MenuPage menuTree)
        {
            if (encoder != null)
            {
                _encoder = encoder;
            }
            else if (buttonNext != null && buttonPrevious != null)
            {
                _buttonPrevious = buttonPrevious;
                _buttonNext     = buttonNext;
            }
            else
            {
                throw new ArgumentNullException("Must have either a Rotary Encoder or Next/Previous buttons");
            }

            _display      = display;
            _buttonSelect = buttonSelect;
            _rootMenuPage = menuTree;
            _menuLevel    = new Stack();

            // Save our custom characters
            _display.SaveCustomCharacter(TextCharacters.RightArrow.CharMap, TextCharacters.RightArrow.MemorySlot);
            _display.SaveCustomCharacter(TextCharacters.RightArrowSelected.CharMap, TextCharacters.RightArrow.MemorySlot);
            _display.SaveCustomCharacter(TextCharacters.BoxSelected.CharMap, TextCharacters.BoxSelected.MemorySlot);
        }
Ejemplo n.º 6
0
 public void Init(ITextDisplay display, IButton buttonNext, IButton buttonPrevious, IButton buttonSelect)
 {
     _display        = display;
     _buttonSelect   = buttonSelect;
     _buttonNext     = buttonNext;
     _buttonPrevious = buttonPrevious;
     _isInit         = true;
 }
Ejemplo n.º 7
0
 public override void stopped(float timelineTime, Clock clock)
 {
     if (textDisplay != null)
     {
         textDisplay.Dispose();
         textDisplay = null;
     }
 }
Ejemplo n.º 8
0
 public override void editingCompleted()
 {
     if (textDisplay != null)
     {
         textDisplay.Dispose();
         textDisplay = null;
     }
 }
Ejemplo n.º 9
0
        private static IAsyncOperation <IEnumerable <ITextDisplay> > loadDisplaysForConfigs(IEnumerable <TextDisplayConfig> configs)
        {
            return(Task.Run(async() =>
            {
                var displays = new List <ITextDisplay>();

                foreach (var config in configs)
                {
                    ITextDisplay driver = null;
                    var type = Type.GetType(config.DriverType);

                    if (null == type && null != config.DriverAssembly)
                    {
                        try
                        {
                            var assembly = Assembly.Load(new AssemblyName(config.DriverAssembly));
                            if (null != assembly)
                            {
                                type = assembly.DefinedTypes.Where(t => t.FullName == config.DriverType).FirstOrDefault().AsType();
                            }
                        }
                        catch (FileNotFoundException)
                        {
                            Debug.WriteLine("TextDisplayManager: Failed to load assembly " +
                                            config.DriverAssembly +
                                            " for driver " +
                                            config.DriverType);
                        }
                    }

                    if (null != type)
                    {
                        driver = Activator.CreateInstance(type, config) as ITextDisplay;
                    }

                    if (null != driver)
                    {
                        try
                        {
                            await driver.InitializeAsync();
                            displays.Add(driver);
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine("TextDisplayManager: Failed to add driver " + type.ToString());
                            Debug.WriteLine("TextDisplayManager: " + e.Message);
                        }
                    }
                    else
                    {
                        Debug.WriteLine("TextDisplayManager: Failed to add driver: " + config.DriverType);
                    }
                }

                return displays as IEnumerable <ITextDisplay>;
            }).AsAsyncOperation());
        }
        /// <summary>
        /// Sets up a text console UI instance for the tests
        /// </summary>
        /// <param name="textDisplay">The text display which is used to show console's captured messages</param>
        /// <param name="console">The console which handles the capturing</param>
        /// <returns></returns>
        private TextConsoleUI SetupTextConsoleUI(out ITextDisplay textDisplay, out IConsole console)
        {
            textDisplay = A.Fake <ITextDisplay>();
            TextConsoleUI textConsoleUI = new TextConsoleUI(textDisplay);

            console = A.Fake <Console>();

            textConsoleUI.Console = console;
            return(textConsoleUI);
        }
Ejemplo n.º 11
0
        public static IAsyncOperation <IEnumerable <ITextDisplay> > GetDisplays()
        {
            return(Task.Run(async() =>
            {
                if (null == s_avaliableDisplays)
                {
                    var displays = new List <ITextDisplay>();

                    var folder = Windows.Storage.ApplicationData.Current.LocalSettings;
                    try
                    {
                        var configFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Microsoft.Maker.Devices.TextDisplay/screens.config"));

                        var xmlString = await FileIO.ReadTextAsync(configFile);

                        var xml = XElement.Parse(xmlString);

                        var screensConfig = xml.Descendants("Screen");

                        foreach (var screenConfig in screensConfig)
                        {
                            var driverTypeAttribute = screensConfig.Attributes().Where(a => a.Name == "driverType").FirstOrDefault();

                            if (null != driverTypeAttribute)
                            {
                                var type = Type.GetType("Microsoft.Maker.Devices.TextDisplay." + driverTypeAttribute.Value);
                                ITextDisplay driver = Activator.CreateInstance(type, screenConfig) as ITextDisplay;
                                if (null != driver)
                                {
                                    try
                                    {
                                        await driver.InitializeAsync();
                                        displays.Add(driver);
                                    }
                                    catch (Exception e)
                                    {
                                        Debug.WriteLine("TextDisplayManager: Failed to add driver " + type.ToString());
                                        Debug.WriteLine("TextDisplayManager: " + e.Message);
                                    }
                                }
                            }
                        }

                        s_avaliableDisplays = displays;
                    }
                    catch (FileNotFoundException)
                    {
                        Debug.WriteLine("TextDisplayManager: Screen config file not found");
                    }
                }

                return s_avaliableDisplays;
            }).AsAsyncOperation());
        }
Ejemplo n.º 12
0
        public Menu(ITextDisplay display, RotaryEncoderWithButton encoder, byte[] menuResource)
        {
            var menuJson = new string(System.Text.Encoding.UTF8.GetChars(menuResource));
            var menuData = Json.NETMF.JsonSerializer.DeserializeString(menuJson) as Hashtable;

            if (menuData["menu"] == null)
            {
                throw new ArgumentException("JSON root must contain a 'menu' item");
            }
            _rootMenuPage = CreateMenuPage((ArrayList)menuData["menu"], false);
            Init(display, encoder, _rootMenuPage);
        }
Ejemplo n.º 13
0
        private void Init(ITextDisplay display, MenuPage menuTree)
        {
            this.display = display;

            rootMenuPage = menuTree;
            menuLevel    = new Stack();

            // Save our custom characters
            // ToDo
            display.SaveCustomCharacter(TextCharacters.RightArrow.CharMap, TextCharacters.RightArrow.MemorySlot);
            display.SaveCustomCharacter(TextCharacters.RightArrowSelected.CharMap, TextCharacters.RightArrow.MemorySlot);
            display.SaveCustomCharacter(TextCharacters.BoxSelected.CharMap, TextCharacters.BoxSelected.MemorySlot);
        }
Ejemplo n.º 14
0
        void CreateMenu(ITextDisplay display)
        {
            Console.WriteLine("Load menu data...");

            var menuData = LoadResource("menu.json");

            Console.WriteLine($"Data length: {menuData.Length}...");

            Console.WriteLine("Create menu...");

            menu = new Menu(display, menuData, false);

            menu.Selected += Menu_Selected;
        }
Ejemplo n.º 15
0
        public DehydratorController(AnalogTemperature tempSensor, SoftPwm heater, Relay fan, ITextDisplay display)
        {
            _tempSensor     = tempSensor;
            _heaterRelayPwm = heater;
            _fanRelay       = fan;
            _display        = display;

            _pidController = new StandardPidController();
            _pidController.ProportionalComponent   = .5f;  // proportional
            _pidController.IntegralComponent       = .55f; // integral time minutes
            _pidController.DerivativeComponent     = 0f;   // derivative time in minutes
            _pidController.OutputMin               = 0.0f; // 0% power minimum
            _pidController.OutputMax               = 1.0f; // 100% power max
            _pidController.OutputTuningInformation = false;
        }
Ejemplo n.º 16
0
        private void Init(ITextDisplay display, MenuPage menuPage)
        {
            //good here
            this.display = display;

            rootMenuPage = menuPage;

            pageStack = new Stack <IPage>();

            // Save our custom characters
            // ToDo
            display.SaveCustomCharacter(TextCharacters.RightArrow.CharMap, TextCharacters.RightArrow.MemorySlot);
            display.SaveCustomCharacter(TextCharacters.RightArrowSelected.CharMap, TextCharacters.RightArrow.MemorySlot);
            display.SaveCustomCharacter(TextCharacters.BoxSelected.CharMap, TextCharacters.BoxSelected.MemorySlot);
        }
Ejemplo n.º 17
0
        internal ITextDisplay showText(String text, String cameraName)
        {
            ITextDisplay textDisplay = null;

            if (TextDisplayFactory != null)
            {
                textDisplay = TextDisplayFactory.createTextDisplay(cameraName);
                textDisplay.setText(text);
                textDisplay.show();
            }
            else
            {
                Log.Warning("Could not display text {0}. No TextDisplayFactory defined.");
            }
            return(textDisplay);
        }
Ejemplo n.º 18
0
        public App()
        {
            _encoder = new RotaryEncoderWithButton(
                N.Pins.GPIO_PIN_D2, N.Pins.GPIO_PIN_D3, N.Pins.GPIO_PIN_D4,
                Netduino.Foundation.CircuitTerminationType.CommonGround);
            _display = new SerialLCD(new TextDisplayConfig()
            {
                Height = 4, Width = 20
            }) as ITextDisplay;

            // set display brightness
            _display.SetBrightness();

            _menu               = new Menu(_display, _encoder, Resources.GetBytes(Resources.BinaryResources.menu));
            _menu.Selected     += HandleMenuSelected;
            _menu.ValueChanged += HandleMenuValueChanged;
        }
Ejemplo n.º 19
0
        private void Init(ITextDisplay display, RotaryEncoderWithButton encoder, MenuPage menuTree)
        {
            _display = display;
            _encoder = encoder;

            _rootMenuPage = menuTree;
            UpdatedCurrentMenuPage();
            RenderCurrentMenuPage();
            _menuLevel = new Stack();

            _encoder.Rotated += HandlEncoderRotation;
            _encoder.Clicked += HandleEncoderClick;

            // Save our custom characters
            _display.SaveCustomCharacter(TextCharacters.RightArrow.CharMap, TextCharacters.RightArrow.MemorySlot);
            _display.SaveCustomCharacter(TextCharacters.RightArrowSelected.CharMap, TextCharacters.RightArrow.MemorySlot);
            _display.SaveCustomCharacter(TextCharacters.BoxSelected.CharMap, TextCharacters.BoxSelected.MemorySlot);
        }
Ejemplo n.º 20
0
        private void UpdateDescriptionText(UpdateParams uparams)
        {
            Piece   piece   = RetrieveCurrentInformationPiece(uparams);
            Invader invader = RetrieveCurrentSelectedInvader(uparams);

            txtDescription.Visible = false;
            btnSell.Visible        = (piece != null & mSelectedPiece != null && mSelectedPiece.Equals(piece));
            btnUpgrade.Visible     = btnSell.Visible;
            btnUpgrade.Enabled     = btnSell.Visible && piece.CanUpgrade;

            if (piece != null || invader != null)
            {
                txtDescription.Visible = true;
                ITextDisplay provider = (piece != null ? (ITextDisplay)piece : (ITextDisplay)invader);
                DisplayDescriptionForTextProvider(provider);
                DisplayCaptionForTextProvider(provider);
            }
        }
Ejemplo n.º 21
0
        protected void InitializePeripherals()
        {
            // display
            //_display = new Lcd2004(new MCP23008());
            _display = new Lcd2004(N.Pins.GPIO_PIN_D8, N.Pins.GPIO_PIN_D9, N.Pins.GPIO_PIN_D10, N.Pins.GPIO_PIN_D11, N.Pins.GPIO_PIN_D12, N.Pins.GPIO_PIN_D13);
            _display.Clear();
            _display.WriteLine("Display up!", 0);

            // rotary encoder
            _encoder = new RotaryEncoderWithButton(N.Pins.GPIO_PIN_D4, N.Pins.GPIO_PIN_D5, N.Pins.GPIO_PIN_D7, CircuitTerminationType.CommonGround);

            // door stuff
            _doorServo          = new ContinuousRotationServo(N.PWMChannels.PWM_PIN_D6, NamedServoConfigs.IdealContinuousRotationServo);
            _openEndStopSwitch  = new PushButton(N.Pins.GPIO_PIN_D2, CircuitTerminationType.CommonGround);
            _closeEndStopSwitch = new PushButton(N.Pins.GPIO_PIN_D3, CircuitTerminationType.CommonGround);
            _display.WriteLine("Door stuff up!", 1);

            // temp stuff
            _heatLampRelay = new SoftPwm(N.Pins.GPIO_PIN_D0, 0, 1f / 60f);
            _tempSensor    = new AnalogTemperature(N.AnalogChannels.ANALOG_PIN_A0, AnalogTemperature.KnownSensorType.LM35, updateInterval: 5000, temperatureChangeNotificationThreshold: 1.0f);
            _display.WriteLine("Temp stuff up!", 2);

            //==== now wire up all the peripheral events
            // Analog Temp Sensor. Setup to notify at half a degree changes
            _tempSensor.TemperatureChanged += (object sender, SensorFloatEventArgs e) => {
                _currentTemp = e.CurrentValue;
                Debug.Print("Current Temp: " + _currentTemp.ToString("N1"));
                UpdateInfoScreen();
            };

            _encoder.Clicked += (s, e) =>
            {
                // if the menu isn't displayed, display it. otherwise
                // encoder click events are handled by menu
                if (!_inMenu)
                {
                    this.DisplayMenu();
                }
            };


            Debug.Print("Peripherals initialized.");
        }
Ejemplo n.º 22
0
 public override void editing()
 {
     if (text != null)
     {
         textDisplay = TimelineController.showText(text, CameraName);
         if (textDisplay != null)
         {
             textDisplay.Position             = position;
             textDisplay.Size                 = size;
             textDisplay.FontName             = fontName;
             textDisplay.FontHeight           = fontHeight;
             textDisplay.TextAlign            = textAlign;
             textDisplay.ScenePoint           = scenePoint;
             textDisplay.PositionOnScenePoint = positionOnScenePoint;
             textDisplay.Editable             = true;
             textDisplay.TextEdited          += new EventDelegate <ITextDisplay, string>(textDisplay_TextEdited);
         }
     }
 }
Ejemplo n.º 23
0
        public App()
        {
            // SETUP CONTROL

            // use encoder with push button
            _encoder = new RotaryEncoderWithButton(
                N.Pins.GPIO_PIN_D7, N.Pins.GPIO_PIN_D6, N.Pins.GPIO_PIN_D5,
                Netduino.Foundation.CircuitTerminationType.CommonGround);

            // use buttons
            //_next = new PushButton(N.Pins.GPIO_PIN_D6, Netduino.Foundation.CircuitTerminationType.CommonGround);
            //_previous = new PushButton(N.Pins.GPIO_PIN_D7, Netduino.Foundation.CircuitTerminationType.CommonGround);
            //_select = new PushButton(N.Pins.GPIO_PIN_D5, Netduino.Foundation.CircuitTerminationType.CommonGround);

            // SETUP DISPLAY

            // GPIO
            _display = new Lcd2004(N.Pins.GPIO_PIN_D13, N.Pins.GPIO_PIN_D12, N.Pins.GPIO_PIN_D11, N.Pins.GPIO_PIN_D10, N.Pins.GPIO_PIN_D9, N.Pins.GPIO_PIN_D8);

            // SERIAL LCD
            //_display = new SerialLCD(new TextDisplayConfig() { Height = 4, Width = 20 }) as ITextDisplay;

            // MCP (i2c)
            //_mcp = new MCP23008();
            //_display = new Lcd2004(_mcp);

            // set display brightness
            _display.SetBrightness();

            // Create menu with encoder
            _menu = new Menu(_display, _encoder, Resources.GetBytes(Resources.BinaryResources.menu), true);

            // Create menu with buttons
            //_menu = new Menu(_display, _next, _previous, _select, Resources.GetBytes(Resources.BinaryResources.menu));

            _menu.Selected     += HandleMenuSelected;
            _menu.ValueChanged += HandleMenuValueChanged;
            _menu.Exited       += HandleMenuExited;

            _menu.Enable();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Configures the hardware perihperals (LCD, temp sensor, relays, etc.)
        /// so they can be used by the application.
        /// </summary>
        protected void InitializePeripherals()
        {
            // pushbutton (for testing)
            _pushButton = new PushButton(
                (H.Cpu.Pin) 0x15, CircuitTerminationType.Floating);

            // Rotary Encoder
            _encoder = new RotaryEncoderWithButton(
                N.Pins.GPIO_PIN_D7, N.Pins.GPIO_PIN_D6, N.Pins.GPIO_PIN_D5,
                CircuitTerminationType.CommonGround);

            // LCD
            //_display = new Lcd2004(new MCP23008());
            _display = new Lcd2004(N.Pins.GPIO_PIN_D8, N.Pins.GPIO_PIN_D9, N.Pins.GPIO_PIN_D10, N.Pins.GPIO_PIN_D11, N.Pins.GPIO_PIN_D12, N.Pins.GPIO_PIN_D13);
            _display.Clear();
            Debug.Print("Display up.");
            _display.WriteLine("Display up!", 0);

            // Analog Temp Sensor. Setup to notify at half a degree changes
            _tempSensor = new AnalogTemperature(N.AnalogChannels.ANALOG_PIN_A0,
                                                AnalogTemperature.KnownSensorType.LM35, temperatureChangeNotificationThreshold: 0.5F);
            Debug.Print("TempSensor up.");
            _display.WriteLine("Temp Sensor up!", 1);

            // Heater driven by Software PWM
            _heaterRelayPwm = new SoftPwm(N.Pins.GPIO_PIN_D2, 0.5f, 1.0f / 30.0f);
            Debug.Print("Heater PWM up.");
            _display.WriteLine("Heater PWM up!", 2);

            // Fan Relay
            _fanRelay = new Relay(N.Pins.GPIO_PIN_D3);
            Debug.Print("Fan up.");
            _display.WriteLine("Fan up!", 3);

            // output status
            Debug.Print("Peripherals up");
            _display.WriteLine("Peripherals online!", 0);
        }
Ejemplo n.º 25
0
 public void Init(ITextDisplay display, RotaryEncoderWithButton encoder)
 {
     _display = display;
     _encoder = encoder;
     _isInit  = true;
 }
Ejemplo n.º 26
0
        public async Task Initialize()
        {
            this.playbackRetries = 0;

            var telemetryInitializeProperties = new Dictionary<string, string>();
#pragma warning disable CS0618 // No current view for Background task
            this.resourceLoader = new ResourceLoader("Resources");
#pragma warning restore CS0618 // No current view for Background task           

            this.radioPowerManager = new RadioPowerManager();
            this.radioPowerManager.PowerStateChanged += RadioPowerManager_PowerStateChanged;

            this.radioPresetManager = new RadioLocalPresetManager();
            this.radioPresetManager.PlaylistChanged += RadioPresetManager_PlaylistChanged;
            this.radioPresetManager.CurrentTrackChanged += RadioPresetManager_CurrentTrackChanged;

            this.radioPlaybackManager = new MediaEnginePlaybackManager();
            this.radioPlaybackManager.VolumeChanged += RadioPlaybackManager_VolumeChanged;
            this.radioPlaybackManager.PlaybackStateChanged += RadioPlaybackManager_PlaybackStateChanged;
            await this.radioPlaybackManager.InitialzeAsync();

            // Initialize the input managers
            allJoynInterfaceManager = new AllJoynInterfaceManager(this.radioPlaybackManager, this.radioPresetManager, this.radioPowerManager);
            this.allJoynInterfaceManager.Initialize();
            
            await this.tryWriteToDisplay(this.resourceLoader.GetString("AllJoynIdMessage") +"\n" + this.allJoynInterfaceManager.GetBusId(), 0);

            this.gpioInterfaceManager = new GpioInterfaceManager(this.radioPlaybackManager, this.radioPresetManager, this.radioPowerManager);
            if (!this.gpioInterfaceManager.Initialize())
            {
                Debug.WriteLine("RadioManager: Failed to initialize GPIO");
                telemetryInitializeProperties.Add("GpioAvailable", false.ToString());
            }
            else
            {
                telemetryInitializeProperties.Add("GpioAvailable", true.ToString());
            }

            this.appServicesInterfaceManager = new AppServicesInterfaceManager(this.radioPlaybackManager, this.radioPresetManager, this.radioPowerManager);

            // Manage settings
            this.radioPlaybackManager.Volume = this.loadVolume();
            var previousPlaylist = this.loadPlaylistId();
            if (previousPlaylist.HasValue)
            {
                await this.radioPresetManager.LoadPlayList(previousPlaylist.Value);
                telemetryInitializeProperties.Add("FirstBoot", false.ToString());
            }
            else
            {
                telemetryInitializeProperties.Add("FirstBoot", true.ToString());
            }

            if (this.radioPresetManager.CurrentPlaylist == null)
            {
                var newPlaylistId = await this.radioPresetManager.StartNewPlaylist("DefaultPlaylist", new List<Track>(), true);
                this.savePlaylistId(newPlaylistId);
            }

            var displays = await TextDisplayManager.GetDisplays();
            this.display = displays.FirstOrDefault();
            if (null != this.display)
            {
                telemetryInitializeProperties.Add("DisplayAvailable", true.ToString());
                telemetryInitializeProperties.Add("DisplayHeight", this.display.Height.ToString());
                telemetryInitializeProperties.Add("DisplayWidth", this.display.Width.ToString());
            }
            else
            {
                Debug.WriteLine("RadioManager: No displays available");
                telemetryInitializeProperties.Add("DisplayAvailable", false.ToString());
            }

            // Wake up the radio
            this.radioPowerManager.PowerState = PowerState.Powered;

            StartupTask.WriteTelemetryEvent("App_Initialize", telemetryInitializeProperties);
        }
Ejemplo n.º 27
0
 public Menu(ITextDisplay display, MenuItem[] menuItems, bool showBackOnRoot = false)
 {
     Init(display, CreateMenuPage(menuItems, showBackOnRoot));
 }
Ejemplo n.º 28
0
 public Menu(ITextDisplay display, IRotaryEncoder encoder, IButton buttonSelect, byte[] menuResource, bool showBackOnRoot = false)
 {
     _showBackOnRoot = showBackOnRoot;
     Init(display, encoder, null, null, buttonSelect, ParseMenuData(menuResource));
 }
Ejemplo n.º 29
0
        public IAsyncAction Initialize(InternetRadioConfig config)
        {
            return Task.Run(async () =>
            {
                this.config = config;
                this.playbackRetries = 0;

                var telemetryInitializeProperties = new Dictionary<string, string>();
#pragma warning disable CS0618 // No current view for Background task
                this.resourceLoader = new ResourceLoader("Resources");
#pragma warning restore CS0618 // No current view for Background task           

                this.radioPowerManager = new RadioPowerManager();
                this.radioPowerManager.PowerStateChanged += RadioPowerManager_PowerStateChanged;

                this.radioPresetManager = new RadioLocalPresetManager();
                this.radioPresetManager.PlaylistChanged += RadioPresetManager_PlaylistChanged;
                this.radioPresetManager.CurrentTrackChanged += RadioPresetManager_CurrentTrackChanged;

                this.radioPlaybackManager = new MediaEnginePlaybackManager();
                this.radioPlaybackManager.VolumeChanged += RadioPlaybackManager_VolumeChanged;
                this.radioPlaybackManager.PlaybackStateChanged += RadioPlaybackManager_PlaybackStateChanged;
                await this.radioPlaybackManager.InitialzeAsync();

                // Initialize the input managers

                // AllJoyn
                this.allJoynInterfaceManager = new AllJoynInterfaceManager(this.radioPlaybackManager, this.radioPresetManager, this.radioPowerManager);
                this.allJoynInterfaceManager.Initialize();

                // GPIO
                this.gpioInterfaceManager = new GpioInterfaceManager(this.radioPlaybackManager, this.radioPresetManager, this.radioPowerManager);
                if (!this.gpioInterfaceManager.Initialize(this.config.Buttons_Debounce, this.config.Buttons_Pins))
                {
                    Debug.WriteLine("RadioManager: Failed to initialize GPIO");
                    telemetryInitializeProperties.Add("GpioAvailable", false.ToString());
                }
                else
                {
                    telemetryInitializeProperties.Add("GpioAvailable", true.ToString());
                }

                // HTTP
                this.httpInterfaceManager = new HttpInterfaceManager(8001, this.radioPlaybackManager, this.radioPresetManager, this.radioPowerManager);
                this.httpInterfaceManager.StartServer();

                // Manage settings
                this.radioPlaybackManager.Volume = this.loadVolume();
                var previousPlaylist = this.loadPlaylistId();
                if (previousPlaylist.HasValue)
                {
                    await this.radioPresetManager.LoadPlayList(previousPlaylist.Value);
                    telemetryInitializeProperties.Add("FirstBoot", false.ToString());
                }
                else
                {
                    telemetryInitializeProperties.Add("FirstBoot", true.ToString());
                }

                if (this.radioPresetManager.CurrentPlaylist == null)
                {
                    var newPlaylistId = await this.radioPresetManager.StartNewPlaylist("DefaultPlaylist", new List<Track>(), true);
                    this.savePlaylistId(newPlaylistId);
                }

                var displays = await TextDisplayManager.GetDisplays();
                this.display = displays.FirstOrDefault();
                if (null != this.display)
                {
                    telemetryInitializeProperties.Add("DisplayAvailable", true.ToString());
                    telemetryInitializeProperties.Add("DisplayHeight", this.display.Height.ToString());
                    telemetryInitializeProperties.Add("DisplayWidth", this.display.Width.ToString());
                }
                else
                {
                    Debug.WriteLine("RadioManager: No displays available");
                    telemetryInitializeProperties.Add("DisplayAvailable", false.ToString());
                }

                // Wake up the radio
                this.radioPowerManager.PowerState = PowerState.Powered;

                if (this.radioPresetManager.CurrentPlaylist.Tracks.Count <= 0)
                {
                    this.radioPresetManager.CurrentPlaylist.Tracks.Add(this.config.Playlist_BuiltInStation);
                }

                TelemetryManager.WriteTelemetryEvent("App_Initialize", telemetryInitializeProperties);
            }).AsAsyncAction();
        }
Ejemplo n.º 30
0
 public Player(string playerName, ITextDisplay textDisplay)
 {
     _textDisplay = textDisplay;
 }
Ejemplo n.º 31
0
 public BoardPlainTextUIDisplay(ITextDisplay display)
 {
     _display = display;
 }
Ejemplo n.º 32
0
 public Menu(ITextDisplay display, IButton buttonNext, IButton buttonPrevious, IButton buttonSelect, byte[] menuResource, bool showBackOnRoot = false)
 {
     _showBackOnRoot = showBackOnRoot;
     Init(display, null, buttonNext, buttonPrevious, buttonSelect, ParseMenuData(menuResource));
 }