Interrupt on teensy 4.0 + Adafruits Neotrellis

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Moris526
 
Posts: 91
Joined: Fri Jan 17, 2020 10:09 am

Interrupt on teensy 4.0 + Adafruits Neotrellis

Post by Moris526 »

Hi all.

Im using Teensy 4.0 to control Adafruits Neotrellis 16 LEd/button board programing it with Arduino Ide

All works fine with the Adafruit example but the interrupt function ( it works fine with an arduino uno board)

Code: Select all

/* This example shows basic usage of the NeoTrellis
  with the interrupt pin.
  The buttons will light up various colors when pressed.
*/

#include "Adafruit_NeoTrellis.h"

Adafruit_NeoTrellis trellis;

#define INT_PIN 8

// Input a value 0 to 255 to get a color value.
// The colors are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return trellis.pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return trellis.pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return trellis.pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

//define a callback for key presses
TrellisCallback blink(keyEvent evt){
  
  if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_RISING)
    trellis.pixels.setPixelColor(evt.bit.NUM, Wheel(map(evt.bit.NUM, 0, trellis.pixels.numPixels(), 0, 255))); //on rising
  else if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_FALLING)
    trellis.pixels.setPixelColor(evt.bit.NUM, 0); //off falling
    
  trellis.pixels.show();
  return 0;
}

void setup() {
  Serial.begin(9600);
  //while(!Serial);

  pinMode(INT_PIN, INPUT);
  
  if(!trellis.begin()){
    Serial.println("could not start trellis");
    while(1);
  }
  else{
    Serial.println("trellis started");
  }

  //activate all keys and set callbacks
  for(int i=0; i<NEO_TRELLIS_NUM_KEYS; i++){
    trellis.activateKey(i, SEESAW_KEYPAD_EDGE_RISING);
    trellis.activateKey(i, SEESAW_KEYPAD_EDGE_FALLING);
    trellis.registerCallback(i, blink);
  }

  //do a little animation to show we're on
  for(uint16_t i=0; i<trellis.pixels.numPixels(); i++) {
    trellis.pixels.setPixelColor(i, Wheel(map(i, 0, trellis.pixels.numPixels(), 0, 255)));
    trellis.pixels.show();
    delay(50);
  }
  for(uint16_t i=0; i<trellis.pixels.numPixels(); i++) {
    trellis.pixels.setPixelColor(i, 0x000000);
    trellis.pixels.show();
    delay(50);
  }
}

void loop() {
  if(!digitalRead(INT_PIN)){
    Serial.println("Hello");
  }
  delay(2);
}


When I press the button I get "Hello" printed continuosly but when I let it go it keeps printing.

any idea?

User avatar
Franklin97355
 
Posts: 23939
Joined: Mon Apr 21, 2008 2:33 pm

Re: Interrupt on teensy 4.0 + Adafruits Neotrellis

Post by Franklin97355 »

You might ask in the pjrc forum also. https://forum.pjrc.com/

User avatar
Moris526
 
Posts: 91
Joined: Fri Jan 17, 2020 10:09 am

Re: Interrupt on teensy 4.0 + Adafruits Neotrellis

Post by Moris526 »

Thanks.

I did

User avatar
Moris526
 
Posts: 91
Joined: Fri Jan 17, 2020 10:09 am

Re: Interrupt on teensy 4.0 + Adafruits Neotrellis

Post by Moris526 »

I have more data.

I have 32 Neotrellis boards soldered together in a 4x8 grid

I try with the Adafruits multitrellis example (surely mine has additional problems)

If I load 16 boards (even thou they are all soldered together) interrupt works perfect. If I load more boards the error starts to pop up.

Im with this proyect for a time now. When I was trying an Arduino mega board, having other problems, different people told that the entire grid had too many pullup resistors, each board has 10k pullup. So I unsoldered half of them with no differnece in behaviour. Thay suggested to unsolder 3/4.

Could that thing be affecting the interrupt?

User avatar
Moris526
 
Posts: 91
Joined: Fri Jan 17, 2020 10:09 am

Re: Interrupt on teensy 4.0 + Adafruits Neotrellis

Post by Moris526 »

Hello.

Someone suggested this
I dug into the libraries a bit and it turns out that you have the option of polling or not for a single trellis board, but once you switch over to the multitrellis class, it is simply .read()
Could this be the problem?

User avatar
Moris526
 
Posts: 91
Joined: Fri Jan 17, 2020 10:09 am

Re: Interrupt on teensy 4.0 + Adafruits Neotrellis

Post by Moris526 »

Cant I put some code after trellis.read(false); to stop the If function no matter what?

User avatar
XRAD
 
Posts: 754
Joined: Sat Nov 19, 2016 3:28 pm

Re: Interrupt on teensy 4.0 + Adafruits Neotrellis

Post by XRAD »

are you using the correct ISR interrupt header and correct routines? there are 40 interrupt capable pins on the 4.0

might have to code for trellis arrays and treat each one distinctly....

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

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”