Exemple #1
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            /*******************************************************************************************
            BLITZKRIEG 0.1 - PROGRAM CONTOH PEMANFAATAN GADGETEER SEBAGAI DEVICE MULTI-FUNGSI
            *******************************************************************************************/
            Debug.Print("Program Started");

            //init pins
            boardPins = new Hashtable();
            for (int i = 1; i <= 10; i++)
            {
                var pin = new BoardPins();
                pin.PinType = BoardPins.PinTypes.None;
                pin.ThisPin = null;
                boardPins.Add(i, pin);
            }
            SetupBackgroundService();
            Screens = new Hashtable();
            //populate all form
            var F1 = new SplashForm(ref MainWindow);
            F1.FormRequestEvent += General_FormRequestEvent;
            Screens.Add(Screen.ScreenTypes.Splash, F1);

            var F2 = new MainMenuForm(ref MainWindow);
            F2.FormRequestEvent += General_FormRequestEvent;
            Screens.Add(Screen.ScreenTypes.MainMenu, F2);

            var F3 = new MyRoomForm(ref MainWindow, ref tempHumidSI70, ref lightSense);
            F3.FormRequestEvent += General_FormRequestEvent;
            Screens.Add(Screen.ScreenTypes.MyRoom, F3);

            var F4 = new InboxForm(ref MainWindow, ref cellularRadio, ref sdCard, ref displayTE35);
            F4.FormRequestEvent += General_FormRequestEvent;
            Screens.Add(Screen.ScreenTypes.Inbox, F4);

            var F5 = new GalleryForm(ref MainWindow, ref serialCameraL1, ref sdCard, ref wifiRS21);
            F5.FormRequestEvent += General_FormRequestEvent;
            Screens.Add(Screen.ScreenTypes.Gallery, F5);

            var F6 = new GameForm(ref MainWindow, ref displayTE35);
            F6.FormRequestEvent += General_FormRequestEvent;
            Screens.Add(Screen.ScreenTypes.Game, F6);

            var F7 = new RegisterForm(ref MainWindow, ref wifiRS21, ref sdCard);
            F7.FormRequestEvent += General_FormRequestEvent;
            Screens.Add(Screen.ScreenTypes.Register, F7);

            Glide.FitToScreen = true;
            GlideTouch.Initialize();

            //load splash
            LoadForm(Screen.ScreenTypes.Splash);
        }
Exemple #2
0
 object GetBoardPin(Gadgeteer.Socket.Pin pin, BoardPins.PinTypes tipe)
 {
     var IsNew = false;
     var CurrPin = boardPins[(int)pin] as BoardPins;
     if (CurrPin.PinType != tipe)
     {
         switch (CurrPin.PinType)
         {
             case BoardPins.PinTypes.AnalogRead:
                 var AR = CurrPin.ThisPin as Gadgeteer.SocketInterfaces.AnalogInput;
                 AR.Dispose();
                 break;
             case BoardPins.PinTypes.AnalogWrite:
                 var AW = CurrPin.ThisPin as Gadgeteer.SocketInterfaces.AnalogOutput;
                 AW.Dispose();
                 break;
             case BoardPins.PinTypes.DigitalRead:
                 var DR = CurrPin.ThisPin as Gadgeteer.SocketInterfaces.DigitalInput;
                 DR.Dispose();
                 break;
             case BoardPins.PinTypes.DigitalWrite:
                 var DW = CurrPin.ThisPin as Gadgeteer.SocketInterfaces.DigitalOutput;
                 DW.Dispose();
                 break;
         }
         IsNew = true;
         CurrPin.PinType = BoardPins.PinTypes.None;
     }
     CurrPin.PinType = tipe;
     switch (tipe)
     {
         case BoardPins.PinTypes.AnalogRead:
             if (!IsNew)
             {
                 var AR = CurrPin.ThisPin as Gadgeteer.SocketInterfaces.AnalogInput;
                 return AR;
             }
             else
             {
                 var AR = breadBoardX1.CreateAnalogInput((Gadgeteer.Socket.Pin)pin);
                 CurrPin.ThisPin = AR;
                 return AR;
             }
         //break;
         case BoardPins.PinTypes.AnalogWrite:
             if (!IsNew)
             {
                 var AW = CurrPin.ThisPin as Gadgeteer.SocketInterfaces.AnalogOutput;
                 return AW;
             }
             else
             {
                 var AW = breadBoardX1.CreateAnalogOutput((Gadgeteer.Socket.Pin)pin);
                 CurrPin.ThisPin = AW;
                 return AW;
             }
         //break;
         case BoardPins.PinTypes.DigitalRead:
             if (!IsNew)
             {
                 var DR = CurrPin.ThisPin as Gadgeteer.SocketInterfaces.DigitalInput;
                 return DR;
             }
             else
             {
                 var DR = breadBoardX1.CreateDigitalInput((Gadgeteer.Socket.Pin)pin, GT.SocketInterfaces.GlitchFilterMode.Off, GT.SocketInterfaces.ResistorMode.Disabled);
                 CurrPin.ThisPin = DR;
                 return DR;
             }
         //break;
         case BoardPins.PinTypes.DigitalWrite:
             if (!IsNew)
             {
                 var DW = CurrPin.ThisPin as Gadgeteer.SocketInterfaces.DigitalOutput;
                 return DW;
             }
             else
             {
                 var DW = breadBoardX1.CreateDigitalOutput((Gadgeteer.Socket.Pin)pin, false);
                 CurrPin.ThisPin = DW;
                 return DW;
             }
             //break;
     }
     return null;
 }