Northeastern-Electric-Racing / Cerberus

Our FreeRTOS-based vehicle control application
1 stars 0 forks source link

113 steering wheel #124

Closed nwdepatie closed 6 months ago

nwdepatie commented 6 months ago

Changes

I've created a basic interface for updating and retrieving button data sent from the steering wheel

Notes

The basic implementation is that I wanted to make each operation from the user atomic, since I am leveraging the ability to spawn timer based callbacks.

My implementation of debouncing is that:

  1. CAN message updates raw fields
  2. If the raw field goes from 0 to 1, we start time debounce timer for that specific button, else we set it to 0
  3. The struct contains an array of timers that all call the same callback, so we also have them push a new debounce request to the ringbuffer
  4. Callback pops off the most recent request to the ring buffer and evaluates if the button is pressed, then update that in the steering struct

Test Cases

To Do

I think I need to evaluate the buffer for the case when a timer is restarted. I.e. how can we handle it when the same button goes up then down then up (would queue 2 and callback wouldn't know what to do)

Closes #113