LED-BackPack Help

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Achilles36
 
Posts: 4
Joined: Sat Feb 18, 2017 1:52 pm

LED-BackPack Help

Post by Achilles36 »

Hi there,

I am trying to control a 16x16 led matrix using the LED Packpack system.

I am currently running into the following error:

"use of deleted function 'Adafruit_8x8matrix& Adafruit_8x8matrix::operator=(Adafruit_8x8matrix&&)'"

Has the 8x8 matrix been removed from this library now??

I am already including the Wire.h, gfxfont.h, Adafruit_GFX.h and the LED Backpack libraries

Code: Select all

void setup() {
  // Here is where the setup code goes to run once
  for (uint8_t i = 0; i < 4; i++) {
    matrix[i] = Adafruit_8x8matrix();
    matrix[i].begin(0x70 + i);
    matrix.setRotation(1); //Set rotation of the screen to the right
    matrix.setTextWrap(false); // Set text wrapping to off for the screen
    pinMode(APin, INPUT_PULLUP); // Intialise pins
    pinMode(DPin, INPUT_PULLUP);
    pinMode(UPin, INPUT_PULLUP);
    pinMode(RPin, INPUT_PULLUP);
    pinMode(LPin, INPUT_PULLUP);
Thanks in advance.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: LED-BackPack Help

Post by adafruit_support_rick »

You have a pointer error. Please post your entire sketch so I can see what's wrong

User avatar
Achilles36
 
Posts: 4
Joined: Sat Feb 18, 2017 1:52 pm

Re: LED-BackPack Help

Post by Achilles36 »

Code: Select all

#include "Adafruit_LEDBackpack.h" // Inlcude libraries
#include "Adafruit_GFX.h"
#include "gfxfont.h"
#include <Wire.h>

Adafruit_8x8matrix matrix[4] = Adafruit_8x8matrix();// Declare an array of 4 8x8 matrices


int APin = 2; // Set the pin information
int DPin = 11;
int UPin = 13;
int RPin = 10;
int LPin = 12;
int AState = 1; // Set variable for the button states
int DState = 1;
int UState = 1;
int RState = 1;
int LState = 1;
int pixPosX = 0; // Create the variable for Pac-Man's position on the matrix
int pixPosY = 0;
bool isTarCaught = false; // Create the variable for when the target is caught
int tarPosX = random (0, 15); // Set the target to have a random position
int tarPosY = random (0, 15);
int score = 0; // Create a variable for tracking the score.

void setup() {
  // Here is where the setup code goes to run once
  for (uint8_t i = 0; i < 4; i++) {
    matrix[i] = Adafruit_8x8matrix();
    matrix[i].begin(0x70 + i);
    matrix.setRotation(1); //Set rotation of the screen to the right
    matrix.setTextWrap(false); // Set text wrapping to off for the screen
    pinMode(APin, INPUT_PULLUP); // Intialise pins
    pinMode(DPin, INPUT_PULLUP);
    pinMode(UPin, INPUT_PULLUP);
    pinMode(RPin, INPUT_PULLUP);
    pinMode(LPin, INPUT_PULLUP);

    for (int C1 = 15; C1 >= -155; C1--) { // Start welcome text scroll across screen
      matrix.print("Pac-Man USW Demo Test 1"); // Print welcome text
      matrix.writeDisplay(); // Force the text to stay on the screen
      delay(75); // Wait 75 ms
      matrix.clear(); // Clear Screen
      matrix.setCursor(C1, 0); // Set cursor to the next pixel

    }
  }
}
void loop() { //main code starts here to repeat
  AState = digitalRead(APin); //Button press check
  DState = digitalRead(DPin);
  UState = digitalRead(UPin);
  RState = digitalRead(RPin);
  LState = digitalRead(LPin);

  if (isTarCaught == true) { //checks if the target is caught
    score = score + 1;
    matrix.clear();
    matrix.drawLine(1, 4, 3, 6, LED_ON); // Draw A Tick
    matrix.drawLine(3, 6, 6, 0, LED_ON);
    matrix.writeDisplay(); // Force the tick to stay on the screen
    delay(1000); // Hold for 1s
    tarPosX = random(0, 15); //set random x axis pos for target
    tarPosY = random(0, 15); //set random y axis pos for target
    isTarCaught = false; //mark target not caught
    pixPosX = 0; // Set Pac-mans position to 0,0
    pixPosY = 0;
    matrix.clear(); // Clear Screen
  }

  matrix.drawPixel(tarPosX, tarPosY, LED_ON); // Draw the Target on the screen
  matrix.writeDisplay(); // Hold the target on the screen until it is caught

  if (UState == 0) { // Move Pac-Man Up if U button is pressed
  pixPosY = pixPosY - 1;
  matrix.clear();
  }
  if (DState == 0) { // Move Pac-Man Down if D button is pressed
  pixPosY = pixPosY + 1;
  matrix.clear();
  }
  if (LState == 0) { // Move Pac-Man Left if L button is pressed
  pixPosX = pixPosX - 1;
  matrix.clear();
  }
  if (RState == 0) { // Move Pac-Man Right if L button is pressed
  pixPosX = pixPosX + 1;
  matrix.clear();
  }

  matrix.drawPixel(pixPosX, pixPosY, LED_ON); // Draw Pac-Man
  matrix.drawPixel((pixPosX + 1), pixPosY, LED_ON);
  matrix.drawPixel(pixPosX, (pixPosY + 1), LED_ON);
  matrix.drawPixel(pixPosX + 1), (pixPosY + 1), LED_ON;
  matrix.writeDisplay(); // Force Pac-Man to remain on the screen

  if (pixPosX == tarPosX && pixPosY == tarPosY) { // Checks if Pac-Man's position matches that of the target
  isTarCaught = true
}
if ((pixPosX + 1) == tarPosX && pixPosY == tarPosY) {
  isTarCaught = true
}
if (pixPosX == tarPosX && (pixPosY + 1) == tarPosY) {
  isTarCaught = true
}
if ((pixPosX + 1) == tarPosX && (pixPosY + 1) == tarPosY) {
  isTarCaught = true
}

if (score == 10) { // Score check = 10?
  for (int c6 = 0; c6 <= 2; c6++) { // Makes fireworks appear 3 times
      matrix.clear(); // Clear Screen
      matrix.drawPixel(7, 3, LED_ON);
      matrix.drawPixel(7, 4, LED_ON);
      matrix.drawPixel(8, 3, LED_ON);
      matrix.drawPixel(8, 4, LED_ON);
      matrix.writeDisplay(); //Make the first pixels to stay on the screen.

      delay(500); //Wait 500 milliseconds.

      matrix.clear(); //Clear the screen.

      matrix.drawPixel(6, 2, LED_ON);
      matrix.drawPixel(9, 2, LED_ON);
      matrix.drawPixel(6, 5, LED_ON);
      matrix.drawPixel(9, 5, LED_ON);
      matrix.writeDisplay();

      delay(500); //Wait 500 milliseconds.

      matrix.clear(); // Clear screen
      ,
      matrix.drawPixel(5, 1, LED_ON);
      matrix.drawPixel(10, 1, LED_ON);
      matrix.drawPixel(5, 6, LED_ON);
      matrix.drawPixel(10, 6, LED_ON);
      matrix.writeDisplay();

      delay(500);

      matrix.clear();

      matrix.drawPixel(4, 0, LED_ON);
      matrix.drawPixel(11, 0, LED_ON);
      matrix.drawPixel(4, 7, LED_ON);
      matrix.drawPixel(11, 7, LED_ON);
      matrix.writeDisplay();
      delay(500);
    }
    delay(500);
    matrix.clear()
    for (int C4 = 0; C4 <= 9999999; C4++) { // Repeat almost indefinite times
      for (int C5 = 16; C5 >= -210; C5--) { // Scroll text across the screen
        matrix.print("Press Reset to start again! :=)" ) // Text to be printed
        delay(75);
        matrix.clear(); // Clear Screen
        matrix.setCursor(C5, 0); // Cursor to the next pixel 
      }
    }
  }
  delay (100) // Wait 100 milliseconds
}

Partial credit for some of this code goes to: Nanohenry10-9

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: LED-BackPack Help

Post by adafruit_support_rick »

You've created an array of matrix objects here:

Code: Select all

Adafruit_8x8matrix matrix[4] = Adafruit_8x8matrix();// Declare an array of 4 8x8 matrices
In your code, you're trying to reassign the array with pointers to new matrix objects. You can't do that. It's a type mismatch.

Simply get rid of this line. You don't need it. Tha array already exists.

Code: Select all

    matrix[i] = Adafruit_8x8matrix();

User avatar
Achilles36
 
Posts: 4
Joined: Sat Feb 18, 2017 1:52 pm

Re: LED-BackPack Help

Post by Achilles36 »

adafruit_support_rick wrote:You've created an array of matrix objects here:

Code: Select all

Adafruit_8x8matrix matrix[4] = Adafruit_8x8matrix();// Declare an array of 4 8x8 matrices
In your code, you're trying to reassign the array with pointers to new matrix objects. You can't do that. It's a type mismatch.

Simply get rid of this line. You don't need it. Tha array already exists.

Code: Select all

    matrix[i] = Adafruit_8x8matrix();
Thanks Rick. That fixed that issue but it then seems to be having some more library issues?

Error: "request for member 'setRotation' in 'matrix', which is of non-class type 'Adafruit_8x8matrix [4]'"

Line:

Code: Select all

    matrix.setRotation(1); //Set rotation of the screen to the right
Any Ideas?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: LED-BackPack Help

Post by adafruit_support_rick »

You need to index the array. So it would be something like

Code: Select all

matrix[1].setRotation(1);
To set all four the same way, you would do this:

Code: Select all

for (int i = 0; i < 4; i++) {
  matrix[i].setRotation(1);
}

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”