Ejemplo n.º 1
0
        // 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();
        }
Ejemplo n.º 2
0
        // 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();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        /*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();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Parses the DataGrid XML into a UI component.
        /// </summary>
        /// <param name="reader">XML reader object.</param>
        /// <returns>Datagrid object.</returns>
        private static DataGrid LoadDataGrid(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"));
            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;

            Font font = GlideUtils.Convert.ToFont(reader.GetAttribute("Font"));
            int rowHeight = Convert.ToInt32(reader.GetAttribute("RowHeight"));
            int rowCount = Convert.ToInt32(reader.GetAttribute("RowCount"));

            bool draggable = (reader.GetAttribute("Draggable") == bool.TrueString) ? true : false;
            bool tappableCells = (reader.GetAttribute("TappableCells") == bool.TrueString) ? true : false;
            bool sortableHeaders = (reader.GetAttribute("SortableHeaders") == bool.TrueString) ? true : false;
            bool showHeaders = (reader.GetAttribute("ShowHeaders") == bool.TrueString) ? true : false;
            bool showScrollbar = (reader.GetAttribute("ShowScrollbar") == bool.TrueString) ? true : false;
            int scrollbarWidth = Convert.ToInt32(reader.GetAttribute("ScrollbarWidth"));

            Color headersBackColor = GlideUtils.Convert.ToColor(reader.GetAttribute("HeadersBackColor"));
            Color headersFontColor = GlideUtils.Convert.ToColor(reader.GetAttribute("HeadersFontColor"));
            Color itemsBackColor = GlideUtils.Convert.ToColor(reader.GetAttribute("ItemsBackColor"));
            Color itemsAltBackColor = GlideUtils.Convert.ToColor(reader.GetAttribute("ItemsAltBackColor"));
            Color itemsFontColor = GlideUtils.Convert.ToColor(reader.GetAttribute("ItemsFontColor"));
            Color selectedItemBackColor = GlideUtils.Convert.ToColor(reader.GetAttribute("SelectedItemBackColor"));
            Color selectedItemFontColor = GlideUtils.Convert.ToColor(reader.GetAttribute("SelectedItemFontColor"));
            Color gridColor = GlideUtils.Convert.ToColor(reader.GetAttribute("GridColor"));
            Color scrollbarBackColor = GlideUtils.Convert.ToColor(reader.GetAttribute("ScrollbarBackColor"));
            Color scrollbarScrubberColor = GlideUtils.Convert.ToColor(reader.GetAttribute("ScrollbarScrubberColor"));

            DataGrid dataGrid = new DataGrid(name, alpha, x, y, width, rowHeight, rowCount);
            dataGrid.Visible = visible;
            dataGrid.Enabled = enabled;
            dataGrid.Font = font;

            dataGrid.Draggable = draggable;
            dataGrid.TappableCells = tappableCells;
            dataGrid.SortableHeaders = sortableHeaders;
            dataGrid.ShowHeaders = showHeaders;
            dataGrid.ShowScrollbar = showScrollbar;
            dataGrid.ScrollbarWidth = scrollbarWidth;

            dataGrid.HeadersBackColor = headersBackColor;
            dataGrid.HeadersFontColor = headersFontColor;
            dataGrid.ItemsBackColor = itemsBackColor;
            dataGrid.ItemsAltBackColor = itemsAltBackColor;
            dataGrid.ItemsFontColor = itemsFontColor;
            dataGrid.SelectedItemBackColor = selectedItemBackColor;
            dataGrid.SelectedItemFontColor = selectedItemFontColor;
            dataGrid.GridColor = gridColor;
            dataGrid.ShowScrollbar = showScrollbar;
            dataGrid.ScrollbarWidth = scrollbarWidth;

            return dataGrid;
        }