Accessing class array from another class

Hello!

I can't figure out, how to use the array wave1Values from the class Display, inside the class Sequencer. I heard about "getter" and "setter" functions, but I don't quite get them yet or is there any other way to solve my problem? :slight_smile: Thank you in advance!

relevant part of Display.h:

#ifndef Display_h
#define Display_h
#include <SPI.h>
#include <ILI9341_t3.h>
#include <font_Arial.h>
#include <XPT2046_Touchscreen.h>
#include <array>

class Display
{
  public:
    std::array<int, 256> wave1Values = {0};

  private:
};

Sequencer.cpp:

#include "Sequencer.h"

Sequencer::Sequencer() : {}

void Sequencer::stepLED()
{
    waveform[0].arbitraryWaveform(Display::wave1Values, 20000);
    counter(); //No constructor needed because you already wrote Sequencer::stepLED()
    for (unsigned int i{0}; i < m_stepLEDPin.size(); ++i)
    {
        if (counter() == 0)
        {
            digitalWrite(m_stepLEDPin[0], m_stepState[0]);
            digitalWrite(m_stepLEDPin[3], LOW);

            envelope[0].noteOn();
            waveform[0].amplitude(m_stepState[0]);
            waveform[0].frequency(frequency[0]);
        }
        else if (counter() == i)
        {
            digitalWrite(m_stepLEDPin[i], m_stepState[i]);
            digitalWrite(m_stepLEDPin[i] - 1, LOW);
            envelope[i].noteOn();
            waveform[i].amplitude(m_stepState[i]);
            waveform[i].frequency(frequency[i]);
        }
    }
}
Display.wave1Values
src/Sequencer.cpp:73:35: error: 'Display' was not declared in this scope
     waveform[0].arbitraryWaveform(Display.wave1Values, 20000);

:confused:

Sorry, can't be of further help. Try reading the forum guide.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.