Need help converting X10 Firecracker code

Huge Spark Core fan here! Absolutely love this device.

I have an X10 Firecracker, and I’m trying to upload some sample code, but I’m getting a bunch of errors related to PROGMEM and pgm_read_word_near

…I’m getting errors about these data types and functions being undefined.

Here’s a link to the .h file:

and to the CPP file:

Any ideas how I can get this code to work with Spark?

Thanks!

osmosis311, first you need to add #include "application.h" at the top of the .h file. You also don’t need the #include <stdint.h> so you can comment it out.

In the .cpp file, comment out:

#include <avr/pgmspace.h>
#include "Arduino.h"

and add:

#define prog_uint16_t  uint16_t
#define PROGMEM

Let me know how it goes after that. :smile:

Thank you! Just made the changes, getting the following errors:

In file included from …/inc/spark_wiring.h:30:0,
from …/inc/application.h:31,
from X10Firecracker.h:6,
from X10Firecracker.cpp:26:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
X10Firecracker.cpp: In member function ‘void X10Firecracker::sendCmd(HouseCode, int, CommandCode)’:
X10Firecracker.cpp:109:59: error: ‘pgm_read_word_near’ was not declared in this scope
X10Firecracker.cpp:113:54: error: ‘pgm_read_word_near’ was not declared in this scope
make: *** [X10Firecracker.o] Error 1

osmosis311, remove those two #defines from the .cpp file and add these to the .h file after the #include “application.h”:

#define PROGMEM
#define prog_uint16_t   uint16_t
#define pgm_read_word_near(x)   ((uint16_t)*(x))

That should work :smile:

Working perfectly! Thank you VERY much!!! :smile:

No problemo osmosis311! Now I gots to get me some sleep :wink: