imu: read all sensors at once at 100 Hz
1 unresolved thread
1 unresolved thread
In preparation to get it into st3m input state
Merge request reports
Activity
assigned to @q3k
added 1 commit
- 79af48df - imu: make available via standard input state
added 1 commit
- 094a4e7e - imu: make available via standard input state
added 1 commit
- 7381c171 - imu: make available via standard input state
- Resolved by q3k
56 void st3m_imu_read_pressure(float *pressure, float *temperature) { 57 LOCK; 58 *pressure = _pressure; 59 *temperature = _temperature; 60 UNLOCK; 61 } 62 63 static void _task(void *data) { 64 TickType_t last_wake = xTaskGetTickCount(); 65 esp_err_t ret; 66 float a, b, c; 67 while (1) { 68 vTaskDelayUntil(&last_wake, pdMS_TO_TICKS(10)); // 100 Hz 69 70 ret = flow3r_bsp_imu_update(&_imu); 71 if (ret == ESP_OK) { - Resolved by q3k
Demo:
class Ball(Responder): def __init__(self): self.ts = 0.0 self.v_x = 0.0 self.v_y = 0.0 self.p_x = 0.0 self.p_y = 0.0 self.input = InputController() super().__init__() def think(self, ins: InputState, delta_ms: int) -> None: self.input.think(ins, delta_ms) self.ts += delta_ms / 1000 self.v_y += self.input.imu.acc[0] * delta_ms / 1000. * 10 self.v_x += self.input.imu.acc[1] * delta_ms / 1000. * 10 x = self.p_x + self.v_x * delta_ms / 1000. y = self.p_y + self.v_y * delta_ms / 1000. if x**2 + y**2 < (120-5)**2: self.p_x = x self.p_y = y else: self.v_x = 0 self.v_y = 0 if self.input.left_shoulder.middle.pressed: print("exiting") def draw(self, ctx: Ctx) -> None: ctx.rectangle(-120, -120, 240, 240) ctx.rgb(0, 0, 0) ctx.fill() ctx.arc(self.p_x, self.p_y, 10, 0, tau, 0) ctx.rgb(117 / 255, 255 / 255, 226 / 255) ctx.fill()
Please register or sign in to reply