Notes for whoever comes next…
The Photon can be power hungry compared to the simpler 'duinos (just an observation, not necessarily a problem…) - while a 9v battery can power a 'duino for a 6-12 hour hack-as-you-travel experience, the Photon with active WiFi and an external 7805 vreg combine to suck it down to useless in less than an hour. Symptoms of “not enough juice” are failure to OTA upload sketches, not getting out of reset to run a sketch, and other flakey behaviors. I have an 8x8 MAX7219 LED matrix that runs fine on a Leonardo for hours, but won’t even initialize on a Photon with 9v battery power alone. Plugged into my bench supply instead and everyone is now happy!
Include “application.h” instead of “Arduino.h” in any self-provided library/class header files (but this may change in the future says @bko)
Don’t include Wiring.h, its effective content gets autoincluded in your main sketch, and by application.h elsewhere
You will probably need to clean up your old 'duino code:
- int’s that you assumed were 16 bits need to be int_16’s instead,
- unsigned’s become uint_16’s…
- int’s are 32 bits now
- Arduino’s boolean can be spelled ‘bool’ if the predefined type isn’t working for you (it worked for me after including application.h)
You need to self-define the bitRead/bitWrite routines (and see above for code cleanup if int-size assumptions may impact your code):
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
The predefined names for the DAC and WKP pins are A6 and A7, not DAC1 and WKP as implied
EDIT: CLOCK_SPEED_100KHZ is not defined as claimed by the firmware docs:
- clockSpeed: CLOCK_SPEED_100KHZ, CLOCK_SPEED_400KHZ or user specified speeds.
(code verifies, but does not link:
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privatestledmatrix.cpp: In function ‘void setup()’:
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privatestledmatrix.cpp:91:19: error: ‘CLOCK_SPEED_100KHZ’ was not declared in this scope)
I’ll re-edit this post to add more info as I learn - thanks to all who jumped in to help!