Skip to content

Instantly share code, notes, and snippets.

View Solidedge's full-sized avatar
🤘

Ole Bjerkemo Solidedge

🤘
  • ASSA ABLOY Global Solutions
  • Norway
View GitHub Profile
@Solidedge
Solidedge / timestamp_converter.c
Last active February 15, 2022 10:25
Convert incoming BLE-MIDI timestamp to localtime, or delayed local time. Functional with https://github.com/BLE-MIDI
/** Convert incoming BLE-MIDI timestamp to localtime, or delay.
* Timestamp out is in microseconds.*/
static uint16_t convert_timestamp(uint16_t received_ts, uint16_t conn_interval, uint16_t time_of_rx) {
static uint16_t prev_received_ts;
static uint32_t prev_time_of_rx;
static uint32_t prev_returned_ts;
static bool first_timestamp = true;
if (first_timestamp) {
prev_time_of_rx = time_of_rx;