fiduciary

Author Topic: TeensySaber Software Discussion  (Read 67122 times)

0 Members and 2 Guests are viewing this topic.

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
PL9823 blade + 1 LED
« Reply #180 on: December 19, 2017, 11:14:26 PM »
I see in the release notes for 1.175 along with 8 blades this also supports auxiliary LEDs, but I'm having trouble figuring out how it works.

I have a saber with a PL9823 string for the main blade and a red accent ring around the main power button.  I'd like to control the red accent ring, make it pulse, flash, etc. How do I configure it?

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: ENABLE_AUDIO
« Reply #181 on: December 19, 2017, 11:17:32 PM »
First, I got my saber working! I'll post video in the hardware thread.

During bring-up I disabled audio by commenting out "#define ENABLE_AUDIO" but found that the dynamic mixer was still called out in a few places so I added some #ifdef code to deal with it and allow the code to compile. Here's the code:

Code: [Select]
template<class A, class B>
class AudioFlicker {
public:
  void run(BladeBase* blade) {
    a_.run(blade);
    b_.run(blade);
#ifdef ENABLE_AUDIO
    mix_ = clampi32(dynamic_mixer.last_sum() >> 4, 0, 255);
#else
    mix_ = random(255);
#endif
  }
  OverDriveColor getColor(int led) {
    OverDriveColor a = a_.getColor(led);
    OverDriveColor b = b_.getColor(led);
    a.c = a.c.mix(b.c, mix_);
    return a;
  }
private:
  A a_;
  B b_;
  int mix_;
};

Code: [Select]
    if (!strcmp(cmd, "get_volume")) {
#ifdef ENABLE_AUDIO
      STDOUT.println(dynamic_mixer.get_volume());
#else
      STDOUT.println("No mixer, can't get volume");
#endif
      return true;
    }

Code: [Select]
    if (!strcmp(cmd, "get_volume")) {
#ifdef ENABLE_AUDIO
      STDOUT.println(dynamic_mixer.get_volume());
#else
      STDOUT.println("No mixer, can't get volume");
#endif
      return true;
    }
    if (!strcmp(cmd, "set_volume") && arg) {
      int32_t volume = strtol(arg, NULL, 0);
      if (volume >= 0 && volume <= 3000)
#ifdef ENABLE_AUDIO
        dynamic_mixer.set_volume(volume);
#else
      STDOUT.println("No mixer, can't set volume");
#endif
      return true;
    }

Thanks for the patches, I will make sure that future versions compile without ENABLE_AUDIO

Offline spearson

  • No Force
  • *
  • Posts: 20
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #182 on: December 26, 2017, 09:24:42 AM »
Question,

I broke my buttons (used super glue on the plungers and it soaked all around and ruined the buttons), so I've been doing my testing using serial monitor and I have disconnected the physical buttons.   I have my fonts loaded, and they seem to be working correctly, but I have a couple issues and I'm not sure if it's just using Serial Monitor that is the problem, or something else.

1)  Verify - Upload - Open Serial Monitor -- sometimes first LED is lit green, no sound, nothing else on.
2)  Using either "on" or "pow", ignites the saber, blade lights up, out sound and hum starts
3)  Using either "off" or "pow", this turns the blade off, but most of the time with the following issues:
-- The very first pixel stays lit, sometimes green, sometimes blue, sometimes off.
-- hum does not turn off

If I power on, and power off a couple times, the first pixel will turn off
The only way to get hum to turn off, is to press the "aux" button (or rather type the command).

I have also clipped off 3 LEDS from my my 144 LED strip.  I have set both spots that I can find with 141 from 144:
{   10000, WS2811BladePtr<141, WS2811_ACTUALLY_800kHz | WS2811_GRB>(), CONFIGARRAY(presets) },
const unsigned int maxLedsPerStrip = 141;

Any thoughts?  I'm working on getting my physical buttons replaced, but until I'll keep plugging away.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #183 on: December 26, 2017, 10:15:38 AM »
Question,

I broke my buttons (used super glue on the plungers and it soaked all around and ruined the buttons), so I've been doing my testing using serial monitor and I have disconnected the physical buttons.   I have my fonts loaded, and they seem to be working correctly, but I have a couple issues and I'm not sure if it's just using Serial Monitor that is the problem, or something else.

1)  Verify - Upload - Open Serial Monitor -- sometimes first LED is lit green, no sound, nothing else on.
2)  Using either "on" or "pow", ignites the saber, blade lights up, out sound and hum starts
3)  Using either "off" or "pow", this turns the blade off, but most of the time with the following issues:
-- The very first pixel stays lit, sometimes green, sometimes blue, sometimes off.
-- hum does not turn off

If I power on, and power off a couple times, the first pixel will turn off
The only way to get hum to turn off, is to press the "aux" button (or rather type the command).

I have also clipped off 3 LEDS from my my 144 LED strip.  I have set both spots that I can find with 141 from 144:
{   10000, WS2811BladePtr<141, WS2811_ACTUALLY_800kHz | WS2811_GRB>(), CONFIGARRAY(presets) },
const unsigned int maxLedsPerStrip = 141;

Any thoughts?  I'm working on getting my physical buttons replaced, but until I'll keep plugging away.

This is all quite strange. Unfortunately I'm on vacation, so I can't try things myself right now, but I have a few observations and a couple of things we can try to see if we can narrow down the problem.
First of all, what kind of sound font are you using? Is it NEC or Plecter style?
The first-pixel-problem might be an issue in the code, as other people have reported similar issues, it may also be a problem caused by not having a resistor on the neopixel data line.
(When the teensy turns off the power to the neopixels, they can still suck some power from the data line and stay on in some circumstances.)
One more thing: There is no need to change the maxLedsPerStrip constant. (But changing it shouldn't actually cause problems either, unless there is a bug in my code...)
Finally, the "whatison" command may be helpful in diagnosing why the hum keeps playing.


Offline spearson

  • No Force
  • *
  • Posts: 20
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #184 on: December 26, 2017, 10:42:18 AM »
I have a 100 ohm resistor on the data line, maybe that's too low from some of the things I've read.  I'll also keep an eye on when it stays on versus my battery voltage.  My voltage is now at 3.01 volts and I no longer have the first LED staying on after pow on off commands, but it is on when first connected and programmed/rebooted.   

I have an NEC font, in a directory named "fonts", and in my presets I have the directory as "fonts", and soundtrack I left blank because I don't have anything to play here.  All the basic fonts seem to play correctly, in and out, hum, clash and lockup, and the font.wav plays each time I change a preset.

The 'whatison' command outputs this after a 'pow' to turn off:
Saber bases: Off
Audio splicer: Off
Beeper: Off
Talker: Off
Wav player 0: On (eof =  0)
Wav player 1: Off (eof =  1)
Wav player 2: Off (eof =  0)
Wav player 3: Off (eof =  0)
Wav player 4: Off (eof =  0)
Wav player 5: Off (eof =  0)

after entering "aux" command
Saber bases: Off
Audio splicer: Off
Beeper: Off
Talker: Off
Wav player 0: Off (eof =  1)
Wav player 1: Off (eof =  0)
Wav player 2: Off (eof =  0)
Wav player 3: Off (eof =  0)
Wav player 4: Off (eof =  0)
Wav player 5: Off (eof =  0)

I'll trace through what "pow" is doing and see if I can find anything.

I might have other issues too, I just noticed that only one strip is lit up now, so that's fun.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #185 on: December 26, 2017, 01:12:21 PM »
I have a 100 ohm resistor on the data line, maybe that's too low from some of the things I've read.  I'll also keep an eye on when it stays on versus my battery voltage.  My voltage is now at 3.01 volts and I no longer have the first LED staying on after pow on off commands, but it is on when first connected and programmed/rebooted.   

I have an NEC font, in a directory named "fonts", and in my presets I have the directory as "fonts", and soundtrack I left blank because I don't have anything to play here.  All the basic fonts seem to play correctly, in and out, hum, clash and lockup, and the font.wav plays each time I change a preset.

The 'whatison' command outputs this after a 'pow' to turn off:
Saber bases: Off
Audio splicer: Off
Beeper: Off
Talker: Off
Wav player 0: On (eof =  0)
Wav player 1: Off (eof =  1)
Wav player 2: Off (eof =  0)
Wav player 3: Off (eof =  0)
Wav player 4: Off (eof =  0)
Wav player 5: Off (eof =  0)

after entering "aux" command
Saber bases: Off
Audio splicer: Off
Beeper: Off
Talker: Off
Wav player 0: Off (eof =  1)
Wav player 1: Off (eof =  0)
Wav player 2: Off (eof =  0)
Wav player 3: Off (eof =  0)
Wav player 4: Off (eof =  0)
Wav player 5: Off (eof =  0)

I'll trace through what "pow" is doing and see if I can find anything.

I might have other issues too, I just noticed that only one strip is lit up now, so that's fun.

Do you have ENABLE_MOTION in your config file?
It seems like the polyphonic font handler doesn't actually turn the hum off, it only fades it to zero volume.
However, the fade is driven by the motion event handler, so it won't work if you're not receiving motion events for some reason. (Like, if ENABLE_MOTION is not defined.)

On a related note, I may have found and fixed some bugs in the polyphonic font handler, so I uploaded a new (and untested) version of the software here:  http://fredrik.hubbe.net/lightsaber/lightsaber-1.181.zip
Also, in fonts/config.ini, is there a field called "humStart" ? If so, what is it's value?

Offline spearson

  • No Force
  • *
  • Posts: 20
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #186 on: December 26, 2017, 02:02:51 PM »
Well that makes sense I have ENABLE_MOTION commented out because it was preventing the Serial Monitor from working.

I do not appear to have a config.ini file. 

Offline spearson

  • No Force
  • *
  • Posts: 20
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #187 on: December 26, 2017, 06:54:23 PM »
I think this first LED being lit issue is probably related to a wiring issue on my blade.  I just spent the last hour playing with it and both strips were working and no LEDs were remaining lit.  But then I moved my saber, and one strip went out, and when I moved the blade I got a flicker on the bad strip + I got the first LED lit again. 

I'll redo my blade and report back. 

Can I move my data line resister to be between the board and the AV connector instead of between the string and AV connector? 

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #188 on: December 27, 2017, 02:07:22 AM »
Well that makes sense I have ENABLE_MOTION commented out because it was preventing the Serial Monitor from working.

Well that solves that mystery.
However, if ENABLE_MOTION causes the serial monitor to not work, it would seem that you have a problem with your motion chip(s).

Can I move my data line resister to be between the board and the AV connector instead of between the string and AV connector?

Yes you can. It will add to the blade ID resistance, so if you're using blade ID to identify blades, you'll need to add the value of the resistor to each entry.

Offline spearson

  • No Force
  • *
  • Posts: 20
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #189 on: December 27, 2017, 07:01:34 AM »
You had it in your troubleshooting page to try disabling it and audio if the Serial Monitor wasn't working, so now that I do have it working, I'll try enabling it and see if I have any issues.

Offline TTFRAZ

  • No Force
  • *
  • Posts: 17
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #190 on: December 28, 2017, 08:06:59 AM »
I’m wiring up the resistor for the ws2811 and I believe the amps for the entire led strip is calculated to 9.72. And they are 5 volt led. In you example you said yours were only 3.2. Can you help figure out which resistor I should use. Or even if I can use these LEDs?

Offline TTFRAZ

  • No Force
  • *
  • Posts: 17
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #191 on: December 28, 2017, 11:09:44 AM »
Also I keep getting this error massage and not sure how to resolve it. I've changed multiple settings and none seem to work

Quote
Arduino: 1.8.5 (Mac OS X), TD: 1.40, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz (overclock), Faster, US English"

In file included from /Users/taylorignacio/Documents/LightSabers/lightsaber/lightsaber.ino:6384:0:
Taylors_Jedi_Saber.h:18: error: cannot convert 'BladeStyle*' to 'const char*' in initialization
 };
 ^
