74HC165 Library

Hello people,
I'm making a library in order to control one or more shift registers.

Here is the code:

ShiftRegister.h

/*
  ShiftRegister.h - Library for using a shift register.
*/

#ifndef ShiftRegister_h
#define ShiftRegister_h

#include "Arduino.h"

class ShiftRegister
{
  public:
    ShiftRegister(int clockPin, int latchPin, int dataPin);
    shiftDataOut(byte *data);
  private:
    byte getPage();
    int _latchPin;
    int _clockPin;
    int _dataPin;
};

#endif

ShiftRegister.cpp

#include "Arduino.h"
#include "ShiftRegister.h"

ShiftRegister::ShiftRegister(int clockPin, int latchPin, int dataPin)
{
  _latchPin = latchPin;
  _clockPin = clockPin;
  _dataPin = dataPin;

  pinMode(_latchPin, OUTPUT);
  pinMode(_clockPin, OUTPUT);
  pinMode(_dataPin, INPUT);
}

ShiftRegister::shiftDataOut(byte *data)
{

  // set latchPin LOW so the register loads data from its inputs
  digitalWrite(_latchPin, 0);
  // wait a little
  //delay(2000);
  //set it to HIGH to collect parallel data
  digitalWrite(_latchPin, 1);
  for (int i = 0; i < sizeof(data); i++)
  {
    data[i] = ShiftRegister::getPage();
  }
}

byte ShiftRegister::getPage() {

  byte pageData = 0;

Serial.println("---");
  for (int i = 7; i >= 0; i--)
  {
    // set clock pin to LOW in order to shift a bit
    digitalWrite(_clockPin, 0);
    
    delay(100);
    Serial.print(digitalRead(_dataPin));
  
    if (digitalRead(_dataPin)) {
      pageData = pageData | (1 << i);
    }
    // the job is done, so set it to HIGH
    digitalWrite(_clockPin, 1);
  }
  Serial.println("");
  return pageData;
}

Main.ino

#include "ShiftRegister.h";

//ShiftRegister::ShiftRegister(int clockPin, int latchPin, int dataPin)
ShiftRegister regist(10, 8, 11);

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  byte data;

  regist.shiftDataOut(&data);
  Serial.print("data: ");
  Serial.println(data, BIN);
  
  delay(400);

}

I'm facing this problem:

I cannot pass an array to shiftDataOut method to hold the data. Right now I can only pass a byte, but I would like to be able to pass an array of bytes in order to store into them the values read by the registers. Is this possible?

Thank you!

pass an address and nbr of bytes ?

Can you please elaborate?

When passed to a function, the name of an array acts as a pointer to the first element in the array.

'sizeof(arrayName) /sizeof(arrayName[0])' computes the number of elements in the array. This should also be passed to the function.