void changeState() { Bitmap bmp; IsEmpty = !IsEmpty; if (IsEmpty) { if (picAvail == null) { var temp = new GT.Picture(Resources.GetBytes(Resources.BinaryResources.empty), GT.Picture.PictureEncoding.JPEG); picAvail = temp.MakeBitmap(); } bmp = picAvail; txt.Text = "Available"; } else { if (picNotAvail == null) { var temp = new GT.Picture(Resources.GetBytes(Resources.BinaryResources.full), GT.Picture.PictureEncoding.JPEG); picNotAvail = temp.MakeBitmap(); } bmp = picNotAvail; txt.Text = "Being Used"; } img.Bitmap = bmp; img.Invalidate(); txt.Invalidate(); }
/// <summary> /// Testing method for DisplayNHVN module /// </summary> private static void TestGlide() { var lcd = new DisplayNHVN(GHIElectronics.TinyCLR.Pins.FEZRaptor.I2cBus.Socket13, FEZRaptor.Socket16.Pin9, FEZRaptor.Socket13.Pin3, DisplayNHVN.DisplayTypes.Display7inch); Glide.SetupGlide(800, 480, 96, 0, lcd.displayController); string GlideXML = @"<Glide Version=""1.0.7""><Window Name=""instance115"" Width=""800"" Height=""480"" BackColor=""dce3e7""><Button Name=""btn"" X=""40"" Y=""60"" Width=""120"" Height=""40"" Alpha=""255"" Text=""Click Me"" Font=""4"" FontColor=""000000"" DisabledFontColor=""808080"" TintColor=""000000"" TintAmount=""0""/><TextBlock Name=""TxtTest"" X=""42"" Y=""120"" Width=""650"" Height=""32"" Alpha=""255"" Text=""TextBlock"" TextAlign=""Left"" TextVerticalAlign=""Top"" Font=""6"" FontColor=""0"" BackColor=""000000"" ShowBackColor=""False""/></Window></Glide>"; //Resources.GetString(Resources.StringResources.Window) Window window = GlideLoader.LoadWindow(GlideXML); GlideTouch.Initialize(); GHI.Glide.UI.Button btn = (GHI.Glide.UI.Button)window.GetChildByName("btn"); GHI.Glide.UI.TextBlock txt = (GHI.Glide.UI.TextBlock)window.GetChildByName("TxtTest"); btn.TapEvent += (object sender) => { txt.Text = "Welcome to Glide for TinyCLR - Cheers from Mif ;)"; Debug.WriteLine("Button tapped."); window.Invalidate(); txt.Invalidate(); }; Glide.MainWindow = window; lcd.CapacitiveScreenReleased += Lcd_CapacitiveScreenReleased; lcd.CapacitiveScreenPressed += Lcd_CapacitiveScreenPressed; //Thread.Sleep(Timeout.Infinite); }
void SendData() { //loop forever for (; ;) { if (pulseOximeter.IsProbeAttached) { //get data from oximeter var RefreshedSensor = new DataSensor() { SPO2 = pulseOximeter.LastReading.SPO2, PulseRate = pulseOximeter.LastReading.PulseRate, SignalStrength = pulseOximeter.LastReading.SignalStrength, Tanggal = DateTime.Now }; string data = Json.NETMF.JsonSerializer.SerializeObject(RefreshedSensor); byte[] b = Encoding.UTF8.GetBytes(data); string hex = "radio tx " + ToHexString(b, 0, b.Length); // TX payload needs to be HEX //send data via lora _loraSerial.WriteLine(hex); txtLora.Text = "Lora Status : OK"; txtStatus.Text = "Sending data : " + RefreshedSensor.Tanggal.ToString("dd MMM yy HH:mm:ss"); txtSPO2.Text = "SPO2 : " + RefreshedSensor.SPO2; txtSignal.Text = "Signal : " + RefreshedSensor.SignalStrength; txtPulseRate.Text = "Pulse Rate : " + RefreshedSensor.PulseRate; //refresh window.Invalidate(); txtLora.Invalidate(); txtStatus.Invalidate(); txtSPO2.Invalidate(); txtSignal.Invalidate(); txtPulseRate.Invalidate(); Thread.Sleep(2000); } } }
void Loop() { //loop forever for (; ;) { if (pulseOximeter.IsProbeAttached) { var msg = ""; //get data from oximeter var item = new DataSensor() { SPO2 = pulseOximeter.LastReading.SPO2, PulseRate = pulseOximeter.LastReading.PulseRate, SignalStrength = pulseOximeter.LastReading.SignalStrength, Tanggal = DateTime.Now }; txtStatus.Text = "Read data from sensor..."; txtSPO2.Text = "SPO2 : " + item.SPO2; if ((long)item.SPO2 >= 95) { msg += "alhamdulilah sehat bang! "; } else { msg += "antum kurang tidur nih, kurang oksigen. "; } txtPulseRate.Text = "Pulse Rate : " + item.PulseRate; if ((long)item.PulseRate >= 60 && (long)item.PulseRate <= 100) { msg += "detak jantung normal. "; } else { msg += "detak jantung abnormal. "; } //update display txtDesc.Text = msg; txtLora.Text = "Lora Status : OK"; window.Invalidate(); txtLora.Invalidate(); txtStatus.Invalidate(); txtSPO2.Invalidate(); txtSignal.Invalidate(); txtPulseRate.Invalidate(); txtDesc.Invalidate(); var Pesan = Encoding.UTF8.GetBytes(Json.NETMF.JsonSerializer.SerializeObject(item)); client.Publish("mifmasterz/medical/data", Pesan, MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); } Thread.Sleep(50); } }
void Loop() { //loop forever for (; ;) { if (pulseOximeter.IsProbeAttached) { var msg = ""; //get data from oximeter var item = new DataSensor() { SPO2 = pulseOximeter.LastReading.SPO2, PulseRate = pulseOximeter.LastReading.PulseRate, SignalStrength = pulseOximeter.LastReading.SignalStrength, Tanggal = DateTime.Now }; txtStatus.Text = "Read data from sensor..."; txtSPO2.Text = "SPO2 : " + item.SPO2; if ((long)item.SPO2 >= 95) { msg += "alhamdulilah sehat bang! "; } else { msg += "antum kurang tidur nih, kurang oksigen. "; } txtPulseRate.Text = "Pulse Rate : " + item.PulseRate; if ((long)item.PulseRate >= 60 && (long)item.PulseRate <= 100) { msg += "detak jantung normal. "; } else { msg += "detak jantung abnormal. "; } //update display txtDesc.Text = msg; txtLora.Text = "Lora Status : OK"; window.Invalidate(); txtLora.Invalidate(); txtStatus.Invalidate(); txtSPO2.Invalidate(); txtSignal.Invalidate(); txtPulseRate.Invalidate(); txtDesc.Invalidate(); } Thread.Sleep(50); } }
void PrintToLCD(string message) { //cek message if (message != null && message.Length > 0) { try { var msg = ""; //parse json message Hashtable hashtable = JsonSerializer.DeserializeString(message) as Hashtable; foreach (DictionaryEntry item in hashtable) { switch (item.Key.ToString()) { case "Tanggal": txtStatus.Text = "Get data : " + DateTimeExtensions.FromIso8601(item.Value.ToString()).ToString("dd MMM yyyy HH:mm:ss"); break; case "SPO2": txtSPO2.Text = "SPO2 : " + item.Value; if ((long)item.Value >= 95) { msg += "alhamdulilah sehat bang! "; } else { msg += "antum kurang tidur nih, kurang oksigen. "; } break; case "SignalStrength": txtSignal.Text = "Signal : " + item.Value; break; case "PulseRate": txtPulseRate.Text = "Pulse Rate : " + item.Value; if ((long)item.Value >= 60 && (long)item.Value <= 100) { msg += "detak jantung normal. "; } else { msg += "detak jantung abnormal. "; } break; } } //update display txtDesc.Text = msg; txtLora.Text = "Lora Status : OK"; window.Invalidate(); txtLora.Invalidate(); txtStatus.Invalidate(); txtSPO2.Invalidate(); txtSignal.Invalidate(); txtPulseRate.Invalidate(); txtDesc.Invalidate(); } catch (Exception ex) { txtPulseRate.Text = message + "_" + ex.Message + "_" + ex.StackTrace; txtPulseRate.Invalidate(); } } }
public override void Init(params string[] Param) { MainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.MyRoomForm)); ArrayList control = new ArrayList(); GT.Picture pic = null; var imgTemp = (GHI.Glide.UI.Image)MainWindow.GetChildByName("imgTemp"); pic = new GT.Picture(Resources.GetBytes(Resources.BinaryResources.temperature), GT.Picture.PictureEncoding.JPEG); imgTemp.Bitmap = pic.MakeBitmap(); control.Add(imgTemp); var imgLight = (GHI.Glide.UI.Image)MainWindow.GetChildByName("imgLight"); pic = new GT.Picture(Resources.GetBytes(Resources.BinaryResources.light), GT.Picture.PictureEncoding.JPEG); imgLight.Bitmap = pic.MakeBitmap(); control.Add(imgLight); var imgHumid = (GHI.Glide.UI.Image)MainWindow.GetChildByName("imgHumid"); pic = new GT.Picture(Resources.GetBytes(Resources.BinaryResources.humidity), GT.Picture.PictureEncoding.JPEG); imgHumid.Bitmap = pic.MakeBitmap(); control.Add(imgHumid); GT.Timer timer = new GT.Timer(2000); var Btn = (GHI.Glide.UI.Button)MainWindow.GetChildByName("btnBack"); control.Add(Btn); Btn.PressEvent += (sender) => { timer.Stop(); CallFormRequestEvent(ScreenTypes.MainMenu); }; txtTemp = (GHI.Glide.UI.TextBlock)MainWindow.GetChildByName("txtTemp"); txtHumid = (GHI.Glide.UI.TextBlock)MainWindow.GetChildByName("txtHumid"); txtLight = (GHI.Glide.UI.TextBlock)MainWindow.GetChildByName("txtLight"); Glide.MainWindow = MainWindow; timer.Tick += (a) => { var measure = tempHumidSI70.TakeMeasurement(); txtTemp.Text = Toolbox.NETMF.Tools.Round((float)measure.Temperature, 2);// + "C"; txtHumid.Text = Toolbox.NETMF.Tools.Round((float)measure.RelativeHumidity);// + "%"; txtLight.Text = Toolbox.NETMF.Tools.Round((float)lightSense.GetIlluminance());// + "Lux"; //MainWindow.Graphics.DrawRectangle(txtTemp.Rect, MainWindow.BackColor, 255); //MainWindow.Graphics.DrawRectangle(txtHumid.Rect, MainWindow.BackColor, 255); //MainWindow.Graphics.DrawRectangle(txtLight.Rect, MainWindow.BackColor, 255); txtTemp.Invalidate(); txtHumid.Invalidate(); txtLight.Invalidate(); MainWindow.Invalidate(); }; timer.Start(); //MainWindow.Invalidate(); }