Skip to content

error in _parse_shake_report wrong bit mask #61

@bradcar

Description

@bradcar

Noticed a typo for the shake report. In the SH-2 doc (6.5.32 page 78) it shows the lower 3 bit contain the x,y,z status bits. but the bit mask here has 0x111, it should be 0b111 or likely clearer for a "<H" may be 0x07.

in init.py line 302

def _parse_shake_report(report_bytes: bytearray) -> bool:
    shake_bitfield = unpack_from("<H", report_bytes, offset=4)[0]
    return (shake_bitfield & 0x111) > 0

I don't have CircuitPython, so I don't have any way to test, so I won't do a pull request. What I believe will fix it:

def _parse_shake_report(report_bytes: bytearray) -> bool:
    shake_bitfield = unpack_from("<H", report_bytes, offset=4)[0]
    return (shake_bitfield & 0x07) > 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions