Go Down

Topic: LPD6803 adalight issue (Read 206 times) previous topic - next topic

lewye

Mar 17, 2015, 02:07 am Last Edit: Mar 17, 2015, 02:10 am by lewye
Arduino working code does not work teensy3.1     pin 11 pin 13 tied  teensy3.1
Code: [Select]
   
TCCR1B |= clockSelectBits;                                                     // reset clock select register


I get an error
'
TCCR1B' was not declared in this scope

 teensy3.1   LPD6803 led for How do I find the code to work
please help

Code: [Select]

/*
 * A 'fork' of the adalight code, with a nice case statement.
 *
 * Tested with the LPD6803 50 led string
 * should work with the WS2801 as well
 */
#include "FastSPI_LED.h"

#define NUM_LEDS 110
/*
 * pin 11 -> blue  for the LPD6803 'yellow' for the WS2801 string
 * pin 13 -> green for the LPD6803 'green' for the WS2801 string
 */


#define PIN 4

#define MODE_HDRA 0
#define MODE_HDRd 1
#define MODE_HDRa 2
#define MODE_HDRhi 3
#define MODE_HDRlo 4
#define MODE_HDRchk 5
#define MODE_DATAr 6
#define MODE_DATAg 7
#define MODE_DATAb 8

// Sometimes chipsets wire in a backwards sort of way
struct CRGB { unsigned char r; unsigned char b; unsigned char g; };
struct CRGB *leds;

unsigned long t,
  startTime,
  lastByteTime,
  lastAckTime;

uint8_t hi, lo, chk,
  mode          = MODE_HDRA;

int channels,channel;

void setup()
{
  Serial.begin(115200);
  FastSPI_LED.setLeds(NUM_LEDS);

  //Change this to match your led strip
  FastSPI_LED.setChipset(CFastSPI_LED::SPI_LPD6803);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_TM1809);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_HL1606);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_595);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_WS2801);

  FastSPI_LED.setPin(PIN);
  //Change datarate to match your led strip as well
  FastSPI_LED.setDataRate(3);

  FastSPI_LED.init();
  FastSPI_LED.start();
 
  leds = (struct CRGB*)FastSPI_LED.getRGBData();
  clearLeds();

  Serial.print("Ada\n");
  lastByteTime = startTime = lastAckTime = millis();
}

int readByte(){
  while(Serial.available()==0){
    ;
    //FastSPI_LED.stop();
  }
  //FastSPI_LED.start();
  return Serial.read();
}

void clearLeds(){
  memset(leds, 0, NUM_LEDS * 3);
  FastSPI_LED.show();
  delay(20);
}

void loop(){
  int16_t c;

  c = readByte();
  t = millis();

  if((t - lastAckTime) > 1000) {
    Serial.print("Ada\n"); // Send ACK string to host
    lastAckTime = t; // Reset counter
  }
  if ((t - lastByteTime) > 5000) {
    mode = MODE_HDRA;     // After 5 seconds reset to HDRA
  }
  lastByteTime = t;
  lastAckTime = t;
 
  switch(mode){
  case MODE_HDRA:
    if (c == 0x41) {
      mode = MODE_HDRd;
    }
    break;
  case MODE_HDRd:
    if (c == 0x64) {
      mode = MODE_HDRa;
    }
    break;
  case MODE_HDRa:
    if (c == 0x61) {
      mode = MODE_HDRhi;
    }
    break;
  case MODE_HDRhi:
    hi = c;
    mode = MODE_HDRlo;
    break;
  case MODE_HDRlo:
    lo = c;
    mode = MODE_HDRchk;
    break;
  case MODE_HDRchk:
    chk = c;
    if (chk == (hi ^ lo ^ 0x55)){
      mode = MODE_DATAr;
      channels = (long)hi*256+(long)lo;
      channel = 0;
     } else {
      // wrong checksum, reset header
      mode = MODE_HDRA;
    }
    break;
  case MODE_DATAr:
    // we are in the data business ;-)
    // ignore all data for channels higher than NUM_LEDS
    if (channel<NUM_LEDS) { leds[channel].r = c; }
    mode = MODE_DATAb;
    break;
  case MODE_DATAb:
    // we are in the data business ;-)
    // ignore all data for channels higher than NUM_LEDS
    if (channel<NUM_LEDS) { leds[channel].b = c; }
    mode = MODE_DATAg;
    break;
  case MODE_DATAg:
    // we are in the data business ;-)
    // ignore all data for channels higher than NUM_LEDS
    if (channel<NUM_LEDS) { leds[channel].g = c; }
    channel++;
    if (channel>channels) {
      FastSPI_LED.show();
      mode = MODE_HDRA;
    } else {
      mode = MODE_DATAr;
    }
    break;
  default:
    // I should not be here, back to
    mode = MODE_HDRA;
  }   
}

Riva

I might seem like an idiot but remember it takes one to know one.
Forum user generally fall into three categories (the good, the bad & the a**hole) what category do you fit in?

Grumpy_Mike

Quote
I get an error
'
TCCR1B' was not declared in this scope
Yes because the processor inside a teensy3 is not the same thing as the processor inside an Arduino. That TCCR1B is a processor timer register which simply does not exist inside an teensy.

lewye

I have no information about software  How it works well get my teensy3

Grumpy_Mike

Quote
Arduino working code does not work teensy3.1
Yes this is correct.
Unless it has been designed to work on the teensy3 it will not work on it. This applies to all code that access the fundamental hardware inside the chip.

lewye

#5
Mar 18, 2015, 12:25 pm Last Edit: Mar 18, 2015, 12:36 pm by lewye
So the above code Arduino due also trying to ?
2 Arduino Uno with arduino occur due to the difference in speed up to 150 LEDs?

Grumpy_Mike

Quote
So the above code Arduino due also trying to ?
Yoda speaking like you are.

Quote
2 Arduino Uno with arduino occur due to the difference in speed up to 150 LEDs?
You got me on that, no idea what you are saying.

lewye

Arduino due Does the above code works

Grumpy_Mike

Arduino due Does the above code works
No.
That is a different processor to the Uno.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy