예제 #1
0
        public MeadowApp()
        {
            Console.WriteLine("Initializing...");

            //display = new CharacterDisplay
            //(
            //    device: Device,
            //    pinV0: Device.Pins.D11,
            //    pinRS: Device.Pins.D10,
            //    pinE: Device.Pins.D09,
            //    pinD4: Device.Pins.D08,
            //    pinD5: Device.Pins.D07,
            //    pinD6: Device.Pins.D06,
            //    pinD7: Device.Pins.D05,
            //    rows: 4, columns: 20    // Adjust dimensions to fit your display
            //);

            display = new CharacterDisplay
                      (
                Device.CreatePwmPort(Device.Pins.D11, 100, 0.5f, true),
                Device.CreateDigitalOutputPort(Device.Pins.D10),
                Device.CreateDigitalOutputPort(Device.Pins.D09),
                Device.CreateDigitalOutputPort(Device.Pins.D08),
                Device.CreateDigitalOutputPort(Device.Pins.D07),
                Device.CreateDigitalOutputPort(Device.Pins.D06),
                Device.CreateDigitalOutputPort(Device.Pins.D05),
                rows: 4, columns: 20    // Adjust dimensions to fit your display
                      );

            TestCharacterDisplay();

            Console.WriteLine("done");
        }
    protected override IEnumerator AnimateAttack(IEnumerable <ObjectDisplay> enemies)
    {
        var atkPwrVal  = attackPower.GetValue();
        var instanceId = GetInstanceID();
        var allyArray  = enemies.Where(x => x.GetInstanceID() != instanceId)
                         .Select(x => (CharacterDisplay)x)
                         .ToArray();
        var minRateHp = 1f;
        CharacterDisplay minHpChar = null;

        foreach (var c in allyArray)
        {
            var rateHp = c.hp / c.maxHP;
            if (rateHp < minRateHp)
            {
                minRateHp = rateHp;
                minHpChar = c;
            }
        }
        if (minHpChar == null || minHpChar is Object && minHpChar.Equals(null))
        {
            yield break;
        }
        if (minHpChar.hp >= minHpChar.maxHP)
        {
            minHpChar.hp = minHpChar.maxHP;
            yield break;
        }
        minHpChar.hp += atkPwrVal;
    }
예제 #3
0
    public static void Main()
    {
        //todo: include electrical schematics

        /*  Pick a driver that matches your hardware setup */
        IDriveTextDisplays driver = null;

        // GPIO or MCP23017 driver
        driver = GetGpio8Driver();
        //driver = GetGpio4Driver();
        //driver = GetMcp8Driver();
        //driver = GetMcp4Driver();

        CharacterDisplay lcd = new CharacterDisplay(20, 4, driver)
        {
            IsCursorBlinking   = false,
            IsCursorUnderlined = false
        };

        /* Hook user input buttons */
        IRunnerUserInput input = null;

        // GPIO or MCP23017 indirected
        input = GetGpioInput();

        /* Run the tests */
        lcd.ClearScreen();
        TextTestHarness.RunTests(Assembly.GetExecutingAssembly(), lcd, input);
    }
예제 #4
0
        void InitGpio()
        {
            Console.WriteLine("InitGpio...");

            //display = new CharacterDisplay
            //(
            //    portRS: Device.CreateDigitalOutputPort(Device.Pins.D10),
            //    portE: Device.CreateDigitalOutputPort(Device.Pins.D09),
            //    portD4: Device.CreateDigitalOutputPort(Device.Pins.D08),
            //    portD5: Device.CreateDigitalOutputPort(Device.Pins.D07),
            //    portD6: Device.CreateDigitalOutputPort(Device.Pins.D06),
            //    portD7: Device.CreateDigitalOutputPort(Device.Pins.D05),
            //    rows: 4, columns: 20
            //);

            display = new CharacterDisplay
                      (
                device: Device,
                pinRS: Device.Pins.D10,
                pinE: Device.Pins.D09,
                pinD4: Device.Pins.D08,
                pinD5: Device.Pins.D07,
                pinD6: Device.Pins.D06,
                pinD7: Device.Pins.D05,
                rows: 4, columns: 20
                      );
        }
예제 #5
0
        void InitGpioWithPWM()
        {
            Console.WriteLine("InitGpioWithPWM...");

            //display = new CharacterDisplay
            //(
            //    portV0: Device.CreatePwmPort(Device.Pins.D11, 100, 0.5f, true),
            //    portRS: Device.CreateDigitalOutputPort(Device.Pins.D10),
            //    portE:  Device.CreateDigitalOutputPort(Device.Pins.D09),
            //    portD4: Device.CreateDigitalOutputPort(Device.Pins.D08),
            //    portD5: Device.CreateDigitalOutputPort(Device.Pins.D07),
            //    portD6: Device.CreateDigitalOutputPort(Device.Pins.D06),
            //    portD7: Device.CreateDigitalOutputPort(Device.Pins.D05),
            //    rows: 4, columns: 20    // Adjust dimensions to fit your display
            //);

            display = new CharacterDisplay
                      (
                device: Device,
                pinV0: Device.Pins.D11,
                pinRS: Device.Pins.D10,
                pinE:  Device.Pins.D09,
                pinD4: Device.Pins.D08,
                pinD5: Device.Pins.D07,
                pinD6: Device.Pins.D06,
                pinD7: Device.Pins.D05,
                rows: 4, columns: 20
                      );
        }
예제 #6
0
 public void UpgradeByDiamond(System.Action then)
 {
     if (_baseCharacter == null || _baseCharacter is Object && _baseCharacter.Equals(null))
     {
         return;
     }
     _currency.PurchaseByDiamond(upgradedCost.Diamond, () =>
     {
         _baseCharacter.attackPower *= (1 + upgradedAttackRate);
         _baseCharacter.hp          *= (1 + upgradedHpRate);
         ++_baseCharacter.level;
         _baseCharacter.AssignUpgradedDisplay();
         attackPower          = _baseCharacter.attackPower;
         hp                   = _baseCharacter.hp;
         level                = _baseCharacter.level;
         display              = _baseCharacter.displayPrefab;
         var upgradedGoldRate = GetUpgradedCostRate();
         _baseCharacter.upgradedCost.Diamond *= (1 + upgradedGoldRate);
         upgradedCost = _baseCharacter.upgradedCost;
         if (then != null)
         {
             then();
         }
     });
 }
예제 #7
0
        public MeadowApp()
        {
            var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue);

            led.SetColor(RgbLed.Colors.Red);

            rtc = new Ds1307(Device.CreateI2cBus());
            // Uncomment only when setting the time
            // rtc.SetTime(new DateTime(2019, 11, 23, 22, 55, 20));

            display = new CharacterDisplay
                      (
                device: Device,
                pinRS: Device.Pins.D15,
                pinE: Device.Pins.D14,
                pinD4: Device.Pins.D13,
                pinD5: Device.Pins.D12,
                pinD6: Device.Pins.D11,
                pinD7: Device.Pins.D10
                      );

            led.SetColor(RgbLed.Colors.Green);

            StartCountdown();
        }
예제 #8
0
        void InitI2c()
        {
            Console.WriteLine("Initializing I2C...");

            display = new CharacterDisplay(Device.CreateI2cBus(I2cBusSpeed.Standard),
                                           I2cCharacterDisplay.DefaultI2cAddress,
                                           2, 16);
        }
