GUI interface

Status
Not open for further replies.

NicoEFI

Member
Hello
I would like to create a graphical interface on pc (or android) to send data to a Teensy3.2. This data received by Teensy would be saved in Eprom.
What builder software can I use to create the interface?
Device-druid?
Does anyone have any examples, link ?
 
Hello
I would like to create a graphical interface on pc (or android) to send data to a Teensy3.2. This data received by Teensy would be saved in Eprom.
What builder software can I use to create the interface?
Device-druid?
Does anyone have any examples, link ?

Hi Nico,
I have wrestled with the same problem and having considered several alternatives settled on Virtuino. See
https://play.google.com/store/apps/details?id=com.virtuino_automations.virtuino&hl=en

I have found this to be an excellent means of building an Android frontend for my Teensy 4.0. It has a library but I discarded this as I thought it was a bit clunky and built my own instead. My Teensy communicates via Bluetooth to Android using an HC-05 connected to one of the serial interfaces. This is an easy and efficient way of doing it. If you want to use WiFi you need to use Virtuino SE instead. It is almost identical. The documentation and examples are poor but with a bit of effort one can work things out.
Here is an image of the home screen of an automotive fuel consumption monitoring system that uses Android as the front end. I only use a small subset of the widgets that are available.
flowsen-home-screen.jpg
 
If you are wondering about the large text size in my Android app that is because I needed something that could easily be read at a glance while driving, even in bright sunlight conditions, which applies to my part of the world.
 
If you are wondering about the large text size in my Android app that is because I needed something that could easily be read at a glance while driving, even in bright sunlight conditions, which applies to my part of the world.

Thanks PDOS
It's a nice professional interface. I like this.
is it possible send data from interface to teensy ?
Can you share me your code please for example.
 
Hi Nico,
you can use the library that is supplied with Virtuino. I didn't like it so wrote my own.
The principle is very straightforward.

1. Every widget has a simple two to four character identifier that you assign to the widget when you drag and drop widgets in the builder.
2. The widget identifier begins with either 'V' or 'T' and is followed by one to three digits.(I am simplifying here)
3. 'T' identifiers range from 0 to 100.
4. 'V' identifiers range from 0 to 255.
5. The identifier is followed by an '=' sign and a value.
6. This is enclosed by '!....$'
7. Data is sent from Android to Arduino as follows(for example):
!V02=10$ without a terminating CR or LF
This tells Arduino that the value '10' from widget 'V02' has been transmitted by Android.
8. The reverse is also true and in the same way Arduino can send the value '10' to the Android widget 'V02' by using the string !V02=10$

That is all there is to it. When you work with the builder you will discover constraints that determine whether you use T variables or V variables.

The main problem is that using T variables and V variables as the communication medium between Android and Arduino is non-intuitive, making the programme hard to read and maintain. I got around this problem by using associative arrays to translate human readable names into Virtuino readable names. For example:
Code:
VIRTUINO_t virt[lastVal+1] {
   {"panelSelect"            , "!V00=%i$"   },
   {"teensyTime_txt"         , "!T00=%s$"   },
   {"tankAremaining_fld"     , "!T01=%4.0f$"},
   {"tankBremaining_fld"     , "!T02=%4.0f$"},
   {"kmPerHour_fld"          , "!T03=%4.0f$"},
   {"numSV_fld"              , "!T04=%i$"   },
   {"avgCno_fld"             , "!T05=%4.1f$"},
   {"litrePer100km_fld"      , "!T06=%4.1f$"},
   {"randPer100km_fld"       , "!T07=%4.1f$"},
   {"water_fld"              , "!T08=%4.1f$"},
   {"oil_fld"                , "!T09=%4.1f$"},
   {"head_fld"               , "!T10=%4.1f$"},
   {"pressure_fld"           , "!T11=%4.1f$"},
   {"tankAcapacity_fld"      , "!T12=%4.1f$"},
   {"tankBcapacity_fld"      , "!T13=%4.1f$"},
   {"tankAdistance_fld"      , "!T14=%4.1f$"},
   {"tankBdistance_fld"      , "!T15=%4.1f$"},
The second column is a format string for a printf statement.
Examples of usage:
Code:
         virtuino.sendD("tankBrefillDate_txt", Gps.year, Gps.month, Gps.day);
         virtuino.sendT("tankBrefillTime_txt", Gps.hour, Gps.minute, Gps.second);
where
Code:
   //--------------------------------------------
   // send date ----
   void sendD(String virtKey, int year, int month, int day) { 
      char str[20];
      
      if(String S = vrtMap->get(virtKey).c_str()) {
         sprintf(str,"%4i/%02i/%02i", year, month, day);
         Bluetooth.printf(S.c_str(), str);
      }
      else
         Serial.println(virtKey);
   }
   
   //--------------------------------------------
   // send time ----
   void sendT(String virtKey, int hour, int minute, int second) { 
      char str[20];
      
      if(String S = vrtMap->get(virtKey).c_str()) {
         sprintf(str,"%02i:%02i:%02i", hour, minute, second);
         Bluetooth.printf(S.c_str(), str);
      }
      else
         Serial.println(virtKey);
   }
For the associative array library I am using SimpleMap
https://github.com/spacehuhn/SimpleMap
I parse incoming commands vrtCmd as follows
Code:
      sscanf(vrtCmd.c_str(), "!%c%i=%f$", cmdType, &cmd, &var);
      if(displayCommand)
         Serial.printf("%s: Type: %s,  Cmd: %i, Var: %f\n", vrtCmd.c_str(), cmdType, cmd, var);
and I use the following simple routine to read Virtuino data from Bluetooth.
Code:
   //--------------------------------------------
   // get incoming data on Bluetooth ----
   String get() {
      String returnLine = "";

      byte inByte;
      
      while ( Bluetooth.available() ) {
       
         inByte = Bluetooth.read(); 
         switch (inByte) {

            case '\n':   // end of text
               input_line [input_pos] = 0;  // terminating null byte

               // terminator reached! now process input_line
               // reset buffer for next time
               input_pos = 0; 
               returnLine = input_line;
               return returnLine; 
               break;
            case '\r':   // discard carriage return
               break;
            case '!':    // start of virtuino command
               input_pos = 0;
               input_line [input_pos++] = inByte;
               break;
            case '$':    // end of virtuino command 
               input_line [input_pos++] = inByte;
               input_line [input_pos++] = 0;  // terminating null byte
               input_pos = 0;
               returnLine = input_line;
               return returnLine;
               break;

            default:
            // keep adding if not full ... allow for terminating null byte
               if (input_pos < (maxInput - 10))
                 input_line [input_pos++] = inByte;
            break;

         }  // end of switch
      }

      return "";

   } // end of get()
I hope this gives you a feeling for how Virtuino can be used.
 
Thanks PDOS.
I understand the principle. I'm going to try.

I am using for a dashboard for a racing car with a Teensy3.2 and a Nextion 4.3 (+ ECU canbus).
On the Nextion, I have pages which record in eeprom configuration data such as maximum speed or minimum oil pressure ...
Via Canbus, the ECU sends the data to Teensy which sends it to the Nextion for display.
I want to change the configuration mode, because sometimes the configuration data is not transmitted correctly to the Teensy (or the Teensy does not receive correctly!). By configuring the Dashboard by android, it will be more user-friendly.
First prototype of my Dashboard https://github.com/NicoEFI/GDash
 
First prototype of my Dashboard https://github.com/NicoEFI/GDash
This is a very interesting project, quite similar to mine but with a different emphasis. You are concerned with monitoring modern high performance engines whereas my emphasis is on fuel usage of old fashioned diesel engines that lack electronic fuel injection. That was my brief, which was just too bad. I would have liked to measure fuel consumption by measuring the pulse width of the signal to the fuel injectors as that would have made for a more interesting project. Instead I am measuring fuel flow(using flow rate sensors) to and from the fuel distribution manifold. The difference is the fuel used by the engine.
 
Hi PDOS.
I begin to test Virtuino. It is simple to use.
I am not find this information : If i build an application, can i use it on other model phone. Graphical design can broken ? Can i use on iphone too ?
 
Can i use on iphone too ?

Hi Nico,
They only supply .apk downloads so I presume this means they only develop for Android.

I am not find this information : If i build an application, can i use it on other model phone. Graphical design can broken ?

I develop on a low cost Teclast A80X tablet and then upload to a Blackview A80pro and a Meizu M5 Note. These are devices with different resolutions and more importantly with different aspect ratios. For the most part this works. The source screens are resized according to the width of the target screen on the initial upload in order to preserve the aspect ratio. So the width fits perfectly but the height may not. This may necessitate vertical scrolling to see the full screen. In my case this is minor so I am not concerned.

It is a good idea to design according to the aspect ratio of the target machine. I learnt this lesson too late and I do not feel inclined to go back and change everything since that would be a lot of work. I could write a program to do a bulk resize since the project definitions are stored in a Sqlite database. I may still do this if I can scrape up the enthusiasm. I have already made other bulk changes in this way.
 
One simple question.

I have always been told/read that using "String" is a bad idea because with any micro controller due to unknown size of the what the string will contain.

Has this changed? Is it safe to use "String"s now.

If so when/how did this change?

Thanks

Bruce
 
Status
Not open for further replies.
Back
Top