CircularBuffer of CircularBufers

For my project i need to create a CircularBuffer of CircularBuffers. So far i have:
#include <CircularBuffer.h>

namespace data {
typedef struct {
unsigned long position;
unsigned long angle;
unsigned int count;
unsigned int distance;
} record;

CircularBuffer<data::record, 13> sprayposition;
CircularBuffer<sprayposition::record, 8>;

but i can’t get it to work. Any thoughts?

Thanks in advance

No idea if this will work, but it does compile:

#include <CircularBuffer.h>

struct record {
  unsigned long position;
  unsigned long angle;
  unsigned int count;
  unsigned int distance;
};

CircularBuffer<CircularBuffer<record, 13>, 8> bigBuffer;

void setup() {}

void loop() {}

Would love to try this but how do i add data to the structure? For example how would i push 1 to bigbuffer[1]position[1]=1

Building on the example from the library, it seems to work if you use nested loops. Added a couple typedef’s to make it more manageable.

#include <Arduino.h>
#include <CircularBuffer.h>

namespace data {
typedef struct {
  unsigned long time;
  unsigned int value; bool flag;
} record;

void print(record r) {
  Serial.print(r.time);
  Serial.print("  ");
  Serial.print(r.value);
  Serial.print("  ");
  Serial.print(r.flag);
}
}

typedef CircularBuffer<data::record, 10> RecordBuffer;
typedef CircularBuffer<RecordBuffer, 4> BufferBuffer;

BufferBuffer bigBuffer;
RecordBuffer sampleBuffer;

#define SAMPLE_PIN A0

void setup() {
  Serial.begin(115200);
  delay(2000);
  pinMode(SAMPLE_PIN, INPUT);
  Serial.println();
  Serial.println();
  Serial.println("STARTING UP");
}

void loop() {
  unsigned int sample = analogRead(SAMPLE_PIN);
  if (sample != sampleBuffer.last().value) {
    if (sampleBuffer.isFull()) {
      bigBuffer.push(sampleBuffer);
      sampleBuffer.clear();
    }
    sampleBuffer.push(data::record { millis(), sample, sample > 128 });
  }

  if (bigBuffer.isFull()) {
    Serial.println("Stack is full:");
    sampleBuffer.clear();
    while (!bigBuffer.isEmpty()) {
      sampleBuffer = bigBuffer.shift();
      while (!sampleBuffer.isEmpty()) {
        data::print(sampleBuffer.shift());
        Serial.println();
      }
    }
    delay(5000);
    Serial.println("START AGAIN");
  }
}