예제 #9
0
 public RealDeployerFactory(EthernetENC28J60 ethernet, StorageDevice storageDevice, BreakoutTB10 breakout,
                            CharacterDisplay characterDisplay,
                            Tunes tunes)
 {
     _ethernet         = ethernet;
     _storageDevice    = storageDevice;
     _breakout         = breakout;
     _characterDisplay = characterDisplay;
     _tunes            = tunes;
 }
 public RealDeployerFactory(EthernetENC28J60 ethernet, StorageDevice storageDevice, BreakoutTB10 breakout,
                            CharacterDisplay characterDisplay,
                            Tunes tunes)
 {
     _ethernet = ethernet;
     _storageDevice = storageDevice;
     _breakout = breakout;
     _characterDisplay = characterDisplay;
     _tunes = tunes;
 }
예제 #11
0
    public void AssignUpgradedDisplay()
    {
        if (upgradedAnimationLevels.All(x => x.level != level))
        {
            return;
        }
        var mUpgradedAnimationLevel = upgradedAnimationLevels.FirstOrDefault(x => x.level == level);

        displayPrefab = (CharacterDisplay)mUpgradedAnimationLevel.characterDisplay;
    }
예제 #12
0
        void InitI2c()
        {
            Console.WriteLine("InitI2c...");

            display = new CharacterDisplay
                      (
                i2cBus: Device.CreateI2cBus(I2cBusSpeed.Standard),
                address: I2cCharacterDisplay.DefaultI2cAddress,
                rows: 4, columns: 20
                      );
        }
예제 #13
0
 void SetBaseCharacterValue(BaseCharacter baseCharacter)
 {
     characterName      = baseCharacter.name;
     attackPower        = baseCharacter.attackPower;
     hp                 = baseCharacter.hp;
     level              = baseCharacter.level;
     display            = baseCharacter.displayPrefab;
     upgradedCost       = _baseCharacter.upgradedCost;
     upgradedAttackRate = _baseCharacter.upgradedAttackRate;
     upgradedHpRate     = _baseCharacter.upgradedHpRate;
 }
예제 #14
0
        /// <summary>
        /// Testing method for CharacterDisplay module (function never returns)
        /// </summary>
        static void TestCharDisplay()
        {
            var characterDisp = new CharacterDisplay(FEZRaptor.Socket1.Pin3, FEZRaptor.Socket1.Pin4, FEZRaptor.Socket1.Pin5, FEZRaptor.Socket1.Pin6, FEZRaptor.Socket1.Pin7, FEZRaptor.Socket1.Pin8, FEZRaptor.Socket1.Pin9);

            characterDisp.Print("Hellow world...");
            characterDisp.BacklightEnabled = true;
            Thread.Sleep(5000);
            characterDisp.Clear();
            characterDisp.Print("Hurrayyy...");
            Thread.Sleep(Timeout.Infinite);
        }
예제 #15
0
        public MeadowApp()
        {
            try
            {
                hour          = new PushButton(Device, Device.Pins.D15);
                hour.Clicked += HourClicked;

                Console.WriteLine("subscribe test");
                //minute = new PushButton(Device, Device.Pins.D12);
                //minute.Clicked += MinuteClicked;
                this.inputPort = Device.CreateDigitalInputPort(Device.Pins.D12, interruptMode:  InterruptMode.EdgeBoth, debounceDuration: 100);

                //this.inputPort.Changed += (object sender, DigitalInputPortEventArgs e) =>
                //{
                //    //Console.WriteLine("Change detected");
                //    Console.WriteLine($"Old school event raised; Time: {e.New.Millisecond}, Value: {e.Value}");
                //};

                this.inputPort.Subscribe(new FilterableChangeObserver <DigitalInputPortEventArgs, DateTime>(
                                             e =>
                {
                    if (!e.Value)
                    {
                        Console.WriteLine($"Event observed at {e.New.Millisecond}, Value: {e.Value}\r\n");
                        this.MinuteClicked(null, null);
                    }
                },
                                             f =>
                {
                    return(true);    // return (f.Delta > new TimeSpan(0, 0, 0, 0, 100));
                }));

                display = new CharacterDisplay
                          (
                    device: Device,
                    pinRS: Device.Pins.D10,
                    pinE: Device.Pins.D09,
                    pinD4: Device.Pins.D08,
                    pinD5: Device.Pins.D07,
                    pinD6: Device.Pins.D06,
                    pinD7: Device.Pins.D05
                          );

                Device.SetClock(new DateTime(2020, 07, 24, 11, 00, 00));

                CharacterDisplayClock();
            }
            catch (Exception e)
            {
                Console.WriteLine($"Exception: {e.ToString()}");
            }
        }
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(transform.root.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(transform.root.gameObject);
 }
예제 #17
0
    public void SelectSuspect()
    {
        GameObject clickedButton = EventSystem.current.currentSelectedGameObject;
        GameObject selected      = clickedButton.transform.Find("Image").gameObject;

        currentSuspect = clickedButton.GetComponent <CharacterDisplay>();
        foreach (CharacterDisplay cd in suspectsPanel.GetComponentsInChildren <CharacterDisplay>())
        {
            cd.transform.Find("Image").gameObject.SetActive(false);
        }

        selected.SetActive(true);
    }
 void Initialize()
 {
     display = new CharacterDisplay
               (
         device: MeadowApp.Device,
         pinRS:  MeadowApp.Device.Pins.D10,
         pinE:   MeadowApp.Device.Pins.D09,
         pinD4:  MeadowApp.Device.Pins.D08,
         pinD5:  MeadowApp.Device.Pins.D07,
         pinD6:  MeadowApp.Device.Pins.D06,
         pinD7:  MeadowApp.Device.Pins.D05,
         rows: 4, columns: 20
               );
 }
예제 #19
0
    public void PointGuilty()
    {
        GameObject clickedButton       = EventSystem.current.currentSelectedGameObject;
        GameObject clickedButtonParent = clickedButton.transform.parent.gameObject;

        CharacterDisplay current = clickedButtonParent.GetComponentInChildren <CharacterDisplay>();

        if (current.character == GameManager.manager.guilty)
        {
            GameManager.manager.TeamVictory(player);
        }
        else
        {
            GameManager.manager.PlayerWrongGuess(gameObject, player);
        }
    }
예제 #20
0
        void InitGpio()
        {
            Console.WriteLine("Initializing GPIO...");

            display = new CharacterDisplay
                      (
                Device.CreatePwmPort(Device.Pins.D11, 100, 0.5f, true),
                Device.CreateDigitalOutputPort(Device.Pins.D10),
                Device.CreateDigitalOutputPort(Device.Pins.D09),
                Device.CreateDigitalOutputPort(Device.Pins.D08),
                Device.CreateDigitalOutputPort(Device.Pins.D07),
                Device.CreateDigitalOutputPort(Device.Pins.D06),
                Device.CreateDigitalOutputPort(Device.Pins.D05),
                rows: 4, columns: 20    // Adjust dimensions to fit your display
                      );
        }
예제 #21
0
 public void DisplayCharacter(CharacterDisplay characterDisplay, Character characterToDisplay)
 {
     if (characterToDisplay.isAlly)
     {
         characterDisplay.manaDisplay.text      = characterToDisplay.currentMana + " / " + characterToDisplay.maxMana;
         characterDisplay.manaFiller.fillAmount = characterToDisplay.currentMana / characterToDisplay.maxMana;
         characterDisplay.rageDisplay.text      = characterToDisplay.currentRage + " / " + characterToDisplay.maxRage;
         characterDisplay.rageFiller.fillAmount = characterToDisplay.currentRage / characterToDisplay.maxRage;
     }
     if (!characterToDisplay.isAlly)
     {
         characterDisplay.nameDisplay.text = characterToDisplay.displayName;
     }
     characterDisplay.lifeDisplay.text       = characterToDisplay.currentLife + " / " + characterToDisplay.maxLife;
     characterDisplay.lifeFiller.fillAmount  = characterToDisplay.currentLife / characterToDisplay.maxLife;
     characterDisplay.portraitDisplay.sprite = characterToDisplay.myLittleSprite;
 }
예제 #22
0
        public MeadowApp()
        {
            Console.WriteLine("Initializing...");

            display = new CharacterDisplay
                      (
                device: Device,
                pinRS: Device.Pins.D15,
                pinE: Device.Pins.D14,
                pinD4: Device.Pins.D13,
                pinD5: Device.Pins.D12,
                pinD6: Device.Pins.D11,
                pinD7: Device.Pins.D10
                      );

            TestCharacterDisplay();
        }
예제 #23
0
        public MeadowApp()
        {
            Console.WriteLine("Initializing...");

            display = new CharacterDisplay
                      (
                device: Device,
                pinRS: Device.Pins.D15,
                pinE: Device.Pins.D14,
                pinD4: Device.Pins.D13,
                pinD5: Device.Pins.D12,
                pinD6: Device.Pins.D11,
                pinD7: Device.Pins.D10,
                rows: 2, columns: 16    // Adjust dimensions to fit your display
                      );

            TestCharacterDisplay();
        }
예제 #24
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);

            bus = Device.CreateI2cBus();

            display = new CharacterDisplay(bus, 39, 2, 16);

            port = Device.CreateSerialMessagePort(Device.SerialPortNames.Com4, suffixDelimiter: new byte[] { 10 }, preserveDelimiter: true, 921600, 8, Parity.None, StopBits.One);
            port.Open();
            port.MessageReceived += Port_MessageReceived;
        }
예제 #25
0
    public static void Main()
    {
        /*  Pick a driver that matches your hardware setup */
        IDriveTextDisplays driver = null;

        CharacterDisplay lcd = new CharacterDisplay(20, 4, driver)
        {
            IsCursorBlinking   = false,
            IsCursorUnderlined = false
        };

        /* Hook user input buttons */
        IDigitalInterrupt startTests = Signals.DigitalInterrupt.Bind(Pin.Pin1, "Restart Testing", ResistorMode.PullUp, InterruptMode.InterruptEdgeLow, 50);
        var input = new GpioInput(startTests);

        /* Run the tests */
        lcd.ClearScreen();
        TextTestHarness.RunTests(Assembly.GetExecutingAssembly(), lcd, input);
    }
예제 #26
0
        public SettingsScreen()
        {
            index      = 0;
            prevUIType = UIType.Spinner;

            spn_speed = new Spinner(0, 0, new string[]
            {
                "5",
                "10",
                "20",
                "30",
                "40",
                "50",
            }, false);
            spn_mute      = new Spinner(0, 0, new string[] { "True", "False" }, true);
            spn_slowOpen  = new Spinner(0, 0, new string[] { "True", "False" }, true);
            chr_mute      = new CharacterDisplay(0, 0, 'm');
            chr_speedUp   = new CharacterDisplay(0, 0, ']');
            chr_speedDown = new CharacterDisplay(0, 0, '[');

            elements = new UIObject[]
            {
                spn_speed,
                spn_mute,
                spn_slowOpen,
                chr_mute,
                chr_speedUp,
                chr_speedDown
            };

            for (int i = 0; i < elements.Length; i++)
            {
                int xPos = Console.WindowWidth / 2 + 13 - elements[i].Width;
                elements[i].Move(xPos, 3 + i * 2, false);
            }

            elements[0].Toggle(false);

            textBox = new TextBox(Console.WindowWidth / 2 - 30, Console.WindowHeight - 10, 60, 8, BorderType.DashedHeavy);

            Console.SetCursorPosition(0, 0);
        }
예제 #27
0
        private void InitializeCharacterDisplay()
        {
            Console.WriteLine("Charter display initialized...");

            this.display = new CharacterDisplay(
                Device,
                pinRS: Device.Pins.D15,
                pinE: Device.Pins.D14,
                pinD4: Device.Pins.D13,
                pinD5: Device.Pins.D12,
                pinD6: Device.Pins.D11,
                pinD7: Device.Pins.D10,
                rows: 4, columns: 20    // Adjust dimensions to fit your display
                );

            this.display.ClearLines();

            this.display.WriteLine("Conditions", 0);
            this.display.WriteLine("Initializing...", 1);
        }
예제 #28
0
        public void Initialize()
        {
            if (initialized)
            {
                return;
            }

            display = new CharacterDisplay
                      (
                device: MeadowApp.Device,
                pinRS: MeadowApp.Device.Pins.D10,
                pinE: MeadowApp.Device.Pins.D09,
                pinD4: MeadowApp.Device.Pins.D08,
                pinD5: MeadowApp.Device.Pins.D07,
                pinD6: MeadowApp.Device.Pins.D06,
                pinD7: MeadowApp.Device.Pins.D05,
                rows: 4, columns: 20
                      );

            initialized = true;
        }
예제 #29
0
        public DeviceOutputService(IIODevice device, F7MicroPinDefinitions pins)
        {
            _onboardLed = new RgbPwmLed(device: device,
                                        redPwmPin: pins.OnboardLedRed,
                                        greenPwmPin: pins.OnboardLedGreen,
                                        bluePwmPin: pins.OnboardLedBlue,
                                        3.3f, 3.3f, 3.3f,
                                        IRgbLed.CommonType.CommonAnode);

            _tempLed = new RgbPwmLed(device, pins.D02, pins.D03, pins.D04);
            _display = new CharacterDisplay(
                device,
                pinRS: pins.D10,
                pinE: pins.D11,
                pinD4: pins.D12,
                pinD5: pins.D13,
                pinD6: pins.D14,
                pinD7: pins.D15,
                rows: 2, columns: 16
                );
        }
예제 #30
0
        //Max7219 display;
        //GraphicsLibrary graphics;

        public MeadowApp()
        {
            Console.Write("Initializing...");

            var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue);

            led.SetColor(RgbLed.Colors.Red);

            display = new CharacterDisplay
                      (
                device: Device,
                pinV0: Device.Pins.D11,
                pinRS: Device.Pins.D10,
                pinE: Device.Pins.D09,
                pinD4: Device.Pins.D08,
                pinD5: Device.Pins.D07,
                pinD6: Device.Pins.D06,
                pinD7: Device.Pins.D05
                      );

            //display = new Max7219(Device, Device.CreateSpiBus(), Device.Pins.D01, 4, Max7219.Max7219Type.Display);
            //graphics = new GraphicsLibrary(display);
            //graphics.CurrentFont = new Font4x8();
            //graphics.Rotation = RotationType._180Degrees;

            hour            = new PushButton(Device, Device.Pins.D15);
            hour.Clicked   += HourClicked;
            minute          = new PushButton(Device, Device.Pins.D12);
            minute.Clicked += MinuteClicked;

            Device.SetClock(new DateTime(2020, 03, 31, 00, 45, 00));

            led.SetColor(RgbLed.Colors.Green);
            Console.WriteLine("done");

            CharacterDisplayClock();
            //RunClock();
        }
        public CharacterDisplayApp()
        {
            display = new CharacterDisplay
                      (
                device: Device,
                pinRS: Device.Pins.D05,
                pinE: Device.Pins.D07,
                pinD4: Device.Pins.D08,
                pinD5: Device.Pins.D09,
                pinD6: Device.Pins.D10,
                pinD7: Device.Pins.D11
                      );

            int count = 0;

            display.WriteLine("CharacterDisplay", 0);

            while (true)
            {
                display.WriteLine($"Count is : {count++}", 1);
                System.Threading.Thread.Sleep(1000);
            }
        }
예제 #32
0
		public CharDisplay(CharacterDisplay cd)
		{
			_cd = cd;
			_previousLine1 = "";
			_previousLine2 = "";
		}