Can I Use a .h File in Spin2 Program Compiled by FlexProp?
JonnyMac
Posts: 9,159
I have a .h file with image data in it that I want to use in native Spin2. While I can manually convert the C-style hex data to Spin-style hex data, it gets a little tedious. Is it possible to include a .h file in a Spin2 program that is compiled by FlexProp? If yes, I can write a translator program that prints out a native Spin2 data listing form the .h and it will work in Propeller Tool and FlexProp.
Comments
Unfortunately not in a useful way. Just
#include
would not work because the syntax inside the file is C instead of Spin2. You could include it with an OBJ declaration, but actually getting at the data is problematic -- you can only reference functions (methods) in the object.My suggestion would be to write a little C wrapper like:
This may either be compiled to run on your PC with your C compiler of choice, or else compiled & run on the P2 with FlexProp.
Thanks, Eric. This is a partial version of one of the small files
PROGMEM is an Arduino thing, so it will need to be removed (I believe).
The first four bytes define the font width (pixels), height (pixels), starting character, number of characters in set. I want to make a utility that will format it like this:
Other that formatting, I want to change the last byte of the first line to the last legal character -- no need to do that math in the character drawing routine.
Ah... well, if you want to keep most of the formatting and comments, I guess you'll pretty much have to work with the original text, rather than trying to compile the data into bytes. I can see a few options:
(1) Doing it in an editor via search & replace or macros. Depending on your editor this might be the easiest option.
(2) Doing it programatically on a PC. I'd probably choose a text processing language like awk or perl for that. I'm not sure what languages you're comfortable with?
(3) You had mentioned writing in Spin2... if so, you could use something like
FILE "fontdata.h"
to include the original text of the .h file, and then walk through the ASCII bytes in memory, outputtiing suitably modified versions of the text to serial, which then gets captured on the PC.That's for binary files -- these are plain text.
Yep -- this is the approach I've done so far and will continue. Some of the line are really long, and I want to turn them into multiple lines. It gets tedious for large characters
FILE "fontdata.h" will include "fontdata.h" as a binary file, so it will have all of the ASCII characters of the file in it. That is, if the file starts
the binary wil have the bytes "f", "o", "n", "t", and so on. Which means you have to parse it to get the binary data; but it sounds like you actually want the text data, if you want to output comments and so on.
I see what you mean.