example/FeatherM0/bma250x.c
static uint16_t scale( uint16_t value )
{
    if( bit_test( value, 9 ) ){
        value = 512 - ((~value + 1) & 0x1FF);
    }
    else{
        bit_set( value, 9 );
    }

    return value;
}
// Scale the two's-complement (10 bit) result to a positive 10 bit value
// scaled from 0 -> 1023 Resulting gain is 2/512, offset 2
Scale the two's-complement (10 bit) result to a positive 10 bit value
scaled from 0 -> 1023 Resulting gain is 2/512, offset 2
Scale the two ' s - complement ( 10 bit ) result to a positive 10 bit value scaled from 0 - > 1023 Resulting gain is 2 / 512 offset 2
static uint16_t scale( uint16_t value )
{
    if( bit_test( value, 9 ) ){
        value = 512 - ((~value + 1) & 0x1FF);
    }
    else{
        bit_set( value, 9 );
    }
    return value;
}
static uint16_t scale ( uint16_t value ) { if ( bit_test ( value , 9 ) ) { value = 512 - ( ( ~ value + 1 ) & 0x1FF ) ; } else { bit_set ( value , 9 ) ; } return value ; }
Scale the two's-complement (10 bit) result to a positive 10 bit value
scaled from 0 -> 1023 Resulting gain is 2/512, offset 2
Scale the two ' s - complement ( 10 bit ) result to a positive 10 bit value scaled from 0 - > 1023 Resulting gain is 2 / 512 offset 2