예제 #1
0
        /// <summary>
        /// Main loop
        /// </summary>
        public static void Main()
        {
            // create a thread handler
            Thread MyThreadHandler;

            // create a new thread object
            // and assing to my handler
            MyThreadHandler = new Thread(Heartbeat);

            // start my new thread
            MyThreadHandler.Start();

            selectors[0] = new Selector(Selectors.A,pinSelectorA);
            selectors[0].OnChange += new SelectorChange(OnSelectorChange);

            selectors[1] = new Selector(Selectors.B, pinSelectorB);
            selectors[1].OnChange += new SelectorChange(OnSelectorChange);

            selectors[2] = new Selector(Selectors.C, pinSelectorC);
            selectors[2].OnChange += new SelectorChange(OnSelectorChange);

            _spi_config = new
                SPI.Configuration(
                        (Cpu.Pin)FEZ_Pin.Digital.Di4,
                        false,
                        0,
                        0,
                        false,
                        true,
                        900,
                        SPI.SPI_module.SPI1);

            _spi = new SPI(_spi_config);

            DisplayRoutineAlphabet drAlphabet = new DisplayRoutineAlphabet();
            DisplayRoutineImages drImages = new DisplayRoutineImages();
            DisplayRoutineColorshifter drColorShifter = new DisplayRoutineColorshifter();
            DisplayRoutineColorfader drColorfader = new DisplayRoutineColorfader();
            DisplayRoutinePong drPong = new DisplayRoutinePong();
            DisplayRoutineMovingLines drMovingLines = new DisplayRoutineMovingLines();

            DisplayRoutineMovingDot drMovingDot = new DisplayRoutineMovingDot();
            DisplayRoutineSnake drSnake = new DisplayRoutineSnake();
            DisplayRoutineTextScrollYuki drTextScrollYuki = new DisplayRoutineTextScrollYuki();
            DisplayRoutineTextScrollAnton drTextScrollAnton = new DisplayRoutineTextScrollAnton();
            DisplayRoutineNumbers drNumbers = new DisplayRoutineNumbers();
            DisplayRoutineCurtains drCurtains = new DisplayRoutineCurtains();

            DisplayRoutine drCurrent = drAlphabet;

            int sleepInterval = 0;

            int selectorPosition0 = 1;
            int selectorPosition1 = 1;
            int selectorPosition2 = 1;

            int selectorPositionTmp0 = 0;
            int selectorPositionTmp1 = 0;
            int selectorPositionTmp2 = 0;

            //selectorPosition0 = selectors[0].Read();
            selectorPosition1 = selectors[1].Read();
            selectorPosition2 = selectors[2].Read();

            drCurrent.Start(selectorPosition1, selectorPosition2);

            while (true)
            {
                selectorPositionTmp0 = selectors[0].Read();
                if (selectorPosition0 != selectorPositionTmp0) {

                    selectorPosition0 = selectorPositionTmp0;

                    drCurrent.Stop();

                    if (selectorPosition0 == 1)
                    {
                        drCurrent = drAlphabet;
                    }
                    else if (selectorPosition0 == 2)
                    {
                        drCurrent = drColorShifter;
                    }
                    else if (selectorPosition0 == 3)
                    {
                        drCurrent = drColorfader;
                    }
                    else if (selectorPosition0 == 4)
                    {
                        drCurrent = drImages;
                    }
                    else if (selectorPosition0 == 5)
                    {
                        drCurrent = drMovingDot;
                    }
                    else if (selectorPosition0 == 6)
                    {
                        drCurrent = drMovingLines;
                    }
                    else if (selectorPosition0 == 7)
                    {
                        drCurrent = drNumbers;
                    }
                    else if (selectorPosition0 == 8)
                    {
                        drCurrent = drTextScrollYuki;
                    }
                    else if (selectorPosition0 == 9)
                    {
                        drCurrent = drTextScrollAnton;
                    }
                    else if (selectorPosition0 == 10)
                    {
                        drCurrent = drCurtains;
                    }
                    else if (selectorPosition0 == 11)
                    {
                        drCurrent = drPong;
                    }

                    drCurrent.Start(selectorPosition1,selectorPosition2);
                }

                //selectorPositionTmp1 = selectors[1].Read();
                //selectorPositionTmp2 = selectors[2].Read();
                if ((selectorPosition1 != selectorPositionTmp1) || (selectorPosition2 != selectorPositionTmp2)) {
                    selectorPosition1 = selectorPositionTmp1;
                    selectorPosition2 = selectorPositionTmp2;
                    drCurrent.UpdateSettings(selectorPosition1,selectorPosition2);
                }

                sleepInterval = drCurrent.Display();

                Thread.Sleep(sleepInterval);

                drCurrent.Next();

            }
        }
예제 #2
0
        /// <summary>
        /// Main loop
        /// </summary>
        public static void Main()
        {
            // create a thread handler
            Thread MyThreadHandler;

            // create a new thread object
            // and assing to my handler
            MyThreadHandler = new Thread(Heartbeat);

            // start my new thread
            MyThreadHandler.Start();

            selectors[0]           = new Selector(Selectors.A, pinSelectorA);
            selectors[0].OnChange += new SelectorChange(OnSelectorChange);

            selectors[1]           = new Selector(Selectors.B, pinSelectorB);
            selectors[1].OnChange += new SelectorChange(OnSelectorChange);

            selectors[2]           = new Selector(Selectors.C, pinSelectorC);
            selectors[2].OnChange += new SelectorChange(OnSelectorChange);

            _spi_config = new
                          SPI.Configuration(
                (Cpu.Pin)FEZ_Pin.Digital.Di4,
                false,
                0,
                0,
                false,
                true,
                900,
                SPI.SPI_module.SPI1);

            _spi = new SPI(_spi_config);

            DisplayRoutineAlphabet     drAlphabet     = new DisplayRoutineAlphabet();
            DisplayRoutineImages       drImages       = new DisplayRoutineImages();
            DisplayRoutineColorshifter drColorShifter = new DisplayRoutineColorshifter();
            DisplayRoutineColorfader   drColorfader   = new DisplayRoutineColorfader();
            DisplayRoutinePong         drPong         = new DisplayRoutinePong();
            DisplayRoutineMovingLines  drMovingLines  = new DisplayRoutineMovingLines();

            DisplayRoutineMovingDot       drMovingDot       = new DisplayRoutineMovingDot();
            DisplayRoutineSnake           drSnake           = new DisplayRoutineSnake();
            DisplayRoutineTextScrollYuki  drTextScrollYuki  = new DisplayRoutineTextScrollYuki();
            DisplayRoutineTextScrollAnton drTextScrollAnton = new DisplayRoutineTextScrollAnton();
            DisplayRoutineNumbers         drNumbers         = new DisplayRoutineNumbers();
            DisplayRoutineCurtains        drCurtains        = new DisplayRoutineCurtains();

            DisplayRoutine drCurrent = drAlphabet;

            int sleepInterval = 0;

            int selectorPosition0 = 1;
            int selectorPosition1 = 1;
            int selectorPosition2 = 1;

            int selectorPositionTmp0 = 0;
            int selectorPositionTmp1 = 0;
            int selectorPositionTmp2 = 0;

            //selectorPosition0 = selectors[0].Read();
            selectorPosition1 = selectors[1].Read();
            selectorPosition2 = selectors[2].Read();

            drCurrent.Start(selectorPosition1, selectorPosition2);

            while (true)
            {
                selectorPositionTmp0 = selectors[0].Read();
                if (selectorPosition0 != selectorPositionTmp0)
                {
                    selectorPosition0 = selectorPositionTmp0;

                    drCurrent.Stop();

                    if (selectorPosition0 == 1)
                    {
                        drCurrent = drAlphabet;
                    }
                    else if (selectorPosition0 == 2)
                    {
                        drCurrent = drColorShifter;
                    }
                    else if (selectorPosition0 == 3)
                    {
                        drCurrent = drColorfader;
                    }
                    else if (selectorPosition0 == 4)
                    {
                        drCurrent = drImages;
                    }
                    else if (selectorPosition0 == 5)
                    {
                        drCurrent = drMovingDot;
                    }
                    else if (selectorPosition0 == 6)
                    {
                        drCurrent = drMovingLines;
                    }
                    else if (selectorPosition0 == 7)
                    {
                        drCurrent = drNumbers;
                    }
                    else if (selectorPosition0 == 8)
                    {
                        drCurrent = drTextScrollYuki;
                    }
                    else if (selectorPosition0 == 9)
                    {
                        drCurrent = drTextScrollAnton;
                    }
                    else if (selectorPosition0 == 10)
                    {
                        drCurrent = drCurtains;
                    }
                    else if (selectorPosition0 == 11)
                    {
                        drCurrent = drPong;
                    }

                    drCurrent.Start(selectorPosition1, selectorPosition2);
                }

                //selectorPositionTmp1 = selectors[1].Read();
                //selectorPositionTmp2 = selectors[2].Read();
                if ((selectorPosition1 != selectorPositionTmp1) || (selectorPosition2 != selectorPositionTmp2))
                {
                    selectorPosition1 = selectorPositionTmp1;
                    selectorPosition2 = selectorPositionTmp2;
                    drCurrent.UpdateSettings(selectorPosition1, selectorPosition2);
                }

                sleepInterval = drCurrent.Display();

                Thread.Sleep(sleepInterval);

                drCurrent.Next();
            }
        }