From d9a56c2977888005a52d5462fd0f06d0cf141f5c Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 25 Oct 2023 12:14:28 +0100 Subject: [PATCH] Adjust some ESPR_NO_X defines so that we can define SAVE_ON_FLASH but also ESPR_NO_PROMISES=0 to force promises to be included --- README_BuildProcess.md | 1 + libs/bluetooth/jswrap_bluetooth.c | 10 +++++----- src/jsi2c.c | 4 ++-- src/jsi2c.h | 2 ++ src/jsutils.h | 7 ++++++- src/jswrap_promise.c | 2 +- src/jswrap_promise.h | 2 +- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README_BuildProcess.md b/README_BuildProcess.md index 0632c531a8..1cfcc7b217 100644 --- a/README_BuildProcess.md +++ b/README_BuildProcess.md @@ -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`) diff --git a/libs/bluetooth/jswrap_bluetooth.c b/libs/bluetooth/jswrap_bluetooth.c index dcf364339f..2ed672d66f 100644 --- a/libs/bluetooth/jswrap_bluetooth.c +++ b/libs/bluetooth/jswrap_bluetooth.c @@ -60,7 +60,7 @@ // ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------ -#ifndef ESPR_NO_PROMISES +#if ESPR_NO_PROMISES!=1 JsVar *blePromise = 0; #endif JsVar *bleTaskInfo = 0; @@ -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 @@ -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); @@ -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 @@ -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); diff --git a/src/jsi2c.c b/src/jsi2c.c index ba97a95c4c..f3dd2ca539 100644 --- a/src/jsi2c.c +++ b/src/jsi2c.c @@ -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 @@ -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 diff --git a/src/jsi2c.h b/src/jsi2c.h index b576406739..822492281f 100644 --- a/src/jsi2c.h +++ b/src/jsi2c.h @@ -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_ diff --git a/src/jsutils.h b/src/jsutils.h index 5352888d33..682905d942 100755 --- a/src/jsutils.h +++ b/src/jsutils.h @@ -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 diff --git a/src/jswrap_promise.c b/src/jswrap_promise.c index e60c0312f3..aa3ce23c83 100644 --- a/src/jswrap_promise.c +++ b/src/jswrap_promise.c @@ -16,7 +16,7 @@ #include "jsutils.h" -#ifndef ESPR_NO_PROMISES +#if ESPR_NO_PROMISES!=1 #include "jswrap_promise.h" #include "jsparse.h" diff --git a/src/jswrap_promise.h b/src/jswrap_promise.h index 7d31aa6177..b855f33b09 100644 --- a/src/jswrap_promise.h +++ b/src/jswrap_promise.h @@ -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();