Pages: [1]   Go Down
Author Topic: New library for eDIPTFT displays - some troubles - help needed  (Read 1594 times)
0 Members and 1 Guest are viewing this topic.
Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I'm fairly new to Arduino and I'm just a hobby-coder, not a professional by a long shot. I'm working on my first bigger project and I have written a bunch of convenience functions to control eDIPTFT-series intelligent displays from Electronic Assembly. With the help of the forum, I now converted this collections of functions in a .ino file into a libray.

Now, my problem. Those displays use serial communication and I want to hand over the serial port to use for communications in a parameter in the constructor:

Code:
EDIPTFT::EDIPTFT(int port, int smallprotocol) {
  _port = port;
  _smallprotocol = smallprotocol;
}

Then, the sendData() function checks this parameter and decides which
port to use:

Code:
void EDIPTFT::sendData(char* data, int len) {
  if (_smallprotocol > 0) {
  }
  else {
    unsigned char i;
    for(i=0; i < len; i++) {
      switch (_port) {
case 0 : {
  Serial.write(data[i]);
  break;
}
case 1 : {
  Serial1.write(data[i]);
  break;
}
case 2 : {
  Serial2.write(data[i]);
  break;
}
case 3 : {
  Serial3.write(data[i]);
  break;
}
      }
    }
  }
}

Trouble is, I can't get it compiled. The sketch I'm writing in my main project includes the FastSerial library which is needed by some other libraries I also use. Now, when I try to compile my sketch with my EDIPTFT library, I get these errors:

Code:
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `__vector_25'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
/opt/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../avr/bin/ld: Disabling relaxation: it will not work with multiple definitions
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `__vector_36'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `__vector_51'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `__vector_54'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `Serial'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
/opt/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../avr/bin/ld: Warning: size of symbol `Serial' changed from 29 in UxV_CS.cpp.o to 34 in core.a(HardwareSerial.cpp.o)
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `Serial1'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
/opt/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../avr/bin/ld: Warning: size of symbol `Serial1' changed from 29 in UxV_CS.cpp.o to 34 in core.a(HardwareSerial.cpp.o)
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `Serial2'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
/opt/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../avr/bin/ld: Warning: size of symbol `Serial2' changed from 29 in UxV_CS.cpp.o to 34 in core.a(HardwareSerial.cpp.o)
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `Serial3'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
/opt/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../avr/bin/ld: Warning: size of symbol `Serial3' changed from 29 in UxV_CS.cpp.o to 34 in core.a(HardwareSerial.cpp.o)
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `__vector_26'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `__vector_37'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `__vector_52'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here
core.a(HardwareSerial.cpp.o): In function `global constructors keyed to rx_buffer':
/opt/arduino-1.0.3/hardware/arduino/cores/arduino/HardwareSerial.cpp:515: multiple definition of `__vector_55'
UxV_CS.cpp.o:/opt/arduino-1.0.3/UxV_CS.ino:79: first defined here

Could somebody help me out with that, please?
The complete code of my library is at

https://github.com/sgofferj/EDIPTFT

-Stefan
Logged

Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is solved meanwhile smiley. I had to remove the inclusion of Arduino.h and additionally include FastSerial.h in my library's .cpp-file. As I understood it, the appeareance of Serial<x>.write() in my lib caused Arduino to automatically include the "wrong" hardwareserial code which collided with the FastSerial lib which is included by the sketch.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,

first of all, thank you! :-)

i would like to use your library with a 7" eDIPTFT display in my next little project.

can you add a small simple example code on GITHUB to show how your library should
be implemented in the main program and how you read back touch-events?

thanks!

with best regards,
 martin lang - austria
Logged

Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I haven't got time to think about an example yet.

You include it basically with

Code:
#include <FastSerial.h>
#include <EDIPTFT.h>

FastSerialPort0(Serial);
FastSerialPort1(Serial1);
FastSerialPort2(Serial2);
FastSerialPort3(Serial3);

EDIPTFT ea(0,1);   //port = 0, smallprotocol on = 1, off = 0

void setup() {
  Serial.begin(115200,256,256);
  ea.smallProtoSelect(7); // send the select command with the matching ID, otherwise the display might not talk to us
  ea.clear();
  ea.cursor(false);
  ...
}


There are a few limitations which I haven't got around yet. One is the need to declare all ports, another the dependance on FastSerial.

Then parsing input, e.g. like this...:

Code:
void loop() {
  ...
  if (ea.datainBuffer() >0) parseSerial();                       // If the display has data for us, go and get it
  ...
}


void parseSerial() {
  char i;
  char len = ea.datainBuffer();
  char data[len];
  ea.readBuffer(data);
  if (data[0] == 27) {
    if ((data[1] == 'A') && (data[2] == 1)) {
      switch (data[3]) {
        case 1 : { setMode(1); break; }
        case 2 : { setMode(2); break; }
        case 3 : { setMode(3); break; }
        case 4 : { setMode(4); break; }
        case 5 : { setMode(5); break; }
        case 6 : { setMode(6); break; }
        case 7 : { setMode(7); break; }
      }
    }
  }
}

datainBuffer() returns the number of characters which are in the output buffer, ready to be pulled. readBuffer() reads the output buffer. Smartprotocol is implemented in those too, when selected on init.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you!

Does your library also work with the normal Serial library when 115200 is not needed?

Ciao
 Martin
Logged

Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It SHOULD work. But you have to remove the FastSerial include from the library too then. However, I'd recommend FastSerial because you can define the buffer size of the read buffer up to 256 bytes and thus are less likely to miss any message from the display. I'd also recommend 115k2. The display is not much fun on slower rates smiley.
Logged

Pages: [1]   Go Up
Jump to: