|
5 | 5 | #include "apps.h" |
6 | 6 | #include "bsp/display.h" |
7 | 7 | #include "bsp/input.h" |
| 8 | +#include "bsp/orientation.h" |
8 | 9 | #include "bsp/power.h" |
9 | 10 | #include "charging_mode.h" |
10 | 11 | #include "common/display.h" |
@@ -144,6 +145,8 @@ void menu_home(void) { |
144 | 145 |
|
145 | 146 | render(buffer, theme, &menu, position, false, true); |
146 | 147 |
|
| 148 | + bsp_orientation_enable_accelerometer(); |
| 149 | + |
147 | 150 | while (1) { |
148 | 151 | bsp_input_event_t event; |
149 | 152 | if (xQueueReceive(input_event_queue, &event, pdMS_TO_TICKS(1000)) == pdTRUE) { |
@@ -244,7 +247,24 @@ void menu_home(void) { |
244 | 247 | break; |
245 | 248 | } |
246 | 249 | } else { |
247 | | - render(buffer, theme, &menu, position, true, true); |
| 250 | + bool gyro_enabled = false; |
| 251 | + bool accel_enabled = false; |
| 252 | + float gyro_x, gyro_y, gyro_z; |
| 253 | + float accel_x, accel_y, accel_z; |
| 254 | + bsp_orientation_get(&gyro_enabled, &accel_enabled, &gyro_x, &gyro_y, &gyro_z, &accel_x, &accel_y, &accel_z); |
| 255 | + bool changed = false; |
| 256 | + if (accel_x > 2.0f || !accel_enabled) { |
| 257 | + if (pax_buf_get_orientation(buffer) != PAX_O_ROT_CCW) { |
| 258 | + pax_buf_set_orientation(buffer, PAX_O_ROT_CCW); |
| 259 | + changed = true; |
| 260 | + } |
| 261 | + } else if (accel_x < -2.0f) { |
| 262 | + if (pax_buf_get_orientation(buffer) != PAX_O_ROT_CW) { |
| 263 | + pax_buf_set_orientation(buffer, PAX_O_ROT_CW); |
| 264 | + changed = true; |
| 265 | + } |
| 266 | + } |
| 267 | + render(buffer, theme, &menu, position, !changed, true); |
248 | 268 | } |
249 | 269 | } |
250 | 270 | } |
0 commit comments