This board behavior is for the Open-Close Sensor PAL.
void setup() {
auto&& brd = the_twelite.board.use<PAL_MAG>();
}
The sensor on the Open-Close Sensor PAL is a magnetic sensor with two interrupt input lines only.
const uint8_t PAL_MAG::PIN_SNS_NORTH = 16;
const uint8_t PAL_MAG::PIN_SNS_OUT1 = 16;
const uint8_t PAL_MAG::PIN_SNS_SOUTH = 17;
const uint8_t PAL_MAG::PIN_SNS_OUT2 = 17;
PAL_MAG::PIN_SNS_NORTH
triggers an interrupt when the sensor detects the north pole; PAL_MAG::PIN_SNS_SOUTH
also triggers an interrupt upon detecting the north pole.
Configure the following before entering sleep:
pinMode(PAL_MAG::PIN_SNS_OUT1, PIN_MODE::WAKE_FALLING);
pinMode(PAL_MAG::PIN_SNS_OUT2, PIN_MODE::WAKE_FALLING);
On wake-up, check the GPIO that triggered the wake-up:
uint8_t b_north =
the_twelite.is_wokeup_by_dio(PAL_MAG::PIN_SNS_NORTH);
uint8_t b_south =
the_twelite.is_wokeup_by_dio(PAL_MAG::PIN_SNS_SOUTH);