Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Adding NeoPixel string to the playground
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Adding NeoPixel string to the playground

by dastels on Thu Jun 25, 2020 8:24 pm

Can you paste the full error output so I can see the context. Thanks!

Dave

dastels
 
Posts: 3494
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adding NeoPixel string to the playground

by Spolyoka1 on Fri Jun 26, 2020 6:12 pm

Hey,

Thanks again 1st posting is the code as is. Second is the Error Message.


Code:

Code: Select all | TOGGLE FULL SIZE
#include <string.h>
#include <Arduino.h>
#include <SPI.h>

#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"
#include "BluefruitConfig.h"

#include <Adafruit_NeoPixel.h>

#if SOFTWARE_SERIAL_AVAILABLE
  #include <SoftwareSerial.h>
#endif

#include <Adafruit_CircuitPlayground.h>

// Configuration (you don't need to change these, but can!):
#define FACTORYRESET_ENABLE     1   // Set to 1 to factory reset the Bluefruit LE
                                    // module.  In general this is a smart idea to
                                    // put the module into a known good state.
                                    // A value of 1 means perform a factory reset
                                    // on start, and 0 means no factory reset.

#define NUMPIXELS               10  // Number of NeoPixels on the board.

#define BRIGHTNESS              255 // NeoPixel brightness (0...255, low to max brightness)

/*=========================================================================*/

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    6

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 20

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

// Create the bluefruit object, for Circuit Playground this needs to be
// hardware serial.
Adafruit_BluefruitLE_UART ble(BLUEFRUIT_HWSERIAL_NAME, BLUEFRUIT_UART_MODE_PIN);

// A small helper
void error(const __FlashStringHelper*err) {
  Serial.println(err);
  while (1);
}

// function prototypes over in packetparser.cpp
uint8_t readPacket(Adafruit_BLE *ble, uint16_t timeout);
float parsefloat(uint8_t *buffer);
void printHex(const uint8_t * data, const uint32_t numBytes);

// the packet buffer
extern uint8_t packetbuffer[];

// Offset that controls which pixels are turned on/off.
// Pressing the left/right controller button moves this offset
// up/down and 'slides' the chain of 10 pixels around.
int currentOffset = 0;

// Last selected color.
uint8_t currentRed, currentGreen, currentBlue;

// Light up a chain of 10 pixels starting at offset global variable value.
void lightPixels(uint8_t red, uint8_t green, uint8_t blue, int offset) {
  CircuitPlayground.strip.clear();
  for (int i = offset; i < offset+NUMPIXELS; ++i) {
    if ((i >= 0) && (i < NUMPIXELS)) {
      CircuitPlayground.strip.setPixelColor(i, red, green, blue);
    }
  }
  CircuitPlayground.strip.show();
   strip.clear();
  for (int i = offset; i < offset+LED_COUNT; ++i) {
    if ((i >= 0) && (i < LED_COUNT)) {
      strip.setPixelColor(i, red, green, blue);
    }
  }
  strip.show();
}

void setup() {


  // Wait for serial port before starting.  Not required but helps with debugging.
  //while (!Serial);
  //delay(500);
 
  // Initialize Circuit Playground library and turn off the Pixels.
  CircuitPlayground.begin(BRIGHTNESS);
  CircuitPlayground.clearPixels();
 

  // Initialize serial output.
  Serial.begin(115200);
  Serial.println(F("Adafruit Circuit Playground Bluefruit Neopixel Color Picker Example"));
  Serial.println(F("-------------------------------------------------------------------"));

  // Initialise the module
  Serial.print(F("Initialising the Bluefruit LE module: "));

  if ( !ble.begin(VERBOSE_MODE) )
  {
    error(F("Couldn't find Bluefruit, make sure it's in DATA mode & check wiring...."));
  }
  Serial.println( F("OK!") );

  if ( FACTORYRESET_ENABLE )
  {
    // Perform a factory reset to make sure everything is in a known state
    Serial.println(F("Performing a factory reset: "));
    if (!ble.factoryReset()) {
      Serial.println(F("Couldn't factory reset, making another attempt..."));
      delay(1000);
      if (!ble.factoryReset()) {
        error(F("Couldn't factory reset!"));
      }
    }
  }

  // Disable command echo from Bluefruit
  ble.echo(false);

  Serial.println("Requesting Bluefruit info:");
  // Print Bluefruit information
  ble.info();

  // Change advertised name to Circuit_Playground_BLE
  ble.println("AT+GAPDEVNAME=CPlay_BLE");
  delay(100);
  ble.println("ATZ");
  delay(100);

  Serial.println(F("Please use Adafruit Bluefruit LE app to connect in Controller mode"));
  Serial.println(F("Then activate/use the sensors, color picker, game controller, etc!"));
  Serial.println();

  ble.verbose(false);  // debug info is a little annoying after this point!

  // Wait for connection
  while (! ble.isConnected()) {
      delay(500);
  }

  Serial.println(F("***********************"));

  // Set Bluefruit to DATA mode
  Serial.println( F("Switching to DATA mode!") );
  ble.setMode(BLUEFRUIT_MODE_DATA);

  Serial.println(F("***********************"));

}

void loop()
{
  /* Wait for new data to arrive */
  uint8_t len = readPacket(&ble, BLE_READPACKET_TIMEOUT);
  if (len == 0) {
    return;
  }

  /* Got a packet! */
  //printHex(packetbuffer, len);

  // Color
  if (packetbuffer[1] == 'C') {
    // Parse out the red, green, blue values and save them.
    uint8_t red = packetbuffer[2];
    uint8_t green = packetbuffer[3];
    uint8_t blue = packetbuffer[4];
    // Change the color.
    currentRed = red;
    currentGreen = green;
    currentBlue = blue;
  }

  // Left/right adjust the offset that turns on/off pixels.
  if (packetbuffer[1] == 'B') {
    if (memcmp(packetbuffer, "!B705", 5) == 0) {
      // Left button release.
      currentOffset -= 1;
    }
    else if (memcmp(packetbuffer, "!B804", 5) == 0) {
      // Right button release.
      currentOffset += 1;
    }
    currentOffset = constrain(currentOffset, -NUMPIXELS, NUMPIXELS);
  }

  // Update the pixels again since either the color or offset position
  // must have changed above.
  lightPixels(currentRed, currentGreen, currentBlue, currentOffset);
}



Error:

Arduino: 1.8.13 (Windows Store 1.8.39.0) (Windows 10), Board: "Adafruit Circuit Playground"





















C:\Users\Spoly\AppData\Local\Temp\cc8AF9jn.s: Assembler messages:

C:\Users\Spoly\AppData\Local\Temp\cc8AF9jn.s:11932: Error: symbol `headD' is already defined

C:\Users\Spoly\AppData\Local\Temp\cc8AF9jn.s:12067: Error: symbol `headB' is already defined

C:\Users\Spoly\AppData\Local\Temp\cc8AF9jn.s:12172: Error: symbol `headC' is already defined

C:\Users\Spoly\AppData\Local\Temp\cc8AF9jn.s:12276: Error: symbol `headF' is already defined

C:\Users\Spoly\AppData\Local\Temp\cc8AF9jn.s:12374: Error: symbol `head20' is already defined

C:\Users\Spoly\AppData\Local\Temp\cc8AF9jn.s:12388: Error: symbol `nextbyte20' is already defined

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.39.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Adafruit Circuit Playground.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Spolyoka1
 
Posts: 16
Joined: Wed Jun 10, 2020 10:29 pm

Re: Adding NeoPixel string to the playground

by dastels on Fri Jun 26, 2020 6:51 pm

These errors are from the assembler. Do you have all the board support packages and libraries up to date?

Dave

dastels
 
Posts: 3494
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adding NeoPixel string to the playground

by Spolyoka1 on Fri Jun 26, 2020 9:07 pm

I think so, I have the libraries I have listed below.

Adafruit_bluefruitLE_nRF51
Adafruit_CircuitPlayground
Adafruit_NeoPixel

Not sure if there are any library collections you would suggest downloading?

Thanks!

Spolyoka1
 
Posts: 16
Joined: Wed Jun 10, 2020 10:29 pm

Re: Adding NeoPixel string to the playground

by dastels on Fri Jun 26, 2020 11:07 pm

I mean are they up to date. Go into the board manager and library manager and select updateable from the type dropdown menu. Update any that are listed.

Dave

dastels
 
Posts: 3494
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adding NeoPixel string to the playground

by Spolyoka1 on Sat Jun 27, 2020 3:26 pm

Sorry, Yes I believe so I went to the library manager and checked they were all the most recent versions. It couldn't be too big a file could it?

Another option that would work is if I can just get the strip to light up I can recreate the circle of LEDS so it doesn't have to light both the strip and Board LEDS. Would that work?

Spolyoka1
 
Posts: 16
Joined: Wed Jun 10, 2020 10:29 pm

Re: Adding NeoPixel string to the playground

by dastels on Sat Jun 27, 2020 5:01 pm

Unlikely it's a space issue. You're working in C++ so you can fit A LOT of code. I expect you'd get something more to the point if you were out of space. I've never actually seen an assembler error in this context. I'll ask around.

Dave

dastels
 
Posts: 3494
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adding NeoPixel string to the playground

by Spolyoka1 on Wed Jul 01, 2020 12:35 pm

Hey Dave,

Thanks again for digging into this. Was anyone able to provide some insight?

Best,

Spolyoka1
 
Posts: 16
Joined: Wed Jun 10, 2020 10:29 pm

Re: Adding NeoPixel string to the playground

by dastels on Wed Jul 01, 2020 1:40 pm

Nothing yet.

Dave

dastels
 
Posts: 3494
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adding NeoPixel string to the playground

by Spolyoka1 on Wed Jul 08, 2020 11:59 pm

Hey,

So I think that for my needs the feather is a better board to try and program. Currently I have the Feather M0 with Bluefruit. I am able to upload the feather bluefruit animation controller sketch and it somewhat works. The LED is very flickery and the color selection is a little delayed. I have it wired from 3V to Power in, Gnd to Gnd, and Pin 6 to data in. Not sure if its a power issue with the 3v instead of 5. I tried it wired to the USB power instead of the 3v and it gives the same result. Any thoughts?

Spolyoka1
 
Posts: 16
Joined: Wed Jun 10, 2020 10:29 pm

Re: Adding NeoPixel string to the playground

by dastels on Thu Jul 09, 2020 11:53 am

Not offhand. Flickery neopixels is often a power issue.

Dave

dastels
 
Posts: 3494
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adding NeoPixel string to the playground

by adafruit_support_carter on Sat Jul 18, 2020 8:07 pm

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>

#if SOFTWARE_SERIAL_AVAILABLE
  #include <SoftwareSerial.h>
#endif

#include <Adafruit_CircuitPlayground.h>


The CircuitPlayground Arduino library has its own NeoPixel implementation. So you don't want to import the standard NeoPixel library for your external NeoPixel strand. We've added a new example to the library to hopefully demonstrate how to do this:
https://github.com/adafruit/Adafruit_Ci ... pixels.ino

adafruit_support_carter
 
Posts: 16922
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.