fiduciary

Author Topic: TeensySaber Software Discussion  (Read 67045 times)

0 Members and 3 Guests are viewing this topic.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #255 on: February 05, 2018, 05:16:28 PM »
I'd like to be able to move through the available presets more easily to select the one I want. Right now this is done by holding down the power button when the blade is off and hitting the saber (like a clash) which is a bit cumbersome and slow.

I wonder if this would work: hold down the power button for 2-3 seconds to enter preset selection mode (perhaps acknowledged with a beep and/or the blade blinks) then slowly swinging the blade right causes the next preset to be selected after rotating 10-15 degrees, which is confirmed by a sound and the blade displaying that preset. Swinging left would go to the previous presets. Releasing the button selects the preset.

I've been looking at the code to see if I can do this now. Can I use the Longclick event and some code to check the Z axis rotation?

It will require a little coding, but shouldn't be too difficult to do.
Showing the current setting might cause some minor problems since some of the code won't expect it, but that shouldn't be too difficult to fix.
I have some crude gesture recognition code in DoGesture/ProcessStrokes that might be useful.
This could be a pretty useful feature, so if you do implement it, please share the code. :)

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #256 on: February 06, 2018, 08:13:56 AM »
To checking sampling rate for WAV files: In Windows File Explorer right-click on the column headings (when in detail view) and select Bitrate.
These are the bitrates TeensySaber can play (so if you see any other bitrate, you'll need to convert the audio file):

176kbps = 11kHz 16 bit Mono
352kbps = 22kHz 16 bit Mono, or 11kHz 16 bit Stereo
705kbps = 44kHz 16 bit Mono, or 22kHz 16 bit Stereo
1411kbps = 44kHz 16 bit Stereo

For more detail audio file info, install VLC Media Player, play the audio file and open Tools | Media Information then select the Codec tab.

Audacity tip: When exporting WAV files, the sampling rate is determined by the Project Rate (Hz) found in the lower left corner of the main window.

Offline miib123

  • No Force
  • *
  • Posts: 20
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #257 on: February 06, 2018, 08:49:46 AM »
Hey profezzorn & KanyonKris!

Please look at the picture. It explains my command entry:


- Files are exported with audacity: WAV (Microsoft) signed 16-bit PCM, 352kbps.

- Soldered new wires to SD adapter. The lenght of wires is now aprox. 25mm. Used AWG26 for data pins and 0,25mm2 for powering the SD adapter.

- Sometimes when i program with MTP USB type it just crashes if i open the serial monitor.

- I rearranged the folders so no looks like your example and i even change the path in code.


Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #258 on: February 06, 2018, 09:25:41 AM »
miib123, the filesize for HUM.WAV is huge, 21 MB. You might be getting the file not found error because the file is too large to play, or the file may be corrupt. My biggest hum WAV is 450074. Try playing OPEN.WAV and CLOSE.WAV. And try playing a file in one of your font directories like, play font01/hum.wav.
Also, download the known-good SmoothSwing V2 sound fonts I posted here yesterday and put those on your microSD card and try to play them.
« Last Edit: February 06, 2018, 09:38:05 AM by KanyonKris »

Offline miib123

  • No Force
  • *
  • Posts: 20
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #259 on: February 06, 2018, 10:04:10 AM »
miib123, the filesize for HUM.WAV is huge, 21 MB. You might be getting the file not found error because the file is too large to play, or the file may be corrupt. My biggest hum WAV is 450074. Try playing OPEN.WAV and CLOSE.WAV. And try playing a file in one of your font directories like, play font01/hum.wav.
Also, download the known-good SmoothSwing V2 sound fonts I posted here yesterday and put those on your microSD card and try to play them.

I played all the files all the way defined and nothing worked :(

I downloaded "SmoothSwing V2 sound fonts" too and used "smoothgrey" type. Than i renamed them and put them on a SD card. Tried to play them and same problem exist.

Otherwise, the neopixel strip works great and animations (clash, in/out) too! :)

Man, i'm so near i can feel it. I almost finished 3D printing the graflex hilt to put the electronics inside. When its finished, i'll post some pictures :)

« Last Edit: February 06, 2018, 10:06:21 AM by miib123 »

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #260 on: February 06, 2018, 10:25:23 AM »
Hey profezzorn & KanyonKris!

Please look at the picture. It explains my command entry:


- Files are exported with audacity: WAV (Microsoft) signed 16-bit PCM, 352kbps.

- Soldered new wires to SD adapter. The lenght of wires is now aprox. 25mm. Used AWG26 for data pins and 0,25mm2 for powering the SD adapter.

- Sometimes when i program with MTP USB type it just crashes if i open the serial monitor.

- I rearranged the folders so no looks like your example and i even change the path in code.


This is very strange.
I'm not sure why "hum.wav" is in the root folder, but that's really irrelevant to the problem at hand.
Clearly, you have SD card support enabled, and the teensy found and enabled your sd card, or "dir" wouldn't work.
The "file not found" message, occurs when SD.Open() fails, which is weird because it really looks like the file is there.
The length and content of the file is also irrelevant at this point as that would cause other types of error messages.

When you say "it crashes when I open the serial monitor", what is it that crashes? Is it the teensy or the arduino program?
If the teensy crashes (or locks up) it could mean the SD card wires are still a problem. It's also possible that the SD card is corrupted somehow. I recommend not using MTP for now, as MTP needs to write to the SD card in order to work, and that could corrupt the sd card if the wires are not 100%.  If you don't use MTP, teensysaber will only read from the SD card, which should be safe.

Offline miib123

  • No Force
  • *
  • Posts: 20
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #261 on: February 06, 2018, 10:49:04 AM »
MTP:


I choose "MTP disk". It programs well and it even speaks out the "bank opena failure" and when i open serial monitor,
 the thing on the pictere happens. It's like restart or something like that. Like if i would unplug the USB cable from teensy.

The second thing:

After that MTP experience, i switched the USB type to serial and reuploaded the firmware and then the next problem occured (picture below). This is not the first time, this problem occured. I then just uploaded some other lightsaber version of yours and than the original one (1.9.1) back again and the problem is gone.




The "fail accel setup" can happen when the teensy crashes or is rebooted in the middle of talking to the acceleration chip.
Since the acceleration chip doesn't get rebooted, it's still waiting for the teensy to do something, but the teensy has been restarted and is trying to re-initialize the chip.  This doesn't happen inside a saber, since everything is rebooted when he power is removed.
The solution is to just disconnect the power for a second.

The driver for the V2/V3 has some code that tries to work around this, which works *most* of the time... :)
At this point, I think you should turn off MTP, re-format the SD card and put the files back again and try again.
If it still doesn't work, then I really don't know what to try next, because it seems like it should work, but then it doesn't...
« Last Edit: February 06, 2018, 11:52:19 AM by profezzorn »

Offline miib123

  • No Force
  • *
  • Posts: 20
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #262 on: February 06, 2018, 11:02:45 AM »


The other side:

« Last Edit: February 06, 2018, 11:04:56 AM by miib123 »

Offline gmcivor

  • Force User
  • ***
  • Posts: 140
  • Do or do not. There is no try.
Re: TeensySaber Software Discussion
« Reply #263 on: February 06, 2018, 12:34:06 PM »
I was updated the and I configured the new button setup but it doesn't work properly. I can hold it down and it will play music but I cannot hold the button and clash to make it move to the next preset. It will not move from the battery monitor to the next preset. attached it the v1_config code I have.
Code: [Select]
#ifdef CONFIG_TOP

// V1 electronics
#include "v1_config.h"

// Number of simultaneously connected blades.
// (For interchangeable blades, see the blades[] array.)
#define NUM_BLADES 1

// Number of buttons
#define NUM_BUTTONS 1

// Dual power buttons means that clicking AUX will also turn the saber on.
// If not defined, AUX will go to next preset when off.
//#define DUAL_POWER_BUTTONS

// Volume, useful range is about 0-2000.
#define VOLUME 2000

// If you have two 144 LED/m strips in your blade, connect
// both of them to bladePin and drive them in parallel.
const unsigned int maxLedsPerStrip = 144;

// This defines how sensetive the clash detection is.
#define CLASH_THRESHOLD_G 1.0

// Define this if your power button is a touch button.
//#define POWER_TOUCHBUTTON_SENSITIVITY 1700
// #define AUX_TOUCHBUTTON_SENSITIVITY 1700
// #define AUX2_TOUCHBUTTON_SENSITIVITY 1700

// For V1 electronics, there is an external pullup resistor to measure
// battery voltage. This specifies how many Ohms it is.
#define BATTERY_PULLUP_OHMS 100000

// If your electonics inverts the bladePin for some reason, define this.
// #define INVERT_WS2811

// Feature defines, these let you turn off large blocks of code
// used for debugging.
#define ENABLE_AUDIO
#define ENABLE_MOTION
// #define ENABLE_SNOOZE
#define ENABLE_WS2811

// FASTLED is experimental and untested right now
// #define ENABLE_FASTLED
// #define ENABLE_WATCHDOG
#define ENABLE_SD
#define ENABLE_SERIALFLASH

#endif

#include "GMcommon_presets.h"

#ifdef CONFIG_BUTTONS

// There are currently three available button classes:
// Button (standard momentary button)
// TouchButton (similar to momentary button, but reacts to touch).
// LatchingButton (on/off button, always controls ignition)

 Button PowerButton(BUTTON_POWER, powerButtonPin, "pow");
//Button AuxButton(BUTTON_AUX, auxPin, "aux");
#endif

Thanks for the help and the work you do.

Regards,

GMcIvor

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #264 on: February 06, 2018, 12:42:34 PM »
I was updated the and I configured the new button setup but it doesn't work properly. I can hold it down and it will play music but I cannot hold the button and clash to make it move to the next preset. It will not move from the battery monitor to the next preset. attached it the v1_config code I have.
Code: [Select]
#ifdef CONFIG_TOP

// V1 electronics
#include "v1_config.h"

// Number of simultaneously connected blades.
// (For interchangeable blades, see the blades[] array.)
#define NUM_BLADES 1

// Number of buttons
#define NUM_BUTTONS 1

// Dual power buttons means that clicking AUX will also turn the saber on.
// If not defined, AUX will go to next preset when off.
//#define DUAL_POWER_BUTTONS

// Volume, useful range is about 0-2000.
#define VOLUME 2000

// If you have two 144 LED/m strips in your blade, connect
// both of them to bladePin and drive them in parallel.
const unsigned int maxLedsPerStrip = 144;

// This defines how sensetive the clash detection is.
#define CLASH_THRESHOLD_G 1.0

// Define this if your power button is a touch button.
//#define POWER_TOUCHBUTTON_SENSITIVITY 1700
// #define AUX_TOUCHBUTTON_SENSITIVITY 1700
// #define AUX2_TOUCHBUTTON_SENSITIVITY 1700

// For V1 electronics, there is an external pullup resistor to measure
// battery voltage. This specifies how many Ohms it is.
#define BATTERY_PULLUP_OHMS 100000

// If your electonics inverts the bladePin for some reason, define this.
// #define INVERT_WS2811

// Feature defines, these let you turn off large blocks of code
// used for debugging.
#define ENABLE_AUDIO
#define ENABLE_MOTION
// #define ENABLE_SNOOZE
#define ENABLE_WS2811

// FASTLED is experimental and untested right now
// #define ENABLE_FASTLED
// #define ENABLE_WATCHDOG
#define ENABLE_SD
#define ENABLE_SERIALFLASH

#endif

#include "GMcommon_presets.h"

#ifdef CONFIG_BUTTONS

// There are currently three available button classes:
// Button (standard momentary button)
// TouchButton (similar to momentary button, but reacts to touch).
// LatchingButton (on/off button, always controls ignition)

 Button PowerButton(BUTTON_POWER, powerButtonPin, "pow");
//Button AuxButton(BUTTON_AUX, auxPin, "aux");
#endif

Thanks for the help and the work you do.

Regards,

GMcIvor

Weird, the button definition looks right.
Does clashes work at all?
What do you see in the serial monitor?
It may be that the saber is "on" (which looks pretty much the same when charging) You just can't switch presets when the saber is on.

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #265 on: February 06, 2018, 12:42:50 PM »
miib123, your wires look short enough.

In case you missed it, I agree with profezzorn, plug your microSD card into your computer and reformat it (mine is FAT32), then copy all the files back onto it and try it in your saber electronics. If that doesn't work, perhaps try a different microSD card.
« Last Edit: February 07, 2018, 09:38:36 AM by KanyonKris »

Offline gmcivor

  • Force User
  • ***
  • Posts: 140
  • Do or do not. There is no try.
Re: TeensySaber Software Discussion
« Reply #266 on: February 06, 2018, 01:21:14 PM »

Weird, the button definition looks right.
Does clashes work at all?
What do you see in the serial monitor?
It may be that the saber is "on" (which looks pretty much the same when charging) You just can't switch presets when the saber is on.
[/quote]

No nothing works. The first preset it boots into when I plug the blade on is the battery monitor preset. The battery will flash and I can make music play by holding down the button. But it will not switch presets.

I will connect to the serial monitor and see. But it is super weird.

So in the serial monitor I can use all the commands and make it work. holding the button and clashing does not trigger the next preset. I am super confused, but I know it is something simple. On some fonts when I type "off" the hum will stay playing and will stop once I type "next preset"

Regards,

GMcIvor


« Last Edit: February 06, 2018, 01:32:04 PM by gmcivor »

Offline KanyonKris

  • Padawan Learner
  • **
  • Posts: 72
  • Um...Hello?
Re: TeensySaber Software Discussion
« Reply #267 on: February 06, 2018, 01:39:21 PM »
Try forcing it to use the blade you have plugged in by commenting out everything else in BladeConfig (in your common_presets.h file). We had issues with our boards not correctly identifying blades so using only one blade config got it working until we could figure out the blade identification problem.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #268 on: February 06, 2018, 01:44:13 PM »
Try forcing it to use the blade you have plugged in by commenting out everything else in BladeConfig (in your common_presets.h file). We had issues with our boards not correctly identifying blades so using only one blade config got it working until we could figure out the blade identification problem.

Good point. If the saber thought you were using a charging blade, there might only be one preset for that, so switching isn't possible.
(No way for me to know unless you show me "GMcommon_presets.h".)

Offline gmcivor

  • Force User
  • ***
  • Posts: 140
  • Do or do not. There is no try.
Re: TeensySaber Software Discussion
« Reply #269 on: February 06, 2018, 01:46:26 PM »
Code: [Select]
#ifdef CONFIG_PRESETS

// CONFIGURABLE
// Each preset line consists of:
// { "font directory", "sound track", Style },
// Where Style is one of:
//   StyleNormalPtr<BaseColor, FlashColor, out millis, in millis>()
//   StyleFirePtr<LowHeatColor, HighHeatColor>()
//   StyleRainBowPtr<out millis, in millis>()
//   StyleStrobePtr<BaseColor, FlashColor, out millis, in millis>()
//   &style_charging
// All colors can be specied as three numbers or using one the handy macros above.
// If you wish to have different presets for different blades, copy this array and
// name it something other than "preset", then use the new name inside the blade
// configuration array below. See "simple_presets" and "charging_presets"
// below for examples.
Preset presets[] = {
  { "Boot", "tracks/Ftheme.wav", &style_charging },
  { "Fonts/Graflex7", "Tracks/SIntro.wav",
    StylePtr<InOutSparkTip<EASYBLADE(BLUE, WHITE), 300, 800> >() },
  { "Fonts/Graflex4", "Tracks/Ftheme.wav", StyleNormalPtr<CYAN, WHITE, 300, 800>() },
  { "Fonts/MPP", "Tracks/Vader.wav", StyleNormalPtr<RED, Orange, 300, 800>() },
  { "Fonts/Kylo", "Tracks/Kintro.wav", StyleFirePtr<RED, Orange>() },
  { "Fonts/Windu", "Tracks/Cantina.wav",
   StylePtr<InOutSparkTip<EASYBLADE(DeepPink, Pink), 300, 800> >() },
  { "Fonts/Yoda1", "Tracks/Cantina.wav",
   StylePtr<InOutHelper<EASYBLADE(OnSpark<GREEN>, WHITE), 300, 800> >() },
  { "Fonts/Grievous", "Tracks/Gintro.wav", StyleFirePtr<GREEN, CYAN>() },
  { "Fonts/ROTJ", "Tracks/Cantina.wav", StyleNormalPtr<SpringGreen, Orange, 300, 800>() },
  { "Fonts/MKVI", "Tracks/Cantina.wav", StyleNormalPtr<SteelBlue, Tomato, 300, 800>() },
  { "Fonts/Master", "Tracks/Gintro.wav", StyleNormalPtr<Gradient<RED, BLUE>, Gradient<Orange, CYAN>, 300, 800>() },
  { "Fonts/StandIs", "Tracks/Cantina.wav", StyleRainbowPtr<300, 800>() },
//{ "Fonts", "Tracks/Cantina.wav", &style_pov },
};

//Preset red_presets[] = {
 // { "igniter/font2", "tracks/vader.wav", StyleNormalPtr<RED, WHITE, 100, 200>()},
 // { "caliban", "tracks/duel.wav", StyleNormalPtr<RED, WHITE, 100, 200>()},
 // { "font02", "tracks/cantina.wav", StyleStrobePtr<RED, WHITE, 15, 100, 200>()},
//};

//Preset simple_presets[] = {
 // { "font01", "tracks/title.wav", StyleNormalPtr<BLUE, WHITE, 100, 200>() },
 // { "font02", "tracks/duel.wav", StyleNormalPtr<BLUE, WHITE, 100, 200>() },
 //{ "font02", "tracks/cantina.wav", StyleStrobePtr<BLUE, WHITE, 15, 100, 200>() },
//};

//Preset white_presets[] = {
  //{ "font01", "tracks/title.wav", StyleNormalPtr<WHITE, WHITE, 100, 200>() },
  //{ "font02", "tracks/duel.wav", StyleNormalPtr<WHITE, WHITE, 100, 200>() },
  //{ "font02", "tracks/cantina.wav", StyleStrobePtr<WHITE, WHITE, 15, 100, 200>() },
//};

Preset charging_presets[] = {
  { "charging", "", &style_charging },
};

// CONFIGURABLE
// Each line of configuration should be:
//     { blade id resistor ohms, blade, CONFIGARRAY(array of presets) },
// Where "blade", can be one of the following:
//     WS2811BladePtr<number of leds, WS2811 configuration flags>()
//     SimpleBladePTR<Color of channel 1, color of channel 2, color of channel 3, color of channel 4>()
// All colors can be specied as three numbers or using one the handy macros above.

BladeConfig blades[] = {
#ifdef ENABLE_WS2811
  // PL9823 blade, 73 LEDs
  {   3300, WS2811BladePtr<73, WS2811_580kHz>(), CONFIGARRAY(presets) },

  // Charging adapter, single PL9823 LED.
  {  10000, WS2811BladePtr<1, WS2811_580kHz>(), CONFIGARRAY(charging_presets) },
 
  // PL9823 blade, 2 LEDs
  {   2200, WS2811BladePtr<2, WS2811_580kHz>(), CONFIGARRAY(presets) },
 
  // For testing (makes the charging blade behave like a normal blade.)
  //  {  15000, WS2811BladePtr<1, WS2811_580kHz>(), CONFIGARRAY(presets) },

  // WS2811 string blade 144 LEDs
  //{   7800, WS2811BladePtr<144, WS2811_ACTUALLY_800kHz | WS2811_GRB>(), CONFIGARRAY(presets) },
#endif

  // Simple blue string blade.
  //{   5200, SimpleBladePtr<Blue3mmLED,Blue3mmLED,Blue3mmLED,NoLED>(), CONFIGARRAY(simple_presets) },

  // Blue-Blue-White LED star
  //{ 20000, SimpleBladePtr<CreeXPE2White, CreeXPE2Blue, CreeXPE2Blue, NoLED>(), CONFIGARRAY(simple_presets) },

  // Blue LED string (with green flourescent tube)
  //{ 27000, SimpleBladePtr<Blue8mmLED100, Blue8mmLED100, Blue8mmLED100, NoLED>(), CONFIGARRAY(simple_presets) },

  // Red LED string
//  { 33000, SimpleBladePtr<Red8mmLED100, Red8mmLED100, Red8mmLED100, NoLED>(), CONFIGARRAY(red_presets) },

  // 3 x Cree XL-L LED star
  //{ 100000, SimpleBladePtr<CreeXPL, CreeXPL, CreeXPL, NoLED>(), CONFIGARRAY(white_presets) },
};

#endif

I am using my 73 LED blade.. I will comment everything out and see if I can get it to work.

So I commented out the battery charge preset and the button work to turn it on and off but the clash does not work.... but clashh will trigger from the serial monitor but not the button... We are getting somewhere.
« Last Edit: February 06, 2018, 02:37:19 PM by gmcivor »

 

retrousse