Skip to content

Commit

Permalink
Minor cleanup of config flags.
Browse files Browse the repository at this point in the history
Changing #if xxx == 1 to CONFIG_ENABLED, and moving a couple of
flags to MicroBitConfig.h
  • Loading branch information
microbit-carlos committed Aug 8, 2023
1 parent 4f2aedc commit 5201d1b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
4 changes: 2 additions & 2 deletions inc/MicroBitCompass.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/

#ifndef MICROBIT_COMPASS
#define MICROBIT_COMPASS
#ifndef MICROBIT_COMPASS_H
#define MICROBIT_COMPASS_H

#include "MicroBitConfig.h"
#include "MicroBitComponent.h"
Expand Down
16 changes: 15 additions & 1 deletion inc/MicroBitConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
#endif

// Configure for open BLE operation if so configured
#if (MICROBIT_BLE_OPEN == 1)
#if CONFIG_ENABLED(MICROBIT_BLE_OPEN)
#define MICROBIT_BLE_SECURITY_MODE 1
#define MICROBIT_BLE_WHITELIST 0
#define MICROBIT_BLE_ADVERTISING_TIMEOUT 0
Expand Down Expand Up @@ -292,3 +292,17 @@
#endif

#endif

// Defines default behaviour of triple-tap-reset-to-pair feature.
// 0: Feature disabled
// 1: Feature enabled. Triple tap of reset button enters Bluetooth pairing mode.
#ifndef MICROBIT_TRIPLE_RESET_TO_PAIR
#define MICROBIT_TRIPLE_RESET_TO_PAIR 1
#endif

// Defines default behaviour of any stored user data when the micro:bit is reflashed.
// 0: No action is taken
// 1: Data is invalidated (any may be hard erased, as per policy of the respective file system used)
#ifndef CONFIG_MICROBIT_ERASE_USER_DATA_ON_REFLASH
#define CONFIG_MICROBIT_ERASE_USER_DATA_ON_REFLASH 1
#endif
4 changes: 2 additions & 2 deletions model/MicroBit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int MicroBit::init()
uint8_t x = 0; uint8_t y = 0;
bool triple_reset = 0;

#if CONFIG_ENABLED(DEVICE_TRIPLE_RESET_TO_PAIR)
#if CONFIG_ENABLED(MICROBIT_TRIPLE_RESET_TO_PAIR)
triple_reset = (microbit_no_init_memory_region.resetClickCount == 3);
#endif

Expand Down Expand Up @@ -458,7 +458,7 @@ void MicroBit::eraseUserStorage(bool forceErase)
f.write((uint32_t) &reflash_status, &zero, 1);

// Determine if our flash contains a recognised file system. If so, invalidate it.
#if (CONFIG_MICROBIT_ERASE_USER_DATA_ON_REFLASH == 1)
#if CONFIG_ENABLED(CONFIG_MICROBIT_ERASE_USER_DATA_ON_REFLASH)
log.invalidate();
#endif
}
Expand Down
19 changes: 0 additions & 19 deletions model/MicroBit.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,13 @@ DEALINGS IN THE SOFTWARE.

#include "MicroBitStorage.h"

//#include "MicroBitLightSensor.h"



// Status flag values
#define DEVICE_INITIALIZED 0x01

// Flag that we have integrate face-touch as a feature
#define MICROBIT_UBIT_FACE_TOUCH_BUTTON 1

// Power on delay time (in milliseconds) applied after a hard power-on reset only.
#define KL27_POWER_ON_DELAY 1000

// Defines default behaviour of any stored user data when the micro:bit is reflashed.
// 0: No action is taken
// 1: Data is invalidated (any may be hard erased, as per policy of the respective file system used)
#ifndef CONFIG_MICROBIT_ERASE_USER_DATA_ON_REFLASH
#define CONFIG_MICROBIT_ERASE_USER_DATA_ON_REFLASH 1
#endif

// Defines default behaviour of triple-tap-reset-to-pair feature.
// 0: Feature disabled
// 1: Feature enabled. Triple tap of reset button enters Bluetooth pairing mode.
#ifndef DEVICE_TRIPLE_RESET_TO_PAIR
#define DEVICE_TRIPLE_RESET_TO_PAIR 1
#endif

/**
* Class definition for a MicroBit device.
Expand Down
2 changes: 1 addition & 1 deletion source/MicroBitLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ void MicroBitLog::_invalidate()
if (_isPresent())
{

#if (CONFIG_MICROBIT_LOG_FULL_ERASE_BY_DEFAULT)
#if CONFIG_ENABLED(CONFIG_MICROBIT_LOG_FULL_ERASE_BY_DEFAULT)
_clear();
#endif
MicroBitLogMetaData m;
Expand Down

0 comments on commit 5201d1b

Please sign in to comment.