Skip to content

Commit

Permalink
Adjust some ESPR_NO_X defines so that we can define SAVE_ON_FLASH but…
Browse files Browse the repository at this point in the history
… also ESPR_NO_PROMISES=0 to force promises to be included
  • Loading branch information
gfwilliams committed Oct 25, 2023
1 parent 5be6ef3 commit d9a56c2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions README_BuildProcess.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ This is a partial list of definitions that can be added in a `BOARD.py` file's `
* `ESPR_PBF_FONTS` - Enable support for loading and displaying Pebble-style PBF font files with `g.setFontPBF`
* `ESPR_BLUETOOTH_ANCS` - Enable Apple ANCS(notification), AMS and CTS support
* `ESPR_NO_SOFTWARE_SERIAL` - don't build in software serial support
* `ESPR_NO_SOFTWARE_I2C` - don't build in software I2C support
* `ESPR_NO_BLUETOOTH_MESSAGES` - don't include text versions of Bluetooth error messages (just the error number)

These are set automatically when `SAVE_ON_FLASH` is set (see `jsutils.h`)
Expand Down
10 changes: 5 additions & 5 deletions libs/bluetooth/jswrap_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------

#ifndef ESPR_NO_PROMISES
#if ESPR_NO_PROMISES!=1
JsVar *blePromise = 0;
#endif
JsVar *bleTaskInfo = 0;
Expand Down Expand Up @@ -104,7 +104,7 @@ bool bleNewTask(BleTask task, JsVar *taskInfo) {
jsiConsolePrintf("Existing bleTaskInfo!\n");
jsvTrace(bleTaskInfo,2);
}*/
#ifndef ESPR_NO_PROMISES
#if ESPR_NO_PROMISES!=1
assert(!blePromise && !bleTaskInfo && !bleTaskInfo2);
blePromise = jspromise_create();
#endif
Expand All @@ -121,7 +121,7 @@ void bleCompleteTask(BleTask task, bool ok, JsVar *data) {
return;
}
bleTask = BLETASK_NONE;
#ifndef ESPR_NO_PROMISES
#if ESPR_NO_PROMISES!=1
if (blePromise) {
if (ok) jspromise_resolve(blePromise, data);
else jspromise_reject(blePromise, data);
Expand Down Expand Up @@ -282,7 +282,7 @@ void jswrap_ble_kill() {
#endif
// stop any BLE tasks
bleTask = BLETASK_NONE;
#ifndef ESPR_NO_PROMISES
#if ESPR_NO_PROMISES!=1
if (blePromise) jsvUnLock(blePromise);
blePromise = 0;
#endif
Expand Down Expand Up @@ -3740,7 +3740,7 @@ JsVar *jswrap_ble_getSecurityStatus(JsVar *parent) {
}
*/
JsVar *jswrap_ble_startBonding(bool forceRePair) {
#ifdef NRF52_SERIES
#if CENTRAL_LINK_COUNT>0
if (bleNewTask(BLETASK_BONDING, NULL)) {
JsVar *promise = jsvLockAgainSafe(blePromise);
jsble_startBonding(forceRePair);
Expand Down
4 changes: 2 additions & 2 deletions src/jsi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool jsi2cPopulateI2CInfo(
return false;
}

#ifndef SAVE_ON_FLASH
#if ESPR_NO_SOFTWARE_I2C!=1

// Do we check to see if we got a NACK or not?
// Some devices (like Bangle.js IO controller) don't ever ACK
Expand Down Expand Up @@ -218,4 +218,4 @@ bool jsi2cRead(JshI2CInfo *inf, unsigned char address, int nBytes, unsigned char
return true;
}

#endif // SAVE_ON_FLASH
#endif // ESPR_NO_SOFT_I2C
2 changes: 2 additions & 0 deletions src/jsi2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ bool jsi2cPopulateI2CInfo(
JsVar *options
);

#if ESPR_NO_SOFTWARE_I2C!=1
void jsi2cSetup(JshI2CInfo *inf);
void jsi2cUnsetup(JshI2CInfo *inf); ///< turn off I2C (remove pullups/sense)
bool jsi2cWrite(JshI2CInfo *inf, unsigned char address, int nBytes, const unsigned char *data, bool sendStop);
bool jsi2cRead(JshI2CInfo *inf, unsigned char address, int nBytes, unsigned char *data, bool sendStop);
#endif // ESPR_NO_SOFT_I2C

#endif // JSI2C_H_
7 changes: 6 additions & 1 deletion src/jsutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@
#define ESPR_NO_GET_SET 1
#define ESPR_NO_LINE_NUMBERS 1
#define ESPR_NO_LET_SCOPING 1
#define ESPR_NO_PROMISES 1
#ifndef ESPR_NO_PROMISES
#define ESPR_NO_PROMISES 1
#endif
#define ESPR_NO_CLASSES 1
#define ESPR_NO_ARROW_FN 1
#define ESPR_NO_REGEX 1
#define ESPR_NO_TEMPLATE_LITERAL 1
#define ESPR_NO_SOFTWARE_SERIAL 1
#ifndef ESPR_NO_SOFTWARE_I2C
#define ESPR_NO_SOFTWARE_I2C 1
#endif
#endif
#ifdef SAVE_ON_FLASH_EXTREME
#define ESPR_NO_BLUETOOTH_MESSAGES 1
Expand Down
2 changes: 1 addition & 1 deletion src/jswrap_promise.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "jsutils.h"

#ifndef ESPR_NO_PROMISES
#if ESPR_NO_PROMISES!=1

#include "jswrap_promise.h"
#include "jsparse.h"
Expand Down
2 changes: 1 addition & 1 deletion src/jswrap_promise.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "jsvar.h"
#include "jsutils.h"

#ifndef ESPR_NO_PROMISES
#if ESPR_NO_PROMISES!=1

/// Create a new promise
JsVar *jspromise_create();
Expand Down

0 comments on commit d9a56c2

Please sign in to comment.