PetitFS library will not compile, byte errors

Ok I’m trying to use a couple functions in my display file that uses the petitfatfs but when ever I try to compile a sketch that has the petitfatfs library included I get errors about the Byte definitions in the Pff files.

If I try to compile the OG sketch by itself I still get the same errors. Could I get some help figuring this out

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:45:14: error: expected unqualified-id before numeric constant

 #define BYTE 0

              ^

C:\Users\duhjoker\Documents\Arduino\libraries\petit_fatfs/integer.h:18:23: note: in expansion of macro 'BYTE'

 typedef unsigned char BYTE;

                       ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:45:14: error: expected unqualified-id before numeric constant

 #define BYTE 0

              ^

C:\Users\duhjoker\Documents\Arduino\libraries\petit_fatfs/pff.h:67:2: note: in expansion of macro 'BYTE'

  BYTE fs_type; /* FAT sub type */

  ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:45:14: error: expected unqualified-id before numeric constant

 #define BYTE 0

              ^

C:\Users\duhjoker\Documents\Arduino\libraries\petit_fatfs/pff.h:68:2: note: in expansion of macro 'BYTE'

  BYTE csize;  /* Number of sectors per cluster */

  ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:45:14: error: expected unqualified-id before numeric constant

 #define BYTE 0

              ^

C:\Users\duhjoker\Documents\Arduino\libraries\petit_fatfs/pff.h:69:2: note: in expansion of macro 'BYTE'

  BYTE flag;  /* File status flags */

  ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:45:14: error: expected unqualified-id before numeric constant

 #define BYTE 0

              ^

C:\Users\duhjoker\Documents\Arduino\libraries\petit_fatfs/pff.h:70:2: note: in expansion of macro 'BYTE'

  BYTE csect;  /* File sector address in the cluster */

  ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:45:14: error: expected unqualified-id before numeric constant

 #define BYTE 0

              ^

C:\Users\duhjoker\Documents\Arduino\libraries\petit_fatfs/pff.h:72:2: note: in expansion of macro 'BYTE'

  BYTE* buf;  /* Pointer to the disk access buffer */

  ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:45:14: error: expected unqualified-id before numeric constant

 #define BYTE 0

              ^

C:\Users\duhjoker\Documents\Arduino\libraries\petit_fatfs/pff.h:90:2: note: in expansion of macro 'BYTE'

  BYTE* fn;   /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */

  ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Print.h:45:14: error: expected unqualified-id before numeric constant

 #define BYTE 0

              ^

C:\Users\duhjoker\Documents\Arduino\libraries\petit_fatfs/pff.h:104:2: note: in expansion of macro 'BYTE'

  BYTE fattrib; /* Attribute */

  ^

drawBitmapFromSd.ino (37.9 KB)

Ok the problem is in my teensy's AVR. The print.h file has an extra definition of #define byte that the arduino version does not.

How should I handle that? Do I mark it out do I need to change something in the example?

I guess the first part would be to get the function working. I noticed the command uses byte instead of int_8, can these be changed to int8_t.

Why does the draw from SD command have the INT in front of it instead of void?

You are asking questions about a non-standard library that few people have. If you posted a link to the library, the chances that you are just talking to yourself would go way down.

Ok I guess some one was just putting me on. I was told the petitfatfs was a common arduino library. Oh well…

Here a link to the library on github…

The attachment at the top called drawbutmapfromSd has the example that I’m trying to add to my display library.

edit:::::
I thonk I may have most of it figured out but I keep getting these errors about two lines the functions need to be able use the petitfatfs library,

// Following two functions are needed by petit_fatfs
byte rx() { SPDR = 0xFF; loop_until_bit_is_set(SPSR, SPIF); return SPDR; }
void tx(byte d) { SPDR = d; loop_until_bit_is_set(SPSR, SPIF); }

C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoduhjokercolorMAIN1\DisplayRGB.cpp: In function ‘byte rx()’:

C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoduhjokercolorMAIN1\DisplayRGB.cpp:52:58: error: ‘loop_until_bit_is_set’ was not declared in this scope

byte rx() { SPDR = 0xFF; loop_until_bit_is_set(SPSR, SPIF); return SPDR; }

^

C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoduhjokercolorMAIN1\DisplayRGB.cpp: In function ‘void tx(byte)’:

C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoduhjokercolorMAIN1\DisplayRGB.cpp:53:61: error: ‘loop_until_bit_is_set’ was not declared in this scope

void tx(byte d) { SPDR = d; loop_until_bit_is_set(SPSR, SPIF); }

the error was about the loop until stuff, I think its a comment but domt know how to proceed. I nalso looked at the petifatfs library and could not find another mention of those functions.

Here a link to the library on github…

No. HERE is a link:
https://github.com/greiman/PetitFS

See the difference? You could have done that, too.

The attachment at the top called drawbutmapfromSd has the example that I’m trying to add to my display library.

I’m not sure that I want to know what a butmap is…

I think its a comment

Why would you think that?

// Comments look like this or
/* they can look like this */

The link above does NOT have a file with this name:

#include <petit_fatfs.h>

I'm grasping at straws here man. Excuse my spelling! I know what comments look like but I can't find any reference to the command "loop until set" or its variables spsr and spif. How about a lil help figuring it out instead of telling someone they are wrong all the time?

Wasn't trying to be rude but dude!!! Cut me some slack you know I'm still learning.

Ok so my dumb@$$ didn't know that I needed to include a couple more files to get the petitfatfs to work. Which also solved my TX RX loop dilemma.

Now my major snag is the byte declarations in the code and the library. The new SD functions use byte instead of int and uint. So now it's got my teensy's print.h and the petitfatfs librarys are fighting each other.

So my teensy's print has an extra define in it called #define BYTE 0 and it's messing with the petitfatfs files. I can comment out the byte def in my print.h but I'm not sure if that will allow every thing to work.

What would be the best way to handle that with out changing core code for the hardware.

I can comment out the byte def in my print.h but I'm not sure if that will allow every thing to work.

Why not try it and see?

Ok so I commented out the #define BYTE 0 line in the print.h so that fixed that. But I need a way to correct it from inside my library I will have to include a version of teensy's 3.2 print.h and .cpp with the Byte define commented out.

Is there another way I could fix that? I've tried this in my display libraries .cpp where the functions that use it are

#define bin 2
#undef BYTE
#define BYTE 0

I've also tried #undef BYTE before

Typedef unsigned char BYTE

In integer.h but still no good.

But I need a way to correct it from inside my library I will have to include a version of teensy's 3.2 print.h and .cpp with the Byte define commented out.

Yes, you will. I don't see what the problem is. The initial problem was that there were duplication definitions of BYTE. Now there there is only one, what is the problem?

The problem is trying to get this done with out the user having to make modifications to thier libraries in order to get started. I want the library to be drop in and go and with out extra files included to make it work.