Show Posts
Pages: 1 ... 4 5 [6] 7 8 ... 10
76  Using Arduino / Programming Questions / Re: library definition on: January 12, 2012, 10:38:53 am
I think it worked!!!!
You are a genius!!!
Definitely owe you a beer smiley
I'll make some more tests later, gotta go to a meeting atm.
Thank you so much!!!

RI
77  Using Arduino / Programming Questions / Re: library definition on: January 11, 2012, 01:25:11 pm
I tried your code, but it didn't print "Test".
78  Using Arduino / Programming Questions / Re: library definition on: January 11, 2012, 12:16:30 pm
In this example, all I wanted to do was to print "Test" if TESTING was defined on either the PDE or in a header file in the same folder as the PDE file:
Code:
#ifdef TESTING
Serial.println("Test");
#endif

I tried what you recommended and my code turned out to be:
Code:
byte r;
#define TESTING
#include "TestClass.h"

TestClass  t;

void setup()
{
  Serial.begin(57600);
  Serial.println("Start");
  t.TestFunction();
  Serial.println("End");
}

void loop()
{
}

But it still does not run what's indide the ifdef smiley-sad
79  Using Arduino / Programming Questions / Re: library definition on: January 11, 2012, 10:53:17 am
Doesn't work.
Here is what I have.
Well, it's pde cause I'm still using 0022
TestClass.pde:
Code:

#define TESTING
#include "TestClass.h"

TestClass  t;

void setup()
{
  Serial.begin(57600);
  Serial.println("Start");
  t.TestFunction();
  Serial.println("End");
}

void loop()
{
}


TestClass.h
Code:
#ifndef __TESTCLASS_H__
#define __TESTCLASS_H__

#include <TestClass.h>

class TestClass
{
public:
TestClass();
void TestFunction();
};

#endif  // __TESTCLASS_H__

TestClass.cpp
Code:
#include "TestClass.h"

TestClass::TestClass()
{
}

void TestClass::TestFunction()
{
#ifdef TESTING
Serial.println("Test");
#endif
}

When I comment or uncomment the define on the PDE file, I get no change on the compiled code.
I tried adding new file on the same folder as the PDE called TestH.h:
Code:
#define TESTING

It still does not do anything.

Any other ideas?
80  Using Arduino / Programming Questions / library definition on: January 11, 2012, 01:03:48 am
Hi,

If I have something like this on my custom library:
Code:
void TestClass::TestFunction()
{
// Doing Something
#ifdef TESTING
// Do something else
#endif
// Continue doing something
}
Which are the places I could define TESTING, besides TestClass.h or TestClass.cpp?
Could I use a separate .h file on the same folder as INO file?
Could I define somehow inside the INO file?

Thank you,
RI
81  Using Arduino / Programming Questions / Re: PROGMEM and Serial on: January 08, 2012, 11:47:45 am
Code:
#define MyTestVar F("Test")

void setup()
{
  Serial.begin(57600);
  Serial.print(MyTestVar);

}

void loop()
{
}
Binary sketch size: 1914 bytes (of a 32256 byte maximum)

Code:
const prog_char MyTestVar[] PROGMEM = "Test";

void setup()
{
  Serial.begin(57600);
  PROGMEMprint(MyTestVar);
}

void loop()
{
}

void PROGMEMprint(const prog_char str[])
{
    char c;
    if(!str) return;
    while((c = pgm_read_byte(str++)))
        Serial.write(c);
}
Binary sketch size: 1868 bytes (of a 32256 byte maximum)


Maybe I'm doing something wrong.
82  Using Arduino / Programming Questions / Re: PROGMEM and Serial on: January 08, 2012, 11:14:07 am
Well, I don't really understand much the difference of the two you mentioned, but actually the PROGMEM code is the one that was smaller not the F().
The end result is the same for both. I wanted to print from flash and they both do that, right?
So, you seem to understand it much more than me. Which is the best approach?
83  Using Arduino / Programming Questions / Re: PROGMEM and Serial on: January 08, 2012, 10:47:28 am
Flash is PROGMEM.

Well, I know that much smiley
 I've been using this for quite a while:
Code:
void PROGMEMprint(const prog_char str[])
{
    char c;
    if(!str) return;
    while((c = pgm_read_byte(str++)))
        Serial.write(c);
}

The reason I wanted to know about the F() printing PROGMEM arrays too is that my code has several PROGMEM variables defined on my custom library header file that I can use on any of my other library files.
So, my questions now is:
Instead of using this:
Code:
const prog_char MyTestVar[] PROGMEM = "Test";
PROGMEMprint(MyTestVar);
If I started using this:
Code:
#define MyTestVar F("Test")
Serial.print(MyTestVar);
Which one is the best alternative, keeping in mind that I have code size issues?
I did a simple run test and the PROGMEM route used less code size.
84  Using Arduino / Programming Questions / Re: PROGMEM and Serial on: January 07, 2012, 08:51:50 pm
http://arduino.cc/en/Main/ReleaseNotes
But I can't find within any library file where it is referenced.
I wanted to peek and see what it actually does, but I was unable to find it.
85  Using Arduino / Programming Questions / PROGMEM and Serial on: January 07, 2012, 07:23:28 pm
Hi,

With the new F() function, I can see how easy it would be to print from Flash without using PROGMEM.
How can I use this function to print a progmem array too?

Thank you,
RI
86  Using Arduino / Programming Questions / Re: PROGMEM problem on: October 22, 2011, 11:29:06 am
Ah-ha!!!
I think you nailed!!!
I don't have any board to test, but I'm pretty sure this is the issue.
Thanks a lot!!
87  Using Arduino / Programming Questions / Re: PROGMEM problem on: October 22, 2011, 10:29:14 am
Nor can I upload it to my Mega2560:

Code:
Binary sketch size: 27010 bytes (of a 258048 byte maximum)
avrdude: verification error, first mismatch at byte 0x0483
         0x9e != 0xff
avrdude: verification error; content mismatch
Thanks for the explanation, but even with very little program size, it still has issues.
The total size of the sketch is 27010, which is below the 64K you mentioned.
Does what you stated still apply even though the size is less than 64K?
88  Using Arduino / Programming Questions / Re: PROGMEM problem on: October 21, 2011, 09:59:58 pm
So, do you think something in the array is causing a hiccup on avrdude?
89  Using Arduino / Programming Questions / Re: PROGMEM problem on: October 21, 2011, 08:00:36 pm
Ok, so here is what else I found out.
This issue only happens on the ATMEGA2560.
I loaded the code on a Duemilanove w/ optiboot and the code works just fine...
Weird... smiley-fat
I can't paste the code, but I attached this time.
90  Using Arduino / Programming Questions / Re: PROGMEM problem on: October 21, 2011, 07:35:46 pm
the array in 24095 in size does not work smiley-sad
Pages: 1 ... 4 5 [6] 7 8 ... 10