Remapping the accelerometer axes when changing the display's orientation so that the wakeup gesture continues to work as expected

This commit is contained in:
anschrammh 2023-10-11 13:30:05 +02:00
parent 34bf170dee
commit 5b0dea4cd7

View File

@ -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)