LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Adjusting color and brightness of 2.8" TFT LCD color touch screen - SOLVED!

Well done Daniel!. It's all simple once you know how.

Now you are this step you will next need to modify the LVIFA file set to include your new LCD functions.

If you look in your LVIFA_Base directory (e.g. C:\Program Files (x86)\National Instruments\LabVIEW 2010\vi.lib\LabVIEW Interface for Arduino\Firmware\LVIFA_Base)

There is the main LVIFA_Base.ino sketch which polls Labview via the serial port to see what to do next. The request from Labview is then passed to a "switch" statement in LabVIEWInterface.ino.

You will need to firstly add a new 'case' for your LCD functions and then add the case enumeration to the .vi you are using.... for example in my application I have added the following which calls my custom function. Your vi may also need to send parameters such as colour etc

case 0x41:  // Get Current Sense

      retVal = getIsense(0); // Relay card CS, relay to toggle, R/W

      Serial.write( (retVal >> 8));

      Serial.write( (retVal & 0xFF));

        break;

Takle a good look at this post it walks you through adding your custom device...

https://decibel.ni.com/content/message/23934#23934

Let me know how you go!

Regards,

Dale

0 Kudos
Message 11 of 21
(3,580 Views)

Ok so now you have got this far, take a good look at this walk through...

https://decibel.ni.com/content/message/23934#23934

0 Kudos
Message 12 of 21
(3,580 Views)

Ok so now you have got this far, take a good look at this walk through...

https://decibel.ni.com/content/message/23934#23934

0 Kudos
Message 13 of 21
(3,580 Views)

Ok so now you have got this far, take a good look at this walk through...

https://decibel.ni.com/content/message/23934#23934

0 Kudos
Message 14 of 21
(3,580 Views)

Hi Dale,

I have been doing other things in the meantime and got a bit more experienced in using Arduino with LabView, but the TFT issue is still unsolved.

I had a good look at https://decibel.ni.com/content/message/23934#23934 and I tried many ways in getting a function executed by sending a case, but - unfortunately no success at all 😞

I modified both LVIFA_Base.pde and LabviewInterface.h by adding

#include <TFT_Graphics.h> (btw, what is the difference between using "" or <>?, When I look at the color in the sketch, it is yellow for the standard includes and black for my added TFT_Graphics file. Is is important that TFT_Graphics is shown in yellow color?)

In the LabviewInterface.h code I added this case:

case 0x41: 

initialize(LCD_HORIZONTAL);

ClearScreen(BLACK);

break;

As well as the functions (stolen an modified from the Graphics.cpp file):

void initialize(uint8_t orient)

{

    LCD::SetOrientation(orient);

    LCD::SetColor(WHITE);

    LCD::init();

    }

void ClearScreen(uint16_t color)

{

    LCD::resetArea();

    LCD::fill(LCD::GetWidth()-1, LCD::GetHeight()-1, color);

}

When I create a sketch like this and run it independently from LVIFA the code works fine:

#include <TFT_Graphics.h>

Graphics tft;

void setup()

{

    tft.initialize(LCD_HORIZONTAL);

    tft.ClearScreen(WHITE);

        //tft.FastSolidRect(85, 10, 240, 231, BLACK);

        //tft.DrawCircle(160,120, 100, BLUE, 1);

}

void loop()

{   

tft.ClearScreen(BLACK);

tft.FastSolidRect(85, 10, 240, 231, BLUE);

delay(1000);

tft.ClearScreen(BLUE);

tft.FastSolidRect(85, 10, 240, 231, BLACK);

delay(1000);

    }

Same for this code:

#include "TFT_Graphics.h"

void setup()                    // run once, when the sketch starts

{

}

void loop()                     // run over and over again

{

  initialize(LCD_HORIZONTAL);

  ClearScreen(BLACK);

}

void initialize(uint8_t orient)

{

    LCD::SetOrientation(orient);

    LCD::SetColor(WHITE);

    LCD::init();

    }

void ClearScreen(uint16_t color){

    LCD::resetArea();

    LCD::fill(LCD::GetWidth()-1, LCD::GetHeight()-1, color);

}

But I can't get this running with LVIFA by sending a case 0x41 using a VI like this:

send case.png

Any suggestion is very very much appreciated as I'm kind of stuck here. Thanks heaps in advance!

0 Kudos
Message 15 of 21
(3,580 Views)

Short update: I succeeded in executing a simple led blink function (arduino led at pin 13) by sending a case (command) in Labview. 🙂 But TFT is still not responding.

0 Kudos
Message 16 of 21
(3,580 Views)

Got it fixed (keep trying if something won't work!)!!! The serial communication required modification - unfortunately I got no hint at all (and no more replies) that the serial communication might be kind of relevant. Here is a bit of my LabviewInterface.pde:

/*********************************************************************************

** TFT

*********************************************************************************/

    case 0x41: //anything to display

    Serial.end();// kill serial communication

    tft.initialize(LCD_HORIZONTAL); //stuff from TFT_Lib

    tft.ClearScreen(BLACK);//stuff from TFT_Lib

    Serial.begin(DEFAULTBAUDRATE);  // restart serial communication

    break;

Works - wow!!! It took me approx. two weeks  to figure out that the serial communication had to be killed and restarted between commands. This might be kind useful general information for anyone of you trying to implement third-party libraries with LIFA... Good luck and thanks to anyone sharing brain and code to get problems solved!

0 Kudos
Message 17 of 21
(3,580 Views)

Congratulation for your effort, and glad that you finaly find the clue.

If I understand well, it means you have to cut the serial communication each time you send a command to the LCD?

If so what about if you are doing something else using serial, like data logging from an analog pin in the same time? Cuted as well and lost packets?

Thanks for your opinion

and btw, it could be very nice to share the rest of you TFT customed .pde....

regards

antoine

0 Kudos
Message 18 of 21
(3,580 Views)

mknix:

If I understand well, it means you have to cut the serial communication each time you send a command to the LCD?

If so what about if you are doing something else using serial, like data logging from an analog pin in the same time? Cuted as well and lost packets?

I assume, data acquisition rate is just limited by the overall time required for (sequential!) cutting and starting the serial communication and for execution of the 'foreign' code. No idea about lost packages...

This method is very crude but it's an efficient and programming-knowledge/time-saving workaround for my unique application. It might work with other hardware/libraries? Any experience  and comments are most welcome and appreciated!

0 Kudos
Message 19 of 21
(3,580 Views)

Thanks ToxFox for the informations !

0 Kudos
Message 20 of 21
(3,580 Views)