Hello!
I have a project that is functionally working, however at a certain point I began to notice prolonged upload times. I have received an error twice (and admittedly, didn't google/screenshot it) that suggested an error having to do with the bootloader. I *think* it might have been directing me to this, and suggesting to add a delay prior to jumping to the bootloader: https://www.pjrc.com/teensy/jump_to_bootloader.html
Since getting the rest of my code working and realizing I should have tackled the above problem when I first encountered it, I haven't been able to reproduce the pop-up error, however it is taking upwards of 30 seconds to upload my code on most occasions (95/100 times). It compiles in 2.5 seconds consistently.
I've made a 16x4 step sequencer using 4 Adafruit Neotrellis boards (https://www.adafruit.com/product/3954) and am using the library written for it.
Can anyone see any issues in my code that might cause this prolonged upload time? The code functions perfectly once uploaded, but I'm concerned that an issue could rear its head after longer use. And of course, if something is wrong, I'd like to fix/learn from it. Since the hardware is functioning fine I'm assuming it is a code problem, however I can upload photos of my wiring if that helps.
Setup:
2017 Macbook pro
Arduino 1.8.7
Teensy 3.6
Teensy Loader 1.44
Adafruit Neotrellis
Library: Adafruit_NeoTrellis.h (which stems from the seesaw library)
Thank you very much!
I have a project that is functionally working, however at a certain point I began to notice prolonged upload times. I have received an error twice (and admittedly, didn't google/screenshot it) that suggested an error having to do with the bootloader. I *think* it might have been directing me to this, and suggesting to add a delay prior to jumping to the bootloader: https://www.pjrc.com/teensy/jump_to_bootloader.html
Since getting the rest of my code working and realizing I should have tackled the above problem when I first encountered it, I haven't been able to reproduce the pop-up error, however it is taking upwards of 30 seconds to upload my code on most occasions (95/100 times). It compiles in 2.5 seconds consistently.
I've made a 16x4 step sequencer using 4 Adafruit Neotrellis boards (https://www.adafruit.com/product/3954) and am using the library written for it.
Can anyone see any issues in my code that might cause this prolonged upload time? The code functions perfectly once uploaded, but I'm concerned that an issue could rear its head after longer use. And of course, if something is wrong, I'd like to fix/learn from it. Since the hardware is functioning fine I'm assuming it is a code problem, however I can upload photos of my wiring if that helps.
Setup:
2017 Macbook pro
Arduino 1.8.7
Teensy 3.6
Teensy Loader 1.44
Adafruit Neotrellis
Library: Adafruit_NeoTrellis.h (which stems from the seesaw library)
Thank you very much!
Code:
/*
A standard 16x4 step sequencer for the Adafruit Neotrellis.
When the playhead passes over a button that is on, a pulse is sent to an external LED.
*/
#include "Adafruit_NeoTrellis.h"
#define X_DIM 16 //number of columns of keys
#define Y_DIM 4 //number of rows of key
//create a matrix of trellis panels
Adafruit_NeoTrellis t_array[Y_DIM / 4][X_DIM / 4] = {
//i2c addresses are based on the jumpers on the back of each board
{ Adafruit_NeoTrellis(0x2E), Adafruit_NeoTrellis(0x2F), Adafruit_NeoTrellis(0x31), Adafruit_NeoTrellis(0x30) }
};
//pass this matrix to the multitrellis object
Adafruit_MultiTrellis trellis((Adafruit_NeoTrellis *)t_array, Y_DIM / 4, X_DIM / 4);
int ledPins[4] = {30, 29, 10, 9};
//used for advancing the playhead
elapsedMillis playheadCounter;
//used to avoid using delay();
unsigned long previousMillis = 0;
//sets the rate of the playhead
unsigned long bpm = 167;
//serves as the column number
int buttonIndex;
//tracks the presses on each button; odd values will turn on
int pressCount[64] = {0};
//define a callback for key presses
TrellisCallback onOff(keyEvent evt) {
for (int x = 0; x < X_DIM; x++) {
//turn on each 16th pixel (resulting in the playhead)
for (int y = 0; y < Y_DIM; y++) {
int button_loc = x + y * X_DIM;
if (evt.bit.EDGE == SEESAW_KEYPAD_EDGE_RISING) {
pressCount[evt.bit.NUM]++;
}
trellis.show();
return 0;
}
}
}
void setup() {
Serial.begin(9600);
//Set the ledPins to outputs and start them off
for (int i = 0; i < 4; i++) {
pinMode(ledPins[i], OUTPUT);
}
//while(!Serial);
if (!trellis.begin()) {
Serial.println("failed to begin Neotrellis");
while (1);
} else {
Serial.println("Neotrellis started");
}
//Display a startup sequence to know that we're on
for (int i = 0; i < Y_DIM * X_DIM; i++) {
trellis.setPixelColor(i, seesaw_NeoPixel::Color(20, 20, 20));
trellis.show();
}
//activate all keys in the array
for (int y = 0; y < Y_DIM; y++) {
for (int x = 0; x < X_DIM; x++) {
//activate rising and falling edges on all keys
trellis.activateKey(x, y, SEESAW_KEYPAD_EDGE_RISING, true);
trellis.activateKey(x, y, SEESAW_KEYPAD_EDGE_FALLING, true);
trellis.registerCallback(x, y, onOff);
trellis.setPixelColor(x, y, 0x000000); //addressed with x,y
trellis.show(); //show all LEDs
}
}
}
void loop() {
trellis.read();
unsigned long currentMillis = millis();
//formula to calculate the rate at which the playhead moves
if (currentMillis - previousMillis >= bpm) {
previousMillis = currentMillis;
buttonIndex++;
buttonIndex = buttonIndex % 16;
}
//Playhead
for (int x = 0; x < X_DIM; x++) {
for (int y = 0; y < Y_DIM; y++) {
int button_loc = x + y * X_DIM;
if (x == buttonIndex) {
//create white playhead, and everywhere else, light up the buttons that are 'on' based on row color; otherwise set to off
trellis.setPixelColor(button_loc, seesaw_NeoPixel::Color(100, 100, 100));
} else if (pressCount[button_loc] % 2 && y == 0) {
trellis.setPixelColor(button_loc, seesaw_NeoPixel::Color(255, 0, 0));
} else if (pressCount[button_loc] % 2 && y == 1) {
trellis.setPixelColor(button_loc, seesaw_NeoPixel::Color(0, 255, 0));
} else if (pressCount[button_loc] % 2 && y == 2) {
trellis.setPixelColor(button_loc, seesaw_NeoPixel::Color(0, 0, 255));
} else if (pressCount[button_loc] % 2 && y == 3) {
trellis.setPixelColor(button_loc, seesaw_NeoPixel::Color(255, 255, 0));
} else {
trellis.setPixelColor(button_loc, 0);
}
// check to send pulse
//if the button is on, and the playhead is over it, pulse the external led
if (pressCount[button_loc] % 2 && x == buttonIndex && y == 0) {
digitalWrite(ledPins[y], HIGH);
if (currentMillis - previousMillis >= 20) {
digitalWrite(ledPins[y], LOW);
}
} else if (pressCount[button_loc] % 2 && x == buttonIndex && y == 1) {
digitalWrite(ledPins[y], HIGH);
if (currentMillis - previousMillis >= 20) {
digitalWrite(ledPins[y], LOW);
}
} else if (pressCount[button_loc] % 2 && x == buttonIndex && y == 2) {
digitalWrite(ledPins[y], HIGH);
if (currentMillis - previousMillis >= 20) {
digitalWrite(ledPins[y], LOW);
}
} else if (pressCount[button_loc] % 2 && x == buttonIndex && y == 3) {
digitalWrite(ledPins[y], HIGH);
if (currentMillis - previousMillis >= 20) {
digitalWrite(ledPins[y], LOW);
}
}
}
}
//show all LEDs
trellis.show();
}
Last edited: