Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display TM1638 Library Integration (HUD Racing)
22-08-2014, 04:14 PM, (This post was last modified: 22-08-2014, 04:18 PM by juanpintom.)
#11
RE: Display TM1638 Library Integration (HUD Racing)
Ok, bool to char changed

Variable i defined on every funcion.

I need to modify this too?
const char* string to char *string
Code:
void TM16XX_setDisplayToString(const char* string, const word dots, const char pos, const char font[])

to:
Code:
void TM16XX_setDisplayToString(char *string, const word dots, const char pos, const char font[])

Isn't compile, but I think it's a problem with my example... xD
Sorry this are my first steps with Pinguino Tongue

I updated to v11, and pdl, c and h files are in the new folder.

Ty!

Edit: Pinguino example:

Code:
/*
//It needed? which one?
//#include <TM16XX.c>
//#include TM16XX.c
//#include "TM16XX.c"




void setup() {

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

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

void loop() {
  char 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));
}

Attached files updated


Attached Files
.c   TM16XX.c (Size: 4.02 KB / Downloads: 0)
.h   TM16XX.h (Size: 6.08 KB / Downloads: 0)
.pdl   TM16XX.pdl (Size: 774 bytes / Downloads: 3)
Reply
22-08-2014, 05:29 PM,
#12
RE: Display TM1638 Library Integration (HUD Racing)
(22-08-2014, 04:14 PM)juanpintom Wrote: I need to modify this too?
const char* string to char *string
No

Quote:I updated to v11, and pdl, c and h files are in the new folder.
.c and .h can be in your own directory but .pdl must be in the path of the IDE.
If you want to test your lib., test it with C name functions (those in your .c file).
So not TM16XX.setDisplayToHexNumber(0x1234ABCD, 0xF0); but TM16XX_setDisplayToHexNumber(0x1234ABCD, 0xF0);
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, 05:55 PM,
#13
RE: Display TM1638 Library Integration (HUD Racing)
Ok I modified to this:

Code:
//#include TM16XX.c
//#include "TM16XX.c"
#include <TM16XX.c>


// define a module on data pin 8, clock pin 9 and strobe pin 7


void setup() {
  // display a hexadecimal number and set the left 4 dots
  TM16XX_init(8, 9, 7);
  TM16XX_setDisplayToHexNumber(0x1234ABCD, 0xF0);
  
}

void loop() {
  char 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));
}

But not compile yet Sad Maybe it's a problem with my ide or permissions, can you try to compile?


Attached Files
.c   TM16XX.c (Size: 4.03 KB / Downloads: 1)
.h   TM16XX.h (Size: 6.07 KB / Downloads: 1)
.pde   tm1638_one_module_example.pde (Size: 1.1 KB / Downloads: 1)
Reply
22-08-2014, 06:51 PM,
#14
RE: Display TM1638 Library Integration (HUD Racing)
#include "TM16XX.c" (as it is temporary a local file) not #include <TM16XX.c>

in TM16XX.h, you can not assign a value in a function declaration in C, even less in a function prototype so :
void TM16XX_init(char dataPin, char clockPin, char strobePin, char displays, char activateDisplay = true, char intensity = 7);
should be :
void TM16XX_init(char dataPin, char clockPin, char strobePin, char displays, char activateDisplay, char intensity);

And there is also no optional variableslike in C++, so in your example you must give a value to each variable :
TM16XX_init(8, 9, 7); -> TM16XX_init(8, 9, 7, ? , true, 7);

Press F9 after compilation and you will get all error messages.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
23-08-2014, 01:28 AM,
#15
RE: Display TM1638 Library Integration (HUD Racing)
Ok, more news.

With v11 there are no log on stdout.
I loaded with 999 and I can get now logs, I corrected every error and now compile.

#include "TM16XX.c" added. C and H files are in the same folder as pde.

I found this line on TM1638.cpp that calls TM16XX and set the fouth value to 8, so your ? it's an 8 .

Code:
TM1638::TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay, byte intensity)
    : TM16XX(dataPin, clockPin, strobePin, 8, activateDisplay, intensity)

And the example now looks like:
Code:
#include "TM16XX.c"

void setup() {
  TM16XX_init(5, 6, 7, 8, 1, 7);
}

void loop() {
}

Now start the problem, I don't know how exatly works fuctions TM16XX_send and TM16XX_sendCommand on this library. I started with the most simple one:

void TM16XX_init(char dataPin, char clockPin, char strobePin, char displays, char activateDisplay, char intensity)
{
int i;
//this->dataPin = dataPin;
dataPin = dataPin;
clockPin = clockPin;
strobePin = strobePin;
displays = displays;

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

digitalwrite(strobePin, HIGH);
digitalwrite(clockPin, HIGH);

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

digitalwrite(strobePin, LOW);
TM16XX_send(0xC0);

for (i = 0; i < 16; i++) {
TM16XX_send(0x00);
}
digitalwrite(strobePin, HIGH);
}

I don't know how I can start with all leds on, i tried to modify
Code:
for (i = 0; i < 16; i++) {
    TM16XX_send(0x00);

to
Code:
for (i = 0; i < 16; i++) {
    TM16XX_send(0x01);
or
Code:
for (i = 0; i < 16; i++) {
    TM16XX_send(0xFF);

New files with many modifications maded.

Ty again Smile I hope we can get this working Tongue


Attached Files
.h   TM16XX.h (Size: 6.32 KB / Downloads: 1)
.c   TM16XX.c (Size: 4.05 KB / Downloads: 1)
Reply
23-08-2014, 09:05 AM,
#16
RE: Display TM1638 Library Integration (HUD Racing)
All your functions call TM16XX_sendChar() which is empty ...
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
23-08-2014, 01:02 PM,
#17
RE: Display TM1638 Library Integration (HUD Racing)
I saw this:

void TM16XX_init(char dataPin, char clockPin, char strobePin, char displays, char activateDisplay, char intensity)
{
int i;
//this->dataPin = dataPin;
dataPin = dataPin;
(etc)

The C++ one that's commented out was setting the members of the object (this) to the values passed in. The new code does nothing.

I'm not sure what you need instead but doing nothing is unlikely to be it Smile

John
Reply
23-08-2014, 02:49 PM, (This post was last modified: 23-08-2014, 02:53 PM by juanpintom.)
#18
RE: Display TM1638 Library Integration (HUD Racing)
Hi regis Smile

I saw this void function before, here is the original one:
https://code.google.com/p/tm1638-library...TM16XX.cpp
Code:
#if !defined(ARDUINO) || ARDUINO < 100
// empty implementation instead of pure virtual for older Arduino IDE
void TM16XX::sendChar(byte pos, byte data, boolean dot) {}
#endif

In file TM1638.cpp it calls to :
Code:
void TM1638::sendChar(byte pos, byte data, boolean dot)
{
        sendData(pos << 1, data | (dot ? 0b10000000 : 0));
}

So I added this to TM16XX.c too:
Code:
void TM16XX_sendChar(char pos, char data, char dot) {
    TM16XX_sendData(pos << 1, data | (dot ? 0b10000000 : 0));
}

Anyway if tried to load a sketch with inverted TM16XX_clearDisplay and isn't works. TM16XX_sendData(i << 1, 0) changed for TM16XX_sendData(i << 1, 1) to power up all leds.

Code:
void TM16XX_clearDisplay()
{
  int i;
  for (i = 0; i < displays; i++) {
    TM16XX_sendData(i << 1, 1);
  }
}

Example used:
Code:
#include "TM16XX.c"

void setup() {
// define a module on data pin 8, clock pin 9 and strobe pin 7
    TM16XX_init(5, 6, 7, 8, 1, 7);

    TM16XX_clearDisplay();
}

void loop() {
}

Nothing happens Sad

(23-08-2014, 01:02 PM)pingotg Wrote: I saw this:

void TM16XX_init(char dataPin, char clockPin, char strobePin, char displays, char activateDisplay, char intensity)
{
int i;
//this->dataPin = dataPin;
dataPin = dataPin;
(etc)

The C++ one that's commented out was setting the members of the object (this) to the values passed in. The new code does nothing.

I'm not sure what you need instead but doing nothing is unlikely to be it Smile

John

Hi! I commented this-> because I get errors on compile, now it's like this:

Code:
/*this->dataPin = dataPin;
  dataPin = dataPin;
  clockPin = clockPin;
  strobePin = strobePin;
  displays = displays;*/


Attached Files
.c   TM16XX.c (Size: 4.11 KB / Downloads: 2)
.h   TM16XX.h (Size: 6.31 KB / Downloads: 1)
Reply
23-08-2014, 05:26 PM,
#19
RE: Display TM1638 Library Integration (HUD Racing)
In your program there are local and global variables.
I didn't pay attention to it but John is right, you must rename your global variables.
For example rename dataPin as TM16XX_dataPin.
So :

void TM16XX_init(char dataPin, char clockPin, char strobePin, char displays, char activateDisplay, char intensity)
{
int i;
//this->dataPin = dataPin;
dataPin = dataPin;
(etc)

becomes :

void TM16XX_init(char dataPin, char clockPin, char strobePin, char displays, char activateDisplay, char intensity)
{
int i;
//this->dataPin = dataPin;
TM16XX_dataPin = dataPin;
(etc)

Do the same for all global variables. They are (see your .h) :
char displays;
char dataPin;
char clockPin;
char strobePin;
char activateDisplay;
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
23-08-2014, 06:41 PM,
#20
RE: Display TM1638 Library Integration (HUD Racing)
GOOD NEWS!! Big Grin

First sketch working =)

Code:
#include "TM16XX.c"
void setup() {

// define a module on data pin 5, clock pin 6 and strobe pin 7
    TM16XX_init(5, 6, 7, 8, 1, 7);

    TM16XX_setDisplayToError();
}

void loop() {
}

Files added.


Attached Files
.c   TM16XX.c (Size: 4.27 KB / Downloads: 1)
.h   TM16XX.h (Size: 6.34 KB / Downloads: 1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)