Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if we need to update as in https://github.com/OxWearables/actipy/commit/32fe82f63142bf60fa243f0f486287f599e987e0 #267

Open
chanshing opened this issue Dec 18, 2024 · 0 comments
Assignees

Comments

@chanshing
Copy link
Member

Check whether the below needs to also be updated according to this: OxWearables/actipy@32fe82f

if (rateCode != 0) {
timestampOffset = buf.getShort(26); // timestamp
// offset ok
// if fractional offset, then timestamp offset was
// artificially
// modified for backwards-compatibility ...
// therefore undo this...
int oldDeviceId = getUnsignedShort(buf, 4);
if ((oldDeviceId & 0x8000) != 0) {
sampleFreq = 3200.0 / (1 << (15 - (rateCode & 15)));
if (USE_PRECISE_TIME) {
// Need to undo backwards-compatible shim:
// Take into account how many whole samples
// the fractional part of timestamp
// accounts for:
// relativeOffset = fifoLength -
// (short)(((unsigned long)timeFractional *
// AccelFrequency()) >> 16);
// nearest whole sample
// whole-sec | /fifo-pos@time
// | |/
// [0][1][2][3][4][5][6][7][8][9]
// use 15-bits as 16-bit fractional time
fractional = ((oldDeviceId & 0x7fff) << 1);
// frequency is truncated to int in firmware
timestampOffset += ((fractional * (int) sampleFreq) >> 16);
}
}
} else {
sampleFreq = buf.getShort(26);
// very old format, where pos26 = freq
}

@chanshing chanshing self-assigned this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant