Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display TM1638 Library Integration (HUD Racing)
14-08-2014, 06:28 PM,
#1
Display TM1638 Library Integration (HUD Racing)
Hi!, I Succesfully loaded an sketch that uses the TM1638 Library from Arduino, and I tested this awesome and cheap Display for Racing Games:
https://www.youtube.com/watch?v=sOAnilJFGhU

Here the link to the Arduino Library:
http://code.google.com/p/tm1638-library/

And the link to the HUD Racing Project, with the Arduino Code http://batrako.blogspot.com.es/2013/06/n...eased.html

Is there any guide to convert an Arduino Library to Pinguino Library? I founded this:
http://forum.pinguino.cc/showthread.php?...19#pid8619

I can work on pdl file, anyone can help me with this?

I like this library to get working on Pinguino because has incorporated USB, so with minimun hardware we can do this awesome Display!

Ty in advance Tongue
Reply
20-08-2014, 11:40 AM,
#2
RE: Display TM1638 Library Integration (HUD Racing)
IMO the thread you mentioned is the best guide you can find to understand how Pinguino works and then try to convert Arduino's libraries. If you need extra help just ask ;-)
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
21-08-2014, 12:28 AM, (This post was last modified: 21-08-2014, 12:28 AM by juanpintom.)
#3
RE: Display TM1638 Library Integration (HUD Racing)
Ok some work made, attached pdl files, can you take a look? Smile

On cpp files we need to change every :: with _ and add a TM16XX_ before call a function?

I modified TM16XX.cpp too but isn't finished. I've modified extension to txt because I can't upload cpp files :S[/u]


Attached Files
.pdl   TM16XX.pdl (Size: 728 bytes / Downloads: 1)
.pdl   TM1638.pdl (Size: 628 bytes / Downloads: 1)
.h   TM16XX.h (Size: 2.7 KB / Downloads: 2)
.h   TM1638.h (Size: 2.53 KB / Downloads: 1)
.txt   TM16XX.txt (Size: 3.94 KB / Downloads: 1)
.c   TM16XX.c (Size: 4.18 KB / Downloads: 1)
Reply
21-08-2014, 08:54 PM, (This post was last modified: 21-08-2014, 08:55 PM by regis.)
#4
RE: Display TM1638 Library Integration (HUD Racing)
You should have no classes in your header files as it is pure C++
Just remove the class syntax included public and private but keep what is inside.

Quote:On cpp files we need to change every :: with _ and add a TM16XX_ before call a function?
No constructor ( :: ) in C so in order to quickly adapt C++ to C, I proposed to replace it with _
So TM1638:ConfusedetLED becomes TM1638_setLED, just as you did.

Your pdl files are good.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
21-08-2014, 10:43 PM, (This post was last modified: 21-08-2014, 10:51 PM by juanpintom.)
#5
RE: Display TM1638 Library Integration (HUD Racing)
(21-08-2014, 08:54 PM)regis Wrote: You should have no classes in your header files as it is pure C++
Just remove the class syntax included public and private but keep what is inside.

Sorry, I dont did this before, and maybe its big for me... xD
What about the arguments?
Original:
Code:
TM16XX::TM16XX(byte dataPin, byte clockPin, byte strobePin, byte displays, boolean activateDisplay,
    byte intensity)
{
  this->dataPin = dataPin;
  this->clockPin = clockPin;
  this->strobePin = strobePin;
  this->displays = displays;

  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(strobePin, OUTPUT);

  digitalWrite(strobePin, HIGH);
  digitalWrite(clockPin, HIGH);

  sendCommand(0x40);
  sendCommand(0x80 | (activateDisplay ? 8 : 0) | min(7, intensity));

  digitalWrite(strobePin, LOW);
  send(0xC0);
  for (int i = 0; i < 16; i++) {
    send(0x00);
  }
  digitalWrite(strobePin, HIGH);
}

Modified:
Code:
//Variables added from TM16XX.h
    byte displays;
    byte dataPin;
    byte clockPin;
    byte strobePin;

TM16XX_TM16XX(byte dataPin, byte clockPin, byte strobePin, byte displays, boolean activateDisplay,
    byte intensity)
{
  this->dataPin = dataPin;
  this->clockPin = clockPin;
  this->strobePin = strobePin;
  this->displays = displays;

  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(strobePin, OUTPUT);

  digitalWrite(strobePin, HIGH);
  digitalWrite(clockPin, HIGH);

  sendCommand(0x40);
  sendCommand(0x80 | (activateDisplay ? 8 : 0) | min(7, intensity));

  digitalWrite(strobePin, LOW);
  send(0xC0);
  for (int i = 0; i < 16; i++) {
    send(0x00);
  }
  digitalWrite(strobePin, HIGH);
}

It's right?

If with this modification the file is ok I'll start with TM1638.cpp
Reply
21-08-2014, 11:22 PM,
#6
RE: Display TM1638 Library Integration (HUD Racing)
(21-08-2014, 10:43 PM)juanpintom Wrote: TM16XX_TM16XX(byte dataPin, byte clockPin, byte strobePin, byte displays, boolean
This one initiate the library so let's call it TM16XX_init

Quote: pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(strobePin, OUTPUT);

digitalWrite(strobePin, HIGH);
digitalWrite(clockPin, HIGH);

Don't forget to #include Pinguino's C libraries :
#include <digitalw.c> for digitalWrite for ex.
You will then see that digitalWrite is not the C name of the function (digitalwrite) but only what we use with the IDE (see also the pdl files). I know it's a bit tricky ...

Anyway keep on the good work, you do it right !
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
22-08-2014, 12:44 AM, (This post was last modified: 22-08-2014, 01:22 AM by juanpintom.)
#7
RE: Display TM1638 Library Integration (HUD Racing)
Ok, I think it's near to be done, but I didn't found the problem. There's an error on compile.
Im using 999 /w 4x bootloader on 2550

I "adapted" a simple example but fail.
Code:
#include "TM16XX.c"

// define a module on data pin 8, clock pin 9 and strobe pin 7
TM16XX.init(8, 9, 7, 1, 7);

void setup() {
  // display a hexadecimal number and set the left 4 dots
  TM16XX.setDisplayToHexNumber(0x1234ABCD, 0xF0);
}

void loop() {
  byte keys = TM16XX.getButtons();

  // light the first 4 red LEDs and the last 4 green LEDs as the buttons are pressed
  TM16XX.setLEDs(((keys & 0xF0) << 8) | (keys & 0xF));
}

Error on complie:
Quote:error line 45 too many parameters

error line 46 too many parameters

error line 47 too many parameters

error line 49 too many parameters

error line 50 too many parameters

error line 52 too many parameters

error line 53 too many parameters

error line 55 too many parameters

error line 56 too many parameters

error line 58 too many parameters

error line 60 too many parameters

error line 67 too many parameters

error line 70 too many parameters

error line 71 too many parameters

error line 72 too many parameters

Line 45 in TM16XX.c is:
Code:
pinMode(dataPin, OUTPUT);

Files atached Smile

(22-08-2014, 12:44 AM)juanpintom Wrote: Ok, I think it's near to be done, but I didn't found the problem. There's an error on compile.
Im using 999 /w 4x bootloader on 2550

I "adapted" a simple example but fail.
Code:
#include "TM16XX.c"

// define a module on data pin 8, clock pin 9 and strobe pin 7
TM16XX.init(8, 9, 7, 1, 7);

void setup() {
  // display a hexadecimal number and set the left 4 dots
  TM16XX.setDisplayToHexNumber(0x1234ABCD, 0xF0);
}

void loop() {
  byte keys = TM16XX.getButtons();

  // light the first 4 red LEDs and the last 4 green LEDs as the buttons are pressed
  TM16XX.setLEDs(((keys & 0xF0) << 8) | (keys & 0xF));
}

Error on complie:
Quote:error line 45 too many parameters

error line 46 too many parameters

error line 47 too many parameters

error line 49 too many parameters

error line 50 too many parameters

error line 52 too many parameters

error line 53 too many parameters

error line 55 too many parameters

error line 56 too many parameters

error line 58 too many parameters

error line 60 too many parameters

error line 67 too many parameters

error line 70 too many parameters

error line 71 too many parameters

error line 72 too many parameters

Line 45 in TM16XX.c is:
Code:
pinMode(dataPin, OUTPUT);

Files atached Smile

Edit: I copied pdl files under p8/pdl and c files under p8/pinguino/libraries, right?

Change every byte var with char is needed, right?


Attached Files
.pdl   TM16XX.pdl (Size: 770 bytes / Downloads: 0)
.c   TM16XX.c (Size: 4.41 KB / Downloads: 0)
.c   TM16XXFonts.c (Size: 3.79 KB / Downloads: 0)
Reply
22-08-2014, 05:20 AM,
#8
RE: Display TM1638 Library Integration (HUD Racing)
Ok I changed every pinMode with pinmode and digitalW or R with digitalw and r.

But now not compile Sad

I changed every byte with char, boolean with bool, but I don't know how I can do this with String variable, can you help me?

I maded the TM16XX.h, i think it's ok but I don't know how typedef enum { works of if its needed

Changed "virtual void" with "void"

I included TM16XXFonts.c constants on TM16XX.h

Files attached, I hope you can take a look to the code Smile

Ty!


Attached Files
.pdl   TM16XX.pdl (Size: 774 bytes / Downloads: 1)
.c   TM16XX.c (Size: 4.02 KB / Downloads: 2)
.h   TM16XX.h (Size: 6.08 KB / Downloads: 1)
Reply
22-08-2014, 09:06 AM,
#9
RE: Display TM1638 Library Integration (HUD Racing)
(22-08-2014, 05:20 AM)juanpintom Wrote: I changed every byte with char, boolean with bool, but I don't know how I can do this with String variable, can you help me?
in TM16XX.c and TM16XX.h replace every bool type with char.
You defined i (int i) as a global variable but it's better to define it locally in every function.
I'm not sure you can defined a function like this: void TM16XX_setDisplay(const char values[], unsigned int size), use void TM16XX_setDisplay(char *values, unsigned int size) instead.
You replaced String with char * and this is what must be done.

Quote:I maded the TM16XX.h, i think it's ok but I don't know how typedef enum { works of if its needed
It seems ok.

What error message do you get ?
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
22-08-2014, 01:32 PM,
#10
RE: Display TM1638 Library Integration (HUD Racing)
No errors, just give msg compiling...

I will modify variables in a few hours

Ty
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)