Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with loop For
28-03-2013, 05:49 AM,
#1
Problem with loop For
Hello,

My first post here, so excuse-me if it is in wrong area.

I'm trying to port code from arduino to pinguino, but without success.

The code is to control a sound module (WTV020-SD-16P) with simple commands.

The code is attached and when I try to compile with pinguino it says that an error during compilations happens.

The problem seems to be on function SendCommand (between lines 54 and 78) and the file Wtv020sd16p.h, because if these are commenteds is possible to compile the code.

Any ideas?

Thanks in advance and sorry for my bad english (I'm from Brasil).

Regards.


Attached Files
.zip   Wtv020sd16p.zip (Size: 1.15 KB / Downloads: 19)
Reply
29-03-2013, 11:13 AM,
#2
RE: Problem with loop For
Hi,
As far as I can see, this is more a C problem than a Pinguino problem.

1- Wtv020sd16p.h defines a C++ class, you should use only C like this :
Code:
#ifndef Wtv020sd16p_h
#define Wtv020sd16p_h

  Wtv020sd16p(int resetPin,int clockPin,int dataPin,int busyPin);
  void reset();
  void playVoice(int voiceNumber);
  void asyncPlayVoice(int voiceNumber);
  void stopVoice();
  void pauseVoice();
  void mute();
  void unmute();
  void sendCommand(unsigned int command);
  int _resetPin;
  int _clockPin;
  int _dataPin;
  int _busyPin;
  int _busyPinState;

#endif

2- in void setup(), you call resetModule() which is defined after your call. You should prototype your functions before. This is actually what Wtv020sd16p.h is done for so just add void resetModule(); in your header file.

3- With SDCC, you can't write :
Code:
for (unsigned int mask = 0x8000; mask > 0; mask >>= 1)
{
}
You should write this instead :
Code:
unsigned int mask;
for (mask = 0x8000; mask > 0; mask >>= 1)
{
}

4- I can't see all functions defined in Wtv020sd16p.h in your code ...

Good luck.


(28-03-2013, 05:49 AM)plautz Wrote: Hello,

My first post here, so excuse-me if it is in wrong area.

I'm trying to port code from arduino to pinguino, but without success.

The code is to control a sound module (WTV020-SD-16P) with simple commands.

The code is attached and when I try to compile with pinguino it says that an error during compilations happens.

The problem seems to be on function SendCommand (between lines 54 and 78) and the file Wtv020sd16p.h, because if these are commenteds is possible to compile the code.

Any ideas?

Thanks in advance and sorry for my bad english (I'm from Brasil).

Regards.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
29-03-2013, 02:17 PM,
#3
RE: Problem with loop For
(29-03-2013, 11:13 AM)regis Wrote: Hi,

Hi Regis,

Thanks for helping.

I'm really a bad programmer. In fact, I barelly understand C or C++. Yes, I have to study a lot yet!

I will respond point 1 later.

Quote:2- in void setup(), you call resetModule() which is defined after your call. You should prototype your functions before. This is actually what Wtv020sd16p.h is done for so just add void resetModule(); in your header file.

Done this, and thanks for tip about prototyping functions.

Quote:3- With SDCC, you can't write :
Code:
for (unsigned int mask = 0x8000; mask > 0; mask >>= 1)
{
}
You should write this instead :
Code:
unsigned int mask;
for (mask = 0x8000; mask > 0; mask >>= 1)
{
}

I take your advice and paste these contents in header file:

Code:
#ifndef Wtv020sd16p_h
#define Wtv020sd16p_h

  Wtv020sd16p(int resetPin,int clockPin,int dataPin,int busyPin);
  void reset();
  void playVoice(int voiceNumber);
  void asyncPlayVoice(int voiceNumber);
  void stopVoice();
  void pauseVoice();
  void mute();
  void unmute();
  void sendCommand(unsigned int command);
  int _resetPin;
  int _clockPin;
  int _dataPin;
  int _busyPin;
  int _busyPinState;

#endif

After that, I modified the pde file with your tip on mask function. Again, when I try to compile, the result is that some error still persist.

If I comment the include at begin of pde file (#include <Wtv020sd16p.h>) and the mask function (between lines 70 and 95), I can compile but, if one of these are uncommented, then no hex is compiled.

Quote:4- I can't see all functions defined in Wtv020sd16p.h in your code ...

My fail.

At the time I posted my question I was very tired.

Attached is my new code (Wtv020sd16p - pinguino.zip) and the original code for arduino (Wtv020sd16p - arduino.zip) just for comparision.

Quote:Good luck.

Sorry for so many questions, and thanks a lot for your tips.

Regards.


Attached Files
.zip   Wtv020sd16p - pinguino.zip (Size: 1.1 KB / Downloads: 5)
.zip   Wtv020sd16p - arduino.zip (Size: 3.98 KB / Downloads: 13)
Reply
20-05-2013, 09:53 AM, (This post was last modified: 20-05-2013, 09:57 AM by latcakir.)
#4
RE: Problem with loop For
(28-03-2013, 05:49 AM)plautz Wrote: Hello,

My first post here, so excuse-me if it is in wrong area.

I'm trying to port code from arduino to pinguino, but without success.

The code is to control a sound module (WTV020-SD-16P) with simple commands.

The code is attached and when I try to compile with pinguino it says that an error during compilations happens.

The problem seems to be on function SendCommand (between lines 54 and 78) and the file Wtv020sd16p.h, because if these are commenteds is possible to compile the code.

Any ideas?

Thanks in advance and sorry for my bad english (I'm from Brasil).

Regards.


Open the file in Wtv020sd16p.zip
WTV20SDBreakout \ examples \ Wtv020sd16pExample \ Wtv020sd16pExample.ino file.
Replace the parts as Wtv020sd16p.h WTV20SDBreakout.h. use CTRL + F for it.

Changed file is attached.


Attached Files
.zip   Wtv020sd16pExample.zip (Size: 736 bytes / Downloads: 7)
Reply
21-05-2013, 09:24 PM,
#5
RE: Problem with loop For
(20-05-2013, 09:53 AM)latcakir Wrote: Open the file in Wtv020sd16p.zip
WTV20SDBreakout \ examples \ Wtv020sd16pExample \ Wtv020sd16pExample.ino file.
Replace the parts as Wtv020sd16p.h WTV20SDBreakout.h. use CTRL + F for it.

Changed file is attached.

Hello Latcakir,

Thanks for your help.

I don't see any differences between the file you attached and the one I put in my first post.

Also, I tried to do as you said ("Replace the parts as Wtv020sd16p.h WTV20SDBreakout.h") but without success.

Regards.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)