From 5b0dea4cd7146c745dd39854cdaac8430fabffbe Mon Sep 17 00:00:00 2001 From: anschrammh Date: Wed, 11 Oct 2023 13:30:05 +0200 Subject: [PATCH] Remapping the accelerometer axes when changing the display's orientation so that the wakeup gesture continues to work as expected --- .../watch_peripherals/watch_peripherals.c | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/W800_SDK_v1.00.10/app/app_drivers/watch_peripherals/watch_peripherals.c b/src/W800_SDK_v1.00.10/app/app_drivers/watch_peripherals/watch_peripherals.c index 859ed17..47b7f17 100644 --- a/src/W800_SDK_v1.00.10/app/app_drivers/watch_peripherals/watch_peripherals.c +++ b/src/W800_SDK_v1.00.10/app/app_drivers/watch_peripherals/watch_peripherals.c @@ -383,7 +383,37 @@ void watch_peripherals_set_brightness(uint8_t brightness) void watch_peripherals_set_orientation(LCDOrientation_e orientation) { extern LCDConfig_t LCDConfig; - lcd_orientation(&LCDConfig, orientation); + //Let's remap the accelerometer axes so that the wakeup gesture is still working correctly :) + struct bma4_remap remapping = { + .x = BMA4_X, + .y = BMA4_Y, + .z = BMA4_Z + }; + switch(orientation) + { + case LCD_ORIENTATION_90: + remapping.x = BMA4_NEG_Y; + remapping.y = BMA4_X; + break; + case LCD_ORIENTATION_180: + remapping.x = BMA4_NEG_X; + remapping.y = BMA4_NEG_Y; + break; + case LCD_ORIENTATION_270: + remapping.x = BMA4_Y; + remapping.y = BMA4_NEG_X; + break; + default: + remapping.x = BMA4_X; + remapping.y = BMA4_Y; + break; + } + + //If the call to the API is successful, we rotate the display's orientation + if(bma456w_set_remap_axes(&remapping, &_bma456.bma) == BMA4_OK) + { + lcd_orientation(&LCDConfig, orientation); + } } bool watch_peripherals_wakeup_source_is_user(void)