Based on tutorial about using Nextion progress bar control with Arduino (http://blog.iteadstudio.com/product-preview-nextion-in-an-arduino-project-2/), I created demo how to create it with Gadgeteer board.

Hardware requirements

  1.        Gadgeteer mainboard (I used https://www.ghielectronics.com/catalog/product/349)
  2.        Nextio Display (I used http://imall.itead.cc/display/nextion/nextion-nx3224t024.html)
  3.        Extender / Breakout module to connect Nextion display to Gadgeteer port (I used https://www.ghielectronics.com/catalog/product/273)
  4.        Gadgeteer Joystick module, potentiometer module or something similar (I used https://www.ghielectronics.com/catalog/product/299)

Software requirements

  1.        Gadgeteer developer environment (Visual Studio, SDKs, …)
  2.        Nextion.NET Gadgeteer driver (https://nextionnet.codeplex.com/releases/view/616960)
  3.        Nextion progress bar demo HMI file (http://wiki.iteadstudio.com/images/4/4f/Progressbar.zip)

Step by step tutorial

  1.        Upload Nextion progress bar demo HMI file
  2.        Create new Gadgeteer Application project
  3.        Use gadgeteer designer to design your hardware connections.
  4.        Use this code

namespace NextionTest
{
   public partial class Program
   {
       private ProgressBar NextProgress;
       private TextBox NextProcent;

       // This method is run when the mainboard is powered up or reset.   
       void ProgramStarted()
       {
           //Define controls in Nextion HMI. 
           //Because we don’t use touch events the order of defining controls is not important.
           NextProgress = nextionDisplay.Controls.DefineProgressBar(0, "j0");
           NextProcent = nextionDisplay.Controls.DefineTextBox(0, "t0"); 

           //Start refresh timer to read value from joystick and display it on the Nextion display
           var refreshTimer = new GT.Timer(100);
           refreshTimer.Tick += refreshTimer_Tick;
           refreshTimer.Start();
       }

       void refreshTimer_Tick(GT.Timer timer)
       {
           //Convert joystick position to percentage
           byte proc = (byte)((joystick.GetPosition().X + 1) * 50);
           //Change progress bar value
           NextProgress.Val = proc;
           //Change textbox value
           NextProcent.Text = proc.ToString();
       }
   }
}

  1.        Deploy and test

Last edited Sep 2, 2015 at 10:39 AM by jernejk, version 1