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

fix reading data in adxl345bGetMultipleMeasurements #294

Closed
4 tasks done
PandiasChild opened this issue Oct 8, 2024 · 0 comments · Fixed by #320
Closed
4 tasks done

fix reading data in adxl345bGetMultipleMeasurements #294

PandiasChild opened this issue Oct 8, 2024 · 0 comments · Fixed by #320
Assignees
Labels
bug Something isn't working sensor sensor library related issues

Comments

@PandiasChild
Copy link
Contributor

PandiasChild commented Oct 8, 2024

  • write Test which shows the error
  • fix writing data (no overwriting)
  • refactor variables
  • use different case for triggermode

currently we're overwriting our alreadyReadData (since ReadDataXYZ reads always 6 Data). We could name it "alreadyReadSamples"

we do this:

/* read Data */
        for(uint8_t i=0; i < samplesInFifo; i++){
            errorCode = adxl345bReadDataXYZ(sensor, rawData[alreadyReadData + i]);
            //sleep 5 μs to ensure data is ready
            sleep_for_ms(5);

            if(errorCode != ADXL345B_NO_ERROR){
                PRINT_DEBUG("ReadDataXYZ failed");
                return errorCode;
            }
        }

instead we need to do this:

/* read Data */
        for (uint8_t i = 0; i < samplesInFifo; i++) {
            errorCode = adxl345bReadDataXYZ(sensor, rawData[alreadyReadSamples * 6]);
            alreadyReadSamples++;
            //sleep 5 μs to ensure data is ready
            sleep_for_ms(5);

            if (errorCode != ADXL345B_NO_ERROR) {
                PRINT_DEBUG("ReadDataXYZ failed");
                return errorCode;
            }
        }
@PandiasChild PandiasChild added bug Something isn't working sensor sensor library related issues labels Oct 8, 2024
@PandiasChild PandiasChild linked a pull request Nov 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sensor sensor library related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant