GT.Timer timerPictureCaptured; // every second (1000ms) void ProgramStarted() { /******************************************************************************************* * Modules added in the Program.gadgeteer designer view are used by typing * their name followed by a period, e.g. button. or camera. * * Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.: * button.ButtonPressed +=<tab><tab> * * If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.: * GT.Timer timer = new GT.Timer(1000); // every second (1000ms) * timer.Tick +=<tab><tab> * timer.Start(); *******************************************************************************************/ // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging. Debug.Print("Program Started"); //Timer timer.Tick += timer_Tick; timer.Start(); timerPictureCaptured = new GT.Timer(9000); timerPictureCaptured.Tick += timerPictureCaptured_Tick; timerPictureCaptured.Start(); //Load windows mainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MainWindow)); resultWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.ResultWindow)); cameraWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.CameraWindow)); BtnLeer = (GHI.Glide.UI.Button)resultWindow.GetChildByName("BtnLeer"); BtnLeer.TapEvent += BtnLeer_TapEvent; GlideTouch.Initialize(); Glide.MainWindow = mainWindow; button.ButtonPressed += button_ButtonPressed; //Conexion a Internet this.ethernetJ11D.NetworkInterface.Open(); //this.ethernetJ11D.NetworkInterface.EnableStaticIP("200.9.176.102", "255.255.255.128", "200.9.176.2"); this.ethernetJ11D.NetworkInterface.EnableDhcp(); //this.ethernetJ11D.UseStaticIP("200.9.176.102", "255.255.255.128","200.9.176.2"); this.ethernetJ11D.UseThisNetworkInterface(); this.ethernetJ11D.NetworkDown += ethernetJ11D_NetworkDown; this.ethernetJ11D.NetworkUp += ethernetJ11D_NetworkUp; //Funciones de Camara camera.BitmapStreamed += camera_BitmapStreamed; camera.CameraConnected += camera_CameraConnected; camera.PictureCaptured += camera_PictureCaptured; systemState = State.Camera; //imagen del qr currentBitmap = new Bitmap(camera.CurrentPictureResolution.Width, camera.CurrentPictureResolution.Height); }
// This method is run when the mainboard is powered up or reset. void ProgramStarted() { /******************************************************************************************* Modules added in the Program.gadgeteer designer view are used by typing their name followed by a period, e.g. button. or camera. Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.: button.ButtonPressed +=<tab><tab> If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.: GT.Timer timer = new GT.Timer(1000); // every second (1000ms) timer.Tick +=<tab><tab> timer.Start(); *******************************************************************************************/ // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging. Debug.Print("Program Started"); //Carga las ventanas controlWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.controlWindow)); camaraWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.camaraWindow)); GlideTouch.Initialize(); //Inicializa los botones en la interface btn_start = (Button)controlWindow.GetChildByName("start"); btn_stop = (Button)controlWindow.GetChildByName("stop"); btn_start.TapEvent += btn_start_TapEvent; btn_stop.TapEvent += btn_stop_TapEvent; //Selecciona mainWindow como la ventana de inicio Glide.MainWindow = controlWindow; }
/**************** * FUNCTION * *************/ void first_step() { flagmdf = 0; /*button plus(input 4)*/ plus.ButtonPressed += Plus_ButtonPressed; plus.TurnLedOff(); /*button minus(input 5)*/ minus.ButtonPressed += Minus_ButtonPressed; minus.TurnLedOff(); Glide.FitToScreen = true; _mainwindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window)); GlideTouch.Initialize(); Glide.MainWindow = _mainwindow; /*create button to start*/ _startbtn = (GHI.Glide.UI.Button)_mainwindow.GetChildByName("startbtn"); /*press button event*/ _startbtn.PressEvent += Button_PressEvent; //_logo = (GHI.Glide.UI.Image)_mainwindow.GetChildByName("logo"); //_logo.Bitmap = new Bitmap(Resources.GetBytes(Resources.BinaryResources.logo), Bitmap.BitmapImageType.Jpeg); //_logo.Invalidate(); //Bitmap prova = new Bitmap(Resources.GetBytes(Resources.BinaryResources.logo), Bitmap.BitmapImageType.Gif); //displayTE35.SimpleGraphics.DisplayImage(prova, 30, 20); //displayTE35.BacklightEnabled = true; }
void initWindow() { btnEnter = (GHI.Glide.UI.Button)mainWindow.GetChildByName("btnEnter"); btnExit = (GHI.Glide.UI.Button)mainWindow.GetChildByName("btnExit"); btnOk = (GHI.Glide.UI.Button)mainWindow.GetChildByName("btnOk"); txtNetworkStatus = (GHI.Glide.UI.TextBlock)mainWindow.GetChildByName("txtNetworkStatus"); txtScreen = (GHI.Glide.UI.TextBlock)mainWindow.GetChildByName("txtText"); txtRectangle = (GHI.Glide.UI.TextBlock)mainWindow.GetChildByName("txtRectangle"); barProgress = (GHI.Glide.UI.ProgressBar)mainWindow.GetChildByName("barRfidTime"); imgPhoto = (GHI.Glide.UI.Image)mainWindow.GetChildByName("imgPhoto"); imgPhoto.Stretch = true; //fits the 320x240 streaming picture in 160x120 image component on window displayDefaultScreen(); btnEnter.TapEvent += btnEnter_TapEvent; btnExit.TapEvent += btnExit_TapEvent; btnOk.TapEvent += btnOk_TapEvent; }
// This method is run when the mainboard is powered up or reset. void ProgramStarted() { multicolorLED.BlinkOnce(GT.Color.Red); //7" Displays Display.Width = 800; Display.Height = 480; Display.OutputEnableIsFixed = false; Display.OutputEnablePolarity = true; Display.PixelPolarity = false; Display.PixelClockRateKHz = 30000; Display.HorizontalSyncPolarity = false; Display.HorizontalSyncPulseWidth = 48; Display.HorizontalBackPorch = 88; Display.HorizontalFrontPorch = 40; Display.VerticalSyncPolarity = false; Display.VerticalSyncPulseWidth = 3; Display.VerticalBackPorch = 32; Display.VerticalFrontPorch = 13; Display.Type = Display.DisplayType.Lcd; if (Display.Save()) // Reboot required? { PowerState.RebootDevice(false); } //set up touch screen CapacitiveTouchController.Initialize(GHI.Pins.FEZRaptor.Socket13.Pin3); //displayNHVN.Configure7InchDisplay(); window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MyForm)); //glide init GlideTouch.Initialize(); btnReset = (GHI.Glide.UI.Button)window.GetChildByName("btnReset"); dataGrid = (GHI.Glide.UI.DataGrid)window.GetChildByName("dataGrid"); Glide.MainWindow = window; Thread th1 = new Thread(new ThreadStart(Looping)); th1.Start(); }
void ProgramStarted() { Glide.FitToScreen = true; //load screen from xml mainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MainWindow)); winMasterMind = new MasterMind(); // reference for buttons from first screen btn1Player = (GHI.Glide.UI.Button)mainWindow.GetChildByName("btn1Player"); btn2Player = (GHI.Glide.UI.Button)mainWindow.GetChildByName("btn2Player"); btn1Player.TintColor = GHI.Glide.Colors.Red; //listeners from button clicked btn1Player.TapEvent += btn1Player_ButtonPressed; btn2Player.TapEvent += btn2Player_ButtonPressed; f = Resources.GetFont(Resources.FontResources.NinaB); fontHeight = f.Height; displayHeight = displayTE35.Height; // position for joystick double xPos = joystick.GetPosition().X; double yPos = joystick.GetPosition().Y; GT.Timer jt = new GT.Timer(275); jt.Tick += jt_Tick; joystick.JoystickPressed += joystick_JoystickPressed; jt.Start(); button.ButtonPressed += button_ButtonPressed; Glide.MainWindow = mainWindow; GlideTouch.Initialize(); }
/// <summary> /// Shows a MessageBox on screen. /// </summary> /// <param name="message">Message</param> /// <param name="title">Title</param> /// <param name="buttons">MessageBoxButtons constant.</param> /// <returns></returns> public ModalResult Show(string message, string title, ModalButtons buttons) { _window = Glide.MainWindow; _result = ModalResult.None; _resetEvent = new ManualResetEvent(false); while (_msgBox.NumChildren > 0) _msgBox.RemoveChildAt(0); Update(message, title); Button abortBtn, okBtn, cancelBtn, retryBtn, ignoreBtn, yesBtn, noBtn; int startX; int buttonY = _msgBox.Height - 32 - 10; switch (buttons) { case ModalButtons.Ok: okBtn = new Button("okBtn", 255, (_msgBox.Width - 50) / 2, buttonY, 50, 32); okBtn.Text = "Ok"; okBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); okBtn.TapEvent += new OnTap(okBtn_TapEvent); _msgBox.AddChild(okBtn); break; case ModalButtons.OkCancel: startX = (_msgBox.Width - (50 + 5 + 70)) / 2; okBtn = new Button("okBtn", 255, startX, buttonY, 50, 32); okBtn.Text = "Ok"; okBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); okBtn.TapEvent += new OnTap(okBtn_TapEvent); _msgBox.AddChild(okBtn); cancelBtn = new Button("cancelBtn", 255, okBtn.X + okBtn.Width + 5, buttonY, 70, 32); cancelBtn.Text = "Cancel"; cancelBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); cancelBtn.TapEvent += new OnTap(cancelBtn_TapEvent); _msgBox.AddChild(cancelBtn); break; case ModalButtons.RetryCancel: startX = (_msgBox.Width - (60 + 5 + 70)) / 2; retryBtn = new Button("retryBtn", 255, startX, buttonY, 60, 32); retryBtn.Text = "Retry"; retryBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); retryBtn.TapEvent += new OnTap(retryBtn_TapEvent); _msgBox.AddChild(retryBtn); cancelBtn = new Button("cancelBtn", 255, retryBtn.X + retryBtn.Width + 5, buttonY, 70, 32); cancelBtn.Text = "Cancel"; cancelBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); cancelBtn.TapEvent += new OnTap(cancelBtn_TapEvent); _msgBox.AddChild(cancelBtn); break; case ModalButtons.AbortRetryIgnore: startX = (_msgBox.Width - (60 + 5 + 60 + 5 + 70)) / 2; abortBtn = new Button("abortBtn", 255, startX, buttonY, 60, 32); abortBtn.Text = "Abort"; abortBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); abortBtn.TapEvent += new OnTap(abortBtn_TapEvent); _msgBox.AddChild(abortBtn); retryBtn = new Button("retryBtn", 255, abortBtn.X + abortBtn.Width + 5, buttonY, 60, 32); retryBtn.Text = "Retry"; retryBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); retryBtn.TapEvent += new OnTap(retryBtn_TapEvent); _msgBox.AddChild(retryBtn); ignoreBtn = new Button("ignoreBtn", 255, retryBtn.X + retryBtn.Width + 5, buttonY, 70, 32); ignoreBtn.Text = "Ignore"; ignoreBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); ignoreBtn.TapEvent += new OnTap(ignoreBtn_TapEvent); _msgBox.AddChild(ignoreBtn); break; case ModalButtons.YesNo: startX = (_msgBox.Width - (55 + 5 + 60)) / 2; yesBtn = new Button("yesBtn", 255, startX, buttonY, 55, 32); yesBtn.Text = "Yes"; yesBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); yesBtn.TapEvent += new OnTap(yesBtn_TapEvent); _msgBox.AddChild(yesBtn); noBtn = new Button("noBtn", 255, yesBtn.X + yesBtn.Width + 5, buttonY, 50, 32); noBtn.Text = "No"; noBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); noBtn.TapEvent += new OnTap(noBtn_TapEvent); _msgBox.AddChild(noBtn); break; case ModalButtons.YesNoCancel: startX = (_msgBox.Width - (55 + 5 + 50 + 5 + 70)) / 2; yesBtn = new Button("yesBtn", 255, startX, buttonY, 55, 32); yesBtn.Text = "Yes"; yesBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); yesBtn.TapEvent += new OnTap(yesBtn_TapEvent); _msgBox.AddChild(yesBtn); noBtn = new Button("noBtn", 255, yesBtn.X + yesBtn.Width + 5, buttonY, 50, 32); noBtn.Text = "No"; noBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); noBtn.TapEvent += new OnTap(noBtn_TapEvent); _msgBox.AddChild(noBtn); cancelBtn = new Button("cancelBtn", 255, noBtn.X + noBtn.Width + 5, buttonY, 70, 32); cancelBtn.Text = "Cancel"; cancelBtn.Font = FontManager.GetFont(FontManager.FontType.droid_reg11); cancelBtn.TapEvent += new OnTap(cancelBtn_TapEvent); _msgBox.AddChild(cancelBtn); break; } _forceClose = false; _touchThread = new Thread(TouchThread); _touchThread.Priority = ThreadPriority.AboveNormal; _touchThread.Start(); Open(); _resetEvent.WaitOne(); Close(); return _result; }
// This method is run when the mainboard is powered up or reset. void ProgramStarted() { /******************************************************************************************* Modules added in the Program.gadgeteer designer view are used by typing their name followed by a period, e.g. button. or camera. Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.: button.ButtonPressed +=<tab><tab> If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.: GT.Timer timer = new GT.Timer(1000); // every second (1000ms) timer.Tick +=<tab><tab> timer.Start(); *******************************************************************************************/ // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging. Debug.Print("Program Started"); ethernetJ11D.NetworkInterface.Open(); ethernetJ11D.NetworkInterface.EnableDhcp(); ethernetJ11D.UseThisNetworkInterface(); //Carga la ventana principal pantallaTiempo = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.pantallaTiempo)); pantallaTemperatura = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.pantallaTemperatura)); pantallaNoticias = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.pantallaNoticias)); GlideTouch.Initialize(); //Inicializa el boton en la interface btn_temperature = (Button)pantallaTiempo.GetChildByName("clima"); btn_news = (Button)pantallaTiempo.GetChildByName("noticias"); deportes = (Button)pantallaNoticias.GetChildByName("deportes"); cine = (Button)pantallaNoticias.GetChildByName("cine"); economia = (Button)pantallaNoticias.GetChildByName("economia"); atrastemp = (Button)pantallaTemperatura.GetChildByName("atras"); atrasnews = (Button)pantallaNoticias.GetChildByName("atrasnews"); //texto = (TextBlock)pantallaTiempo.GetChildByName("text_net_status"); textotemp = (TextBlock)pantallaTiempo.GetChildByName("hora"); fechatext = (TextBlock)pantallaTiempo.GetChildByName("fecha"); msm = (TextBlock)pantallaTemperatura.GetChildByName("msm"); temp = (TextBlock)pantallaTemperatura.GetChildByName("temp"); n1 = (TextBlock)pantallaNoticias.GetChildByName("n1"); n2 = (TextBlock)pantallaNoticias.GetChildByName("n2"); labeld = (TextBlock)pantallaNoticias.GetChildByName("labeld"); labelc = (TextBlock)pantallaNoticias.GetChildByName("labelc"); labele = (TextBlock)pantallaNoticias.GetChildByName("labele"); back = (Button)pantallaNoticias.GetChildByName("back"); next = (Button)pantallaNoticias.GetChildByName("next"); btn_temperature.TapEvent += btn_temperature_TapEvent; btn_news.TapEvent += btn_news_TapEvent; atrasnews.TapEvent += atrasnews_TapEvent; atrastemp.TapEvent += atrastemp_TapEvent; deportes.TapEvent += deportes_TapEvent; cine.TapEvent += cine_TapEvent; economia.TapEvent += economia_TapEvent; back.TapEvent += back_TapEvent; next.TapEvent += next_TapEvent; ethernetJ11D.NetworkDown += ethernetJ11D_NetworkDown; ethernetJ11D.NetworkUp += ethernetJ11D_NetworkUp; timer.Tick += timer_Tick; timer2.Tick += timer2_Tick; //Selecciona iniciarWindow como la ventana de inicio Glide.MainWindow = pantallaTiempo; timer2.Start(); }
/// <summary> /// Creates a new CalibrationWindow. /// </summary> /// <param name="autoStart">Whether or not to automatically begin calibration.</param> /// <param name="autoSave">Whether or not to save the calibration settings using Extended Weak Reference.</param> public CalibrationWindow(bool autoStart, bool autoSave) { _autoStart = autoStart; _autoSave = autoSave; Settings = new CalibrationSettings(); Name = "calibrationWindow"; Width = Glide.LCD.Width; Height = Glide.LCD.Height; BackColor = Colors.White; Graphics = new Graphics(Width, Height); int yPos = (Height / 2) - 50; _text1 = new TextBlock("text1", 255, (Glide.LCD.Width - 300) / 2, yPos, 300, 50); _text1.Font = FontManager.GetFont(FontManager.FontType.droid_reg12); _text1.TextAlign = HorizontalAlignment.Center; AddChild(_text1); yPos += 50 + 5; _startBtn = new Button("startBtn", 255, (Width - 200) / 2, yPos, 122, 32); _startBtn.Text = "Recalibrate"; _startBtn.TapEvent += new OnTap(_startBtn_TapEvent); _startBtn.Visible = false; AddChild(_startBtn); _exitBtn = new Button("exitBtn", 255, _startBtn.X + _startBtn.Width + 10, yPos, 68, 32); _exitBtn.Text = "Done"; _exitBtn.TapEvent += new OnTap(_exitBtn_TapEvent); _exitBtn.Visible = false; AddChild(_exitBtn); _canvas = new Canvas(); AddChild(_canvas); if (_autoStart) { _text1.FontColor = Colors.Black; _text1.Text = "Touch the crosshair location."; Start(); } else { if (GlideTouch.Calibrated) { _text1.FontColor = Colors.Red; _text1.Text = "Touch is already calibrated."; _exitBtn.Visible = true; _startBtn.Visible = true; } else { _text1.FontColor = Colors.Black; _text1.Text = "Touch the screen to start."; TapEvent += new OnTap(CalibrationWindow_TapEvent); } } }
public void Selection() { Glide.MainWindow = fenetreSelection; //Affiche la fenetre de selection sur l'écran LCD BoutonBleu = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonBleu"); //Créer les différents boutons BoutonJaune = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonJaune"); BoutonDispo1 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonHomologation"); BoutonDispo2 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonDispo2"); BoutonDispo3 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonDispo3"); BoutonDispo4 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonDispo4"); BoutonDispo5 = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonDispo5"); BoutonValider = (GHI.Glide.UI.Button)fenetreSelection.GetChildByName("BoutonValider"); TexteCouleur = (TextBlock)fenetreSelection.GetChildByName("TexteCouleur"); //Bloc de texte pour la selection (affiche la couleur et la disposition choisie) TexteDispo = (TextBlock)fenetreSelection.GetChildByName("TexteDispo"); // BoutonBleu.TapEvent += new OnTap(sender => { m_equipe = Couleur.Bleu; TexteCouleur.Text = "Equipe bleue"; TexteCouleur.BackColor = (Color)0xE8D630; fenetreSelection.FillRect(TexteCouleur.Rect); TexteCouleur.Invalidate(); }); BoutonJaune.TapEvent += new OnTap(sender => { m_equipe = Couleur.Jaune; TexteCouleur.Text = "Equipe jaune"; TexteCouleur.BackColor = (Color)0x1E7FCB; fenetreSelection.FillRect(TexteCouleur.Rect); TexteCouleur.Invalidate(); }); BoutonDispo1.TapEvent += new OnTap(sender => { m_disposition = 1; TexteDispo.Text = "Strategie 1"; fenetreSelection.FillRect(TexteDispo.Rect); TexteDispo.Invalidate(); }); BoutonDispo2.TapEvent += new OnTap(sender => { m_disposition = 2; TexteDispo.Text = "Strategie 2"; fenetreSelection.FillRect(TexteDispo.Rect); TexteDispo.Invalidate(); }); BoutonDispo3.TapEvent += new OnTap(sender => { m_disposition = 3; TexteDispo.Text = "Dispo. no. 3"; fenetreSelection.FillRect(TexteDispo.Rect); TexteDispo.Invalidate(); }); BoutonDispo4.TapEvent += new OnTap(sender => { m_disposition = 4; TexteDispo.Text = "Dispo. no. 4"; fenetreSelection.FillRect(TexteDispo.Rect); TexteDispo.Invalidate(); }); BoutonDispo5.TapEvent += new OnTap(sender => { m_disposition = 5; TexteDispo.Text = "Dispo. no. 5"; fenetreSelection.FillRect(TexteDispo.Rect); TexteDispo.Invalidate(); }); while (m_equipe == Couleur.Null || m_disposition == 0) //Execution de la boucle tant que l'equipe et la disposition du terrain ne sont pas validés { while (validation == false) { BoutonValider.TapEvent += new OnTap(sender => { validation = true; }); } } Fermer(); //ferme la fenetre de selection Glide.MainWindow = fenetreAffichage; //Affiche la fenetre d'affichage sur l'écran LCD TexteAffichage = (TextBlock)fenetreAffichage.GetChildByName("TexteAffichage"); //Bloc de texte pour l'affichage des instructions }
void ProgramStarted() { window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Form1)); GlideTouch.Initialize(); GHI.Glide.UI.Button btn = (GHI.Glide.UI.Button)window.GetChildByName("btn"); btn.TapEvent += OnTap; txtGas = (TextBlock)window.GetChildByName("txtGas"); txtHumid = (TextBlock)window.GetChildByName("txtHumid"); txtLight = (TextBlock)window.GetChildByName("txtLight"); txtTemp = (TextBlock)window.GetChildByName("txtTemp"); txtStatus = (TextBlock)window.GetChildByName("txtStatus"); txtMessage = (TextBlock)window.GetChildByName("txtMessage"); txtGas.TextAlign = HorizontalAlignment.Left; txtHumid.TextAlign = HorizontalAlignment.Left; txtLight.TextAlign = HorizontalAlignment.Left; txtTemp.TextAlign = HorizontalAlignment.Left; txtStatus.TextAlign = HorizontalAlignment.Left; txtMessage.TextAlign = HorizontalAlignment.Left; Glide.MainWindow = window; UART = new SimpleSerial(GHI.Pins.FEZRaptor.Socket1.SerialPortName, 57600); UART.ReadTimeout = 0; UART.DataReceived += UART_DataReceived; Debug.Print("57600"); Debug.Print("RN2483 Test"); PrintToLcd("RN2483 Test"); OutputPort reset = new OutputPort(GHI.Pins.FEZRaptor.Socket1.Pin6, false); OutputPort reset2 = new OutputPort(GHI.Pins.FEZRaptor.Socket1.Pin3, false); reset.Write(true); reset2.Write(true); Thread.Sleep(100); reset.Write(false); reset2.Write(false); Thread.Sleep(100); reset.Write(true); reset2.Write(true); Thread.Sleep(100); waitForResponse(); sendCmd("sys factoryRESET"); sendCmd("sys get hweui"); sendCmd("mac get deveui"); // For TTN sendCmd("mac set devaddr AAABBBEE"); // Set own address Thread.Sleep(1000); sendCmd("mac set appskey 2B7E151628AED2A6ABF7158809CF4F3D"); Thread.Sleep(1000); sendCmd("mac set nwkskey 2B7E151628AED2A6ABF7158809CF4F3D"); Thread.Sleep(1000); sendCmd("mac set adr off"); Thread.Sleep(1000); sendCmd("mac set rx2 3 868400000");//869525000 Thread.Sleep(1000); sendCmd("mac join abp"); sendCmd("mac get status"); sendCmd("mac get devaddr"); Thread.Sleep(1000); Thread th1 = new Thread(new ThreadStart(Loop)); th1.Start(); }
// Initializes main window buttons static void initMainWindow(Window window) { //Image imgLogo = (Image)window.GetChildByName("imgLogo"); //imgLogo.Bitmap = Resources.GetBitmap(Resources.BitmapResources.Stinkmeaner_Thumb); // Create a Canvas GHI.Glide.UI.Canvas canvas = new GHI.Glide.UI.Canvas(); window.AddChild(canvas); // Draw a separator line. //canvas.DrawLine(GHI.Glide.Colors.White, 1, 30, 50, window.Width - 30, 50); // Draw a fieldset around our "Login" text block. _txtTitle = (TextBlock)window.GetChildByName("txtTitle"); _txtTitle.FontColor = GHI.Glide.Colors.White; canvas.DrawFieldset(_txtTitle, 30, 100, 220, GHI.Glide.Colors.White, 1); _pBarConnected = (ProgressBar)_mainWindow.GetChildByName("pBarConnected"); _pBarConnected.Value = 0; _txtCntrlBattery = (TextBlock)_mainWindow.GetChildByName("txtCntrlBattery"); _txtCntrlBattery.Text = "Battery: "; _txtCntrlBatteryOut = (TextBlock)_mainWindow.GetChildByName("txtCntrlBatteryOut"); _txtCntrlBatteryOut.Text = "---%"; _txtRoverBattery = (TextBlock)_mainWindow.GetChildByName("txtRoverBattery"); _txtRoverBattery.Text = "Rover: "; _txtRoverBatteryOut = (TextBlock)_mainWindow.GetChildByName("txtRoverBatteryOut"); _txtRoverBatteryOut.Text = "---%"; _txtRoverRange = (TextBlock)_mainWindow.GetChildByName("txtRoverRange"); _txtRoverRange.Text = "Range: "; _txtRoverRangeOut = (TextBlock)_mainWindow.GetChildByName("txtRoverRangeOut"); _txtRoverRangeOut.Text = "---in."; _txtRoverHeading = (TextBlock)_mainWindow.GetChildByName("txtRoverHeading"); _txtRoverHeading.Text = "Head: "; _txtRoverHeadingOut = (TextBlock)_mainWindow.GetChildByName("txtRoverHeadingOut"); _txtRoverHeadingOut.Text = "---deg"; _txtRoverTemp = (TextBlock)_mainWindow.GetChildByName("txtRoverTemp"); _txtRoverTemp.Text = "Temp: "; _txtRoverTempOut = (TextBlock)_mainWindow.GetChildByName("txtRoverTempOut"); _txtRoverTempOut.Text = "---F"; _txtRoverPress = (TextBlock)_mainWindow.GetChildByName("txtRoverPress"); _txtRoverPress.Text = "Press: "; _txtRoverPressOut = (TextBlock)_mainWindow.GetChildByName("txtRoverPressOut"); _txtRoverPressOut.Text = "---psi"; _txtRoverLat = (TextBlock)_mainWindow.GetChildByName("txtRoverLat"); _txtRoverLat.Text = "Lat: "; _txtRoverLatOut = (TextBlock)_mainWindow.GetChildByName("txtRoverLatOut"); _txtRoverLatOut.Text = "---"; _txtRoverLon = (TextBlock)_mainWindow.GetChildByName("txtRoverLon"); _txtRoverLon.Text = "Lon: "; _txtRoverLonOut = (TextBlock)_mainWindow.GetChildByName("txtRoverLonOut"); _txtRoverLonOut.Text = "---"; _txtWpDist = (TextBlock)_mainWindow.GetChildByName("txtWpDist"); _txtWpDist.Text = "WpDist: "; _txtWpDistOut = (TextBlock)_mainWindow.GetChildByName("txtWpDistOut"); _txtWpDistOut.Text = "-m"; _txtTargetHead = (TextBlock)_mainWindow.GetChildByName("txtTargetHead"); _txtTargetHead.Text = "TarHd: "; _txtTargetHeadOut = (TextBlock)_mainWindow.GetChildByName("txtTargetHeadOut"); _txtTargetHeadOut.Text = "-deg"; _txtWpSpeedDir = (TextBlock)_mainWindow.GetChildByName("txtWpSpeedDir"); _txtWpSpeedDir.Text = "Spd_Dir:"; _txtWpSpeedDirOut = (TextBlock)_mainWindow.GetChildByName("txtWpSpeedDirOut"); _txtWpSpeedDirOut.Text = "0_0"; _txtTargetWpNum = (TextBlock)_mainWindow.GetChildByName("txtTargetWpNum"); _txtTargetWpNum.Text = "TarWP: "; _txtTargetWpNumOut = (TextBlock)_mainWindow.GetChildByName("txtTargetWpNumOut"); _txtTargetWpNumOut.Text = "0"; _txtRovMode = (TextBlock)_mainWindow.GetChildByName("txtRovMode"); _txtRovMode.Text = "Mode: "; _txtRovModeOut = (TextBlock)_mainWindow.GetChildByName("txtRovModeOut"); _txtRovModeOut.Text = "-"; _btnSettings = (GHI.Glide.UI.Button)_mainWindow.GetChildByName("btnSettings"); _btnSettings.TapEvent += new OnTap(btnSettings_TapEvent); _btnOutputs = (GHI.Glide.UI.Button)_mainWindow.GetChildByName("btnOutputs"); _btnOutputs.TapEvent += new OnTap(btnOutputs_TapEvent); _btnMode = (GHI.Glide.UI.Button)_mainWindow.GetChildByName("btnMode"); _btnMode.TapEvent += new OnTap(btnMode_TapEvent); _btnInputs = (GHI.Glide.UI.Button)_mainWindow.GetChildByName("btnInputs"); _btnInputs.TapEvent += new OnTap(btnInputs_TapEvent); }
// This method is run when the mainboard is powered up or reset. void ProgramStarted() { //set display this.videoOut.SetDisplayConfiguration(VideoOut.Resolution.Vga800x600); //set glide window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Form1)); txtTime = (GHI.Glide.UI.TextBlock)window.GetChildByName("txtTime"); GvData = (GHI.Glide.UI.DataGrid)window.GetChildByName("GvData"); BtnReset = (GHI.Glide.UI.Button)window.GetChildByName("BtnReset"); txtMessage = (GHI.Glide.UI.TextBlock)window.GetChildByName("TxtMessage"); Glide.MainWindow = window; //setup grid //create grid column GvData.AddColumn(new DataGridColumn("Time", 200)); GvData.AddColumn(new DataGridColumn("Temp", 200)); GvData.AddColumn(new DataGridColumn("Humid", 200)); GvData.AddColumn(new DataGridColumn("Light", 200)); GvData.AddColumn(new DataGridColumn("Gas", 200)); // Create a database in memory, // file system is possible however! myDatabase = new GHI.SQLite.Database(); myDatabase.ExecuteNonQuery("CREATE Table Sensor" + " (Time TEXT, Temp DOUBLE,Humid DOUBLE,Light DOUBLE,Gas DOUBLE)"); //reset database n display BtnReset.TapEvent += (object sender) => { Counter = 0; myDatabase.ExecuteNonQuery("DELETE FROM Sensor"); GvData.Clear(); GvData.Invalidate(); }; //reset lora _restPort.Write(false); Thread.Sleep(1000); _restPort.Write(true); Thread.Sleep(1000); _loraSerial = new SimpleSerial(GHI.Pins.FEZSpiderII.Socket11.SerialPortName, 57600); _loraSerial.Open(); _loraSerial.DataReceived += _loraSerial_DataReceived; //get version _loraSerial.WriteLine("sys get ver"); Thread.Sleep(1000); //pause join _loraSerial.WriteLine("mac pause"); Thread.Sleep(1500); //antena power _loraSerial.WriteLine("radio set pwr 14"); Thread.Sleep(1500); //set device to receive _loraSerial.WriteLine("radio rx 0"); //set module to RX txtMessage.Text = "LORA-RN2483 setup has been completed..."; txtMessage.Invalidate(); window.Invalidate(); //myDatabase.Dispose(); }
// This method is run when the mainboard is powered up or reset. void ProgramStarted() { /******************************************************************************************* Modules added in the Program.gadgeteer designer view are used by typing their name followed by a period, e.g. button. or camera. Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.: button.ButtonPressed +=<tab><tab> If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.: GT.Timer timer = new GT.Timer(1000); // every second (1000ms) timer.Tick +=<tab><tab> timer.Start(); *******************************************************************************************/ // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging. Debug.Print("Program Started"); ethernetJ11D.NetworkInterface.Open(); ethernetJ11D.NetworkInterface.EnableDhcp(); ethernetJ11D.UseThisNetworkInterface(); //Carga la ventana principal iniciarWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.inicioWindow)); pantallaTemperatura = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.pantallaTemperatura)); GlideTouch.Initialize(); //Inicializa el boton en la interface btn_inicio = (Button)iniciarWindow.GetChildByName("button_iniciar"); atras = (Button)pantallaTemperatura.GetChildByName("atras"); barra = (ProgressBar)pantallaTemperatura.GetChildByName("instance23061"); texto = (TextBlock)iniciarWindow.GetChildByName("text_net_status"); textotemp = (TextBlock)pantallaTemperatura.GetChildByName("valor"); btn_inicio.TapEvent += btn_inicio_TapEvent; atras.TapEvent += atras_TapEvent; ethernetJ11D.NetworkDown += ethernetJ11D_NetworkDown; ethernetJ11D.NetworkUp += ethernetJ11D_NetworkUp; timer.Tick += timer_Tick; //Selecciona iniciarWindow como la ventana de inicio Glide.MainWindow = iniciarWindow; }
void ProgramStarted() { /******************************************************************************************* Modules added in the Program.gadgeteer designer view are used by typing their name followed by a period, e.g. button. or camera. Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.: button.ButtonPressed +=<tab><tab> If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.: GT.Timer timer = new GT.Timer(1000); // every second (1000ms) timer.Tick +=<tab><tab> timer.Start(); *******************************************************************************************/ // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging. Debug.Print("Program Started"); //Timer timer.Tick += timer_Tick; timer.Start(); timerPictureCaptured = new GT.Timer(9000); timerPictureCaptured.Tick += timerPictureCaptured_Tick; timerPictureCaptured.Start(); //Load windows mainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MainWindow)); resultWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.ResultWindow)); cameraWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.CameraWindow)); BtnLeer = (GHI.Glide.UI.Button)resultWindow.GetChildByName("BtnLeer"); BtnLeer.TapEvent += BtnLeer_TapEvent; GlideTouch.Initialize(); Glide.MainWindow = mainWindow; button.ButtonPressed += button_ButtonPressed; //Conexion a Internet this.ethernetJ11D.NetworkInterface.Open(); //this.ethernetJ11D.NetworkInterface.EnableStaticIP("200.9.176.102", "255.255.255.128", "200.9.176.2"); this.ethernetJ11D.NetworkInterface.EnableDhcp(); //this.ethernetJ11D.UseStaticIP("200.9.176.102", "255.255.255.128","200.9.176.2"); this.ethernetJ11D.UseThisNetworkInterface(); this.ethernetJ11D.NetworkDown += ethernetJ11D_NetworkDown; this.ethernetJ11D.NetworkUp += ethernetJ11D_NetworkUp; //Funciones de Camara camera.BitmapStreamed += camera_BitmapStreamed; camera.CameraConnected += camera_CameraConnected; camera.PictureCaptured += camera_PictureCaptured; systemState = State.Camera; //imagen del qr currentBitmap = new Bitmap(camera.CurrentPictureResolution.Width, camera.CurrentPictureResolution.Height); }
/*ordBtn TapEvent*/ void _ordBtn_PressEvent(object sender) { var random = new Random(System.DateTime.Now.Millisecond); uint randomNumber = (uint)random.Next(); string id_ordine = randomNumber.ToString(); string tot = price.ToString(); Hashtable order = new Hashtable(); order.Add("id", id_ordine); order.Add("price", tot); // Preparing order array list ArrayList foods = new ArrayList(); foreach (Product p in payment) { // Preparing food array list Hashtable new_food = new Hashtable(); new_food.Add("name", p.nome); new_food.Add("price", p.prezzo); Hashtable food = new Hashtable(); food.Add("food", new_food); food.Add("quantity", p.quantita); foods.Add(food); } order.Add("foods", foods); string order_as_json = Json.NETMF.JsonSerializer.SerializeObject(order); // TODO: MANDARE order_as_json al Desktop tramite Socket Debug.Print(order_as_json); /*load ordina*/ _ordina = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Ordina)); Glide.MainWindow = _ordina; _gridOrdine = (GHI.Glide.UI.DataGrid)_menu.GetChildByName("gridOrdine"); _annullaBtn = (GHI.Glide.UI.Button)_ordina.GetChildByName("annullaBtn"); _payBtn = (GHI.Glide.UI.Button)_ordina.GetChildByName("payBtn"); _mdfBtn = (GHI.Glide.UI.Button)_ordina.GetChildByName("mdfBtn"); _pfinal = (GHI.Glide.UI.TextBlock)_ordina.GetChildByName("pFinal"); _annullaBtn.TapEvent += _annullaBtn_TapEvent; _mdfBtn.TapEvent += _mdfBtn_TapEvent; _payBtn.TapEvent += _payBtn_TapEvent; /*Setup the dataGrid reference*/ _gridOrdine = (DataGrid)_ordina.GetChildByName("gridOrdine"); /*Create our four columns*/ _gridOrdine.AddColumn(new DataGridColumn("PIZZA", 125)); _gridOrdine.AddColumn(new DataGridColumn("PREZZO", 80)); _gridOrdine.AddColumn(new DataGridColumn("QNT", 50)); foreach (Product p in payment) { _gridOrdine.AddItem(new DataGridItem(new object[3] { p.nome, p.prezzo, p.quantita })); } _pfinal.Text = price.ToString(); _ordina.Invalidate(); _gridOrdine.Invalidate(); }
void initMenu() { Debug.Print("Init Menu!"); /*inizio socket*/ SocketClient.StartClient(); /*fine socket*/ /*load menu*/ _menu = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Menu)); Glide.MainWindow = _menu; _dataGrid = (GHI.Glide.UI.DataGrid)_menu.GetChildByName("dataGrid"); _pCounter = (GHI.Glide.UI.TextBlock)_menu.GetChildByName("pCounter"); _qntCounter = (GHI.Glide.UI.TextBlock)_menu.GetChildByName("qntCounter"); _errMsg = (GHI.Glide.UI.TextBlock)_menu.GetChildByName("errMsg"); _ordBtn = (GHI.Glide.UI.Button)_menu.GetChildByName("ordBtn"); if (flagmdf == 0) { _ordBtn.Enabled = false; } else { _ordBtn.Enabled = true; } _menu.Invalidate(); _ordBtn.PressEvent += _ordBtn_PressEvent; _deleteBtn = (GHI.Glide.UI.Button)_menu.GetChildByName("deleteBtn"); if (flagmdf == 0) { _deleteBtn.Enabled = false; } else { _deleteBtn.Enabled = true; } _menu.Invalidate(); _deleteBtn.PressEvent += deleteBtn_PressEvent; //_ingBtn = (GHI.Glide.UI.Button)_menu.GetChildByName("ingBtn"); //_ingBtn.Visible = false; //_menu.Invalidate(); //_ingBtn.PressEvent += ingBtn_PressEvent; /*Setup the dataGrid reference*/ _dataGrid = (DataGrid)_menu.GetChildByName("dataGrid"); // Listen for tap cell events. _dataGrid.TapCellEvent += new OnTapCell(dataGrid_TapCellEvent); /*Create our four columns*/ _dataGrid.AddColumn(new DataGridColumn("ID", 0)); _dataGrid.AddColumn(new DataGridColumn("PIZZA", 125)); _dataGrid.AddColumn(new DataGridColumn("PREZZO", 80)); _dataGrid.AddColumn(new DataGridColumn("QNT", 50)); /*Populate the data grid with random data*/ Populate(); /*Add the data grid to the window before rendering it*/ _menu.AddChild(_dataGrid); _dataGrid.Render(); /*Create a timer & run method timer_trick when thr timer ticks (for joystick)*/ GT.Timer timer = new GT.Timer(200); timer.Tick += Timer_Tick; timer.Start(); }
public static void refreshButton(Window myWindow, GHI.Glide.UI.Button myBtn) { myWindow.FillRect(myBtn.Rect); myBtn.Invalidate(); }
/// <summary> /// Parses the Button XML into a UI component. /// </summary> /// <param name="reader">XML reader object.</param> /// <returns>Button object.</returns> private static Button LoadButton(XmlReader reader) { string name = reader.GetAttribute("Name"); int x = Convert.ToInt32(reader.GetAttribute("X")); int y = Convert.ToInt32(reader.GetAttribute("Y")); int width = Convert.ToInt32(reader.GetAttribute("Width")); int height = Convert.ToInt32(reader.GetAttribute("Height")); ushort alpha = Convert.ToUInt16(reader.GetAttribute("Alpha")); string text = reader.GetAttribute("Text"); int i = text.IndexOf("\\n"); while (i > -1) { text = text.Substring(0, i) + "\n" + text.Substring(i + 2, text.Length - (i + 2)); i = text.IndexOf("\\n"); } Font font = GlideUtils.Convert.ToFont(reader.GetAttribute("Font")); Color fontColor = GlideUtils.Convert.ToColor(reader.GetAttribute("FontColor")); Color disabledFontColor = GlideUtils.Convert.ToColor(reader.GetAttribute("DisabledFontColor")); Color tintColor = GlideUtils.Convert.ToColor(reader.GetAttribute("TintColor")); ushort tintAmount = Convert.ToUInt16(reader.GetAttribute("TintAmount")); Button button = new Button(name, alpha, x, y, width, height); button.Text = text; button.Font = font; button.FontColor = fontColor; button.DisabledFontColor = disabledFontColor; button.TintColor = tintColor; button.TintAmount = tintAmount; return button; }