Skip to content

Commit

Permalink
CMake: Add acceleration sensor configuration
Browse files Browse the repository at this point in the history
The DRIVER_ACC configuration variable can be used to select the
acceleration sensor driver to be used.
  • Loading branch information
StarGate01 committed Jun 27, 2022
1 parent 25cf1c3 commit ca60633
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -795,22 +795,27 @@ add_definitions(-DTARGET_DEVICE_${TARGET_DEVICE})
if(TARGET_DEVICE STREQUAL "PINETIME")
add_definitions(-DDRIVER_PINMAP_PINETIME)
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
add_definitions(-DDRIVER_ACC_BMA421)
elseif(TARGET_DEVICE STREQUAL "MOY-TFK5") # P8a
add_definitions(-DDRIVER_PINMAP_P8)
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
add_definitions(-DDRIVER_ACC_BMA421)
elseif(TARGET_DEVICE STREQUAL "MOY-TIN5") # P8a variant 2
add_definitions(-DDRIVER_PINMAP_P8)
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
add_definitions(-DDRIVER_ACC_SC7A20)
elseif(TARGET_DEVICE STREQUAL "MOY-TON5") # P8b
add_definitions(-DDRIVER_PINMAP_P8)
add_definitions(-DCLOCK_CONFIG_LF_SRC=0) # RC
add_definitions(-DMYNEWT_VAL_BLE_LL_SCA=500)
add_definitions(-DCLOCK_CONFIG_LF_CAL_ENABLED=1)
add_definitions(-DDRIVER_ACC_SC7A20)
elseif(TARGET_DEVICE STREQUAL "MOY-UNK") # P8b mirrored
add_definitions(-DDRIVER_PINMAP_P8)
add_definitions(-DCLOCK_CONFIG_LF_SRC=0) # RC
add_definitions(-DMYNEWT_VAL_BLE_LL_SCA=500)
add_definitions(-DCLOCK_CONFIG_LF_CAL_ENABLED=1)
add_definitions(-DDRIVER_ACC_SC7A20)
else()
message(FATAL_ERROR "Invalid TARGET_DEVICE")
endif()
Expand Down
8 changes: 3 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
Pinetime::Components::LittleVgl lvgl {lcd, touchPanel};

#if (defined DRIVER_ACC_SC7A20)
#include <drivers/SC7A20.h>
static constexpr uint8_t motionSensorTwiAddress = 0x18;
#include <drivers/SC7A20.h>
static constexpr uint8_t motionSensorTwiAddress = 0x18;
Pinetime::Drivers::SC7A20 motionSensor {twiMaster, motionSensorTwiAddress};
#else
// Assume DRIVER_ACC_BMA421,
// this is needed for the LVGL simulator,
// which does not set any target hardware configuration variables
// Assume PineTime (DRIVER_ACC_BMA421)
#include <drivers/Bma421.h>
static constexpr uint8_t motionSensorTwiAddress = 0x18;
Pinetime::Drivers::Bma421 motionSensor {twiMaster, motionSensorTwiAddress};
Expand Down

0 comments on commit ca60633

Please sign in to comment.