06-06-2012 04:59 PM
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
06-06-2012 05:04 PM
Ok so now you have got this far, take a good look at this walk through...
06-06-2012 05:55 PM
Ok so now you have got this far, take a good look at this walk through...
06-06-2012 07:09 PM
Ok so now you have got this far, take a good look at this walk through...
11-25-2012 03:39 AM
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:
Any suggestion is very very much appreciated as I'm kind of stuck here. Thanks heaps in advance!
11-26-2012 01:51 PM
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.
12-04-2012 05:52 AM
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!
12-04-2012 09:25 AM
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
12-04-2012 01:28 PM
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!
12-05-2012 02:27 AM
Thanks ToxFox for the informations !