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

How to print out the the value of the register #52

Closed
krupis opened this issue Jul 8, 2021 · 0 comments
Closed

How to print out the the value of the register #52

krupis opened this issue Jul 8, 2021 · 0 comments

Comments

@krupis
Copy link

krupis commented Jul 8, 2021

Hello. I am looking into registers and learning various operations with them. I am using LIS3DH accelerometer sensor with the adafruit library.

For some reason, I am having a lot of troubles trying to print out the value of the register. For example, I want to print CTRL1_REG of the LIS3DH.

Inside Adafruit_LIS3DH.cpp file, I have created my own function for reading the register:

Adafruit_BusIO_Register Adafruit_LIS3DH::read_register(int register){
    Adafruit_BusIO_Register reg_to_read = Adafruit_BusIO_Register(
    i2c_dev, spi_dev, ADDRBIT8_HIGH_TOREAD, register, 1);
    return reg_to_read;

}

Simply, all I want to do is pass the value of the register to the function, and the function would then return me a number or hex value so I know what is set for this register. I have tried the above but I am not fully sure whether I can use the type Adafruit_BusIO_Register as a regular numbe or hex. Is that possible?

In my main arduino code, I call:

  Adafruit_BusIO_Register reg_to_read;
  reg_to_read = lis.read_register(LIS3DH_REG_CTRL4);
  Serial.println(reg_to_read);

But there is an error :

no matching function for call to 'Adafruit_BusIO_Register::Adafruit_BusIO_Register()'

Any help is appreciated. Please suggest me a simplest way how to read a register and print out using serial print

@krupis krupis closed this as completed Jul 8, 2021
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