Taylors_Jedi_Saber.h:18: error: cannot convert 'const char*' to 'BladeStyle*' in initialization
Multiple libraries were found for "SD.h"
 Used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/SD
 Not used: /Applications/Arduino.app/Contents/Java/libraries/SD
cannot convert 'BladeStyle*' to 'const char*' in initialization

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

heres my preset page

Quote
#ifdef CONFIG_PRESETS
Preset light[] = {
   { "Corellian",
    StyleNormalPtr<OnSpark<Gradient<WHITE, CYAN>, WHITE, 800>, WHITE, 300, 500>(), "justice"},
}; <- this is the part in question
BladeConfig blades[] = {
 { 0, WS2811BladePtr<54, WS2811_ACTUALLY_800kHz | WS2811_GRB>(), CONFIGARRAY(light) },
 };
#endif

Offline TTFRAZ

  • No Force
  • *
  • Posts: 17
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #192 on: December 28, 2017, 01:05:15 PM »
Fixed the error. Its was in the way my preset was set up

But now when i go to upload to the teensy it says the lightsaber.ino.hex is too large. has anyone experienced this before?
« Last Edit: December 28, 2017, 01:26:24 PM by TTFRAZ »

Offline TTFRAZ

  • No Force
  • *
  • Posts: 17
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #193 on: December 28, 2017, 03:53:03 PM »
Just looked into it a bit more and noticed the led on the Teensy isn’t lighting up. Perhaps I fried something while soldering or there’s a wiring error. Tho I wired it up to the Teensy saber and accessories just as it was in the diagram

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #194 on: December 29, 2017, 01:04:55 AM »
I’m wiring up the resistor for the ws2811 and I believe the amps for the entire led strip is calculated to 9.72. And they are 5 volt led. In you example you said yours were only 3.2. Can you help figure out which resistor I should use. Or even if I can use these LEDs?

The LED strips will draw less than 9.72 amps, because they won't get the full 5 volts.
WS2811 strips have internal current limiting, so they don't need resistors on the power line.
However, they do need a resistor on the data line to make sure the strip turns off properly when not in use. A 100-300 ohm resistor is recommended.

 

retrousse