/*apre pagina per il pagamento*/ private void _payBtn_TapEvent(object sender) { /*load pagamento*/ _pagamento = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Pagamento)); Glide.MainWindow = _pagamento; _paypal = (GHI.Glide.UI.TextBlock)_ordina.GetChildByName("paypal"); _pagamento.Invalidate(); }
void setup() { //rnd = new Random(); Display.Width = 800; Display.Height = 480; Display.HorizontalSyncPulseWidth = 1; Display.HorizontalBackPorch = 88; Display.HorizontalFrontPorch = 40; Display.VerticalSyncPulseWidth = 3; Display.VerticalBackPorch = 32; Display.VerticalFrontPorch = 13; Display.PixelClockRateKHz = 25000; Display.OutputEnableIsFixed = true; Display.OutputEnablePolarity = true; Display.HorizontalSyncPolarity = false; Display.VerticalSyncPolarity = false; Display.PixelPolarity = true; Display.Type = Display.DisplayType.Lcd; if (Display.Save()) // Reboot required? { PowerState.RebootDevice(false); } //init touch i2cDevice = new I2CDevice(new I2CDevice.Configuration(0x38, 400)); CapDriver = new CapTouchDriver(i2cDevice); CapDriver.SetBacklightTime(0); CapDriver.ResetBacklight(); //CapacitiveTouchController.Initialize(GHI.Pins.G120.P2_21); //CapacitiveTouchController.Initialize(GHI.Pins.FEZCobraII.Socket4.Pin3); GlideTouch.Initialize(); MainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Form1)); //img = (GHI.Glide.UI.Image)MainWindow.GetChildByName("img"); //btn = (GHI.Glide.UI.Button)MainWindow.GetChildByName("BtnChange"); txt = (GHI.Glide.UI.TextBlock)MainWindow.GetChildByName("txtStatus"); //GT.Picture pic = new GT.Picture(Resources.GetBytes(Resources.BinaryResources.empty), GT.Picture.PictureEncoding.JPEG); //img.Bitmap = pic.MakeBitmap(); GvData = (DataGrid)MainWindow.GetChildByName("GvData"); GvData.AddColumn(new DataGridColumn("Time", 100)); GvData.AddColumn(new DataGridColumn("Temp 1", 100)); GvData.AddColumn(new DataGridColumn("Temp 2", 100)); GvData.AddColumn(new DataGridColumn("Water Dist", 100)); GvData.AddColumn(new DataGridColumn("Tds 1", 100)); GvData.AddColumn(new DataGridColumn("Tds 2", 100)); Random rnd = new Random(); counter = 0; Glide.MainWindow = MainWindow; //btn.ReleaseEvent += btn_ReleaseEvent; Glide.FitToScreen = true; //Thread th1 = new Thread(new ThreadStart(LoopButton)); //th1.Start(); //Mainboard.LDR0.OnInterrupt += LDR0_OnInterrupt; //Mainboard.LDR1.OnInterrupt += LDR1_OnInterrupt; //logs = new LogHelper(usbHost); xBeeAdapter.Configure(9600, SerialParity.None, SerialStopBits.One, 8, HardwareFlowControl.NotRequired); //StartLora(); xBeeAdapter.Port.LineReceived += Port_LineReceived; GT.Timer timer = new GT.Timer(5000); // every second (1000ms) timer.Tick += timer_Tick; timer.Start(); // Timeout 10 seconds int timeout = 1000 * 10; // Enable Watchdog GHI.Processor.Watchdog.Enable(timeout); // Start a time counter reset thread WDTCounterReset = new Thread(WDTCounterResetLoop); WDTCounterReset.Start(); // Normally, you can read this flag ***ONLY ONCE*** on power up if (GHI.Processor.Watchdog.LastResetCause == GHI.Processor.Watchdog.ResetCause.Watchdog) { //logs.WriteLogs("reset by watchdog"); Debug.Print("Watchdog did Reset"); } else { //logs.WriteLogs("system reboot / start"); Debug.Print("Reset switch or system power"); } }
// 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); } } }
// 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"); //Carga las ventanas controlWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.controlWindow)); camaraWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.camaraWindow)); GlideTouch.Initialize(); sensor = new SensorProximidad(extender); //Inicializa los botones en la interface camera.BitmapStreamed += camera_BitmapStreamed; text = (TextBlock)controlWindow.GetChildByName("status"); btn_start = (Button)controlWindow.GetChildByName("start"); btn_stop = (Button)controlWindow.GetChildByName("stop"); sensor.ObjectOn += sensor_ObjectOn; sensor.ObjectOff += sensor_ObjectOff; btn_start.TapEvent += btn_start_TapEvent; btn_stop.TapEvent += btn_stop_TapEvent; //Selecciona mainWindow como la ventana de inicio Glide.MainWindow = controlWindow; }
// 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; }
/*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(); }
void request_ResponseReceived(HttpRequest sender, HttpResponse response) { var x = response.Text; Debug.Print(x); temp = (TextBlock)Glide.MainWindow.GetChildByName("texto_temperatura"); temp.Text = x; sliderBar = (Slider)Glide.MainWindow.GetChildByName("slider"); sliderBar.Value = Convert.ToDouble(x); Glide.MainWindow = temperatura; }
/// <summary> /// Parses the TextBlock XML into a UI component. /// </summary> /// <param name="reader">XML reader object.</param> /// <returns>TextBlock object.</returns> private static TextBlock LoadTextBlock(XmlReader reader) { string name = reader.GetAttribute("Name"); ushort alpha = (reader.GetAttribute("Alpha") != null) ? Convert.ToUInt16(reader.GetAttribute("Alpha")) : _defaultDisplayObject.Alpha; 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")); bool visible = (reader.GetAttribute("Visible") != null) ? (reader.GetAttribute("Visible") == bool.TrueString) : _defaultDisplayObject.Visible; bool enabled = (reader.GetAttribute("Enabled") != null) ? (reader.GetAttribute("Enabled") == bool.TrueString) : _defaultDisplayObject.Enabled; string text = reader.GetAttribute("Text"); HorizontalAlignment textAlign = GlideUtils.Convert.ToHorizontalAlign(reader.GetAttribute("TextAlign")); VerticalAlignment textVerticalAlign = GlideUtils.Convert.ToVerticalAlign(reader.GetAttribute("TextVerticalAlign")); Font font = GlideUtils.Convert.ToFont(reader.GetAttribute("Font")); Color fontColor = GlideUtils.Convert.ToColor(reader.GetAttribute("FontColor")); Color backColor = GlideUtils.Convert.ToColor(reader.GetAttribute("BackColor")); bool showBackColor = (reader.GetAttribute("ShowBackColor") == bool.TrueString) ? true : false; TextBlock textBlock = new TextBlock(name, alpha, x, y, width, height); textBlock.Visible = visible; textBlock.Enabled = enabled; textBlock.Text = text; textBlock.TextAlign = textAlign; textBlock.TextVerticalAlign = textVerticalAlign; textBlock.Font = font; textBlock.FontColor = fontColor; textBlock.BackColor = backColor; textBlock.ShowBackColor = showBackColor; return textBlock; }