Have you had a look if the MPL3115A2 library is compatible with your sensor?
It’s also available on Particle Build
But a quick browse through your repo seemed OK.
Just out of curiosity, why have you decided to change the static functions into non-static? Did the Particle Wire
class not play well with static
?
One thing you might want to consider for future ports is, that you could keep the original Arduino functionality and just add the Particle specifics by use of conditional compiling (#ifdef .. #endif
).
e.g.
#if defined(SPARK)
#include "application.h"
#else
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Wire.h>
#endif
...
static uint8_t i2cread(void) {
uint8_t x;
#if (ARDUINO >= 100) || defined(SPARK)
x = Wire.read();
#else
x = Wire.receive();
#endif
//Serial.print("0x"); Serial.println(x, HEX);
return x;
}