If you don't mind to review my config. Comments and questions added in the config

Hello @profezzorn ,

Thank you for your insight. I had not noticed there was two different syntax.

I don’t think I red anything about that. I did see in some sound fonts some Alt-sounds but I don’t know anything about it or what they are for ?

I have been thinking about the following for the last few days.

So I came up with several ideas (to achieve the same thing) while reading through the code of dual_props.h, the files in buttons and several others *.h (for which I have, mostly, no idea what they do, especially the ones that don’t have any “// xxx…” with your notes).

idea 1) My favorite idea would be to create a new prop (I’d call it “multi_prop.h” which is based on dual_prop.h and would replace blade detect with “two buttons long push”, and would allow to switch from saber to blaster to saber to detonator and back to saber. The idea of the code would be something like this :

"create variable" "state_of_prop" (value 0 or 1 or 2) 
          // "state_of_prop" = 0 = saber, = 1 = blaster, = 2 = detonator
"create variable" "previous_state_of_prop" (value 1 or 2)
          // "previous_state_of_prop" = 1 = blaster, = 2 = detonator
if (two buttons long push detected)
          // or even "very" long push, if there is already a 2 buttons long push in POS
          // I am referring to "BUTTON_HELD_LONG_TIMEOUT 2000" from ".../buttons/button_base.h, could add "BUTTON_HELD_VERY_LONG_TIMEOUT 4000"
then
   if "state_of_prop" different than 0 (zero)
  then - set "state_of_prop" to 0
       - switch to saber and buttons behave like saber 
  else
     if "previous_state_of_prop" = 1
     then - set "previous_state_of_prop" to 2
  //the idea is for the prop to "remember" what state it was before being a saber
          - set "state_of_prop" to 2
          - switch to detonator and buttons behave like detonator
     else - set "previous_state_of_prop" to 1
          - set "state_of_prop" to 1
          - switch to blaster and buttons behave like blaster (and lets not forget bullet counts for the OLED)
     endif
endif

idea 2) create a “dual_prop2.h” where “blade detect” is replaced by “two buttons long push”. The problem I see is that “blade detect” is a latching switch and the “two buttons long push” are not.

idea 3) add a 3rd latching button on my saber and replace “blade detect” in “dual_prop.h” with the 3rd button. How would I wire the third button while still keeping blade detect (I want my light saber to be able to do everything) ?

idea 4) While looking at the configurator for Pfoffie V3 for idea 3), I saw the Touchbutton. Maybe it could be used in idea 1) where the top is blaster, the middle is saber & the bottom is thermal detonator or what ever order you choose. But that might be a “waste of use” of a very “fancy” button ? Like you said:

Anyways, thank you for reading my (long) post. Hope you recover from your jet-lag quickly.

Expending what was created by others, that I can see but creating from scratch is not my forte.

P.S.: My trick to combat jet-lag as quickly as possible (I travel a lot for work) for flights from EU to US. or Far-East to EU.

  1. If you arrive in daytime, take a nap but not more than 2-3 hours (set at least 2 alarms 5 minutes apart, the second alarm out of reach from the bed) and kick yourself out of bed if you have to.
  2. go out with some friends or colleagues and have dinner.
  3. go to bed at normal time or at least no too late.
  4. next day back to normal schedule and no nap.
    From US to EU is a bit harder but:
  5. Go out and drink a bit more than usual so you can go sleep at a time when your body/brain doesn’t want to.
  6. Wake up for breakfast with 2 alarms like above.
  7. If needed, take a nap not longer than 2-3 hours.
  8. Go out for dinner with friends or colleagues
  9. Go to bed at normal time.

Hope it helps.

P.P.S.: Maybe this post should/could be moved to a new “multi_prop” thread ?

I’m confused about what this means.
Also, why would a prop be a saber and a blaster and a detonator?

That’s not a problem. (in fact, it might make it easier)
Still, why?

Why not just use blade detect?

The touch button works like a momentary button at this time. I’ve been contemplating adding ways to use two touch-buttons to detect where the finger is located on the button, but it’s not written yet.

Cool, I learn everyday :grinning:

If I may, I believe there are two words ommision in the text:

Controlling which alternative is used.

Ok, so now our font (or sound font) has two sets of hum and force sounds, but how do we select which set of sounds is actually used? ProffieOS does not actually do anything to select which alternative is used by default, it just provides ways for you to do it, either from a blade style, or from a prop. I will now describe a few ways that this could work, but it’s by no means the only ways.

Because my kids would love it for their “pretend play”. And I don’t have the funds to get them a lightsaber, a blaster and a thermal detonator. They have just finished watching Star Wars Rebels and they love Ezra’s lightsaber. They would also go “That’s so cool it can do that!” . It doesn’t need to be cannon.

Because at the moment I only have a baselit blade plug and since I am finally in the process of buying a house, my “cash for fun” will be limited for some time. So it will take a while before I will purchase a proper blade, let alone 3, one for each of us.

It could also be saber to blaster to detonator and back to blade.

I thought it might “work like” a sliding potentiometer but in a “touch screen” format.

There is an edit button in the top right corner.

Combining props together is definitely not the simplest thing in the world. Learning coding by doing that would definitely be jumping into the deep end, but it’s entirely possible, and I don’t mind helping.

Correction submitted.

Yes, I am sure it will be difficult for me. For starters I would be happy to “just” change blade detect with the 2 buttons long push as a switch between blade and blaster. I just finished working on “my version” of dual_prop.h. I named it multi_prop_“+suffix”.h but as far as the code is concerned, see it as multi_prop.h

So here is my newbie first attempt at C++, it is ok if you laugh, I know I inserted quite a bit of whish-full “what I want it to do”.

multi_prop_attempt_001.h (4.4 KB)

I have changed everything that has to do with blade detect and latching switch (at least for the parts I think I understand). And I tried to adapt it to a TWO_BUTTON_X_LONG_PUSH type of event.

Please enjoy the laugh.

Oh! And if possible, I would like to only mess with your "dual_props.h, re-named “multi_props.h” so I don’t mess with anymore files than I need to, to achieve a 3 “props in one”. If possible ?

I don’t see it in my list of pending PRs though…

Does this compile?

In some cases, it may be needed to make some changes to the props, or prop_base.h to make things work, but most changes should be limited to the multi_props.h file I think.

I am new to Github as well.
I clicked on the pencil icon, it opened

I edited the text, clicked on “Commit changes…”, added a title and a description of the changes, clicked “propose change” and got a message " Able to merge. These branches can be automatically merged."

I didn’t click on create pull request, but now I did.

Not at all. But I whish.
here is the error log extract:


In file included from C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\config\olicomplex1.4.1_test_multi_prop_attempt_001.h:272,

                 from C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\ProffieOS_7.14.ino:625:

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:27:1: error: expected unqualified-id before 'case'

   27 | case EVENTID(BUTTON_POWER and BUTTON_AUX, EVENT_CLICK_X_LONG, "??what do I need to put here ??"):

      | ^~~~

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:29:9: error: expected unqualified-id before 'return'

   29 |         return true;

      |         ^~~~~~

In file included from C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\config\olicomplex1.4.1_test_multi_prop_attempt_001.h:272,

                 from C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\ProffieOS_7.14.ino:625:

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h: In member function 'bool SaberBlasterProp<Saber, Blaster>::Event(BUTTON, EVENT)':

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:73:42: error: expected primary-expression before ')' token

   73 |     if (button == TWO_BUTTONS_X_LONG_PUSH) {}

      |                                          ^

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:74:39: error: expected unqualified-id before ')' token

   74 |     if (Saber::TWO_BUTTONS_X_LONG_PUSH) {

      |                                       ^

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h: In member function 'bool SaberBlasterProp<Saber, Blaster>::Event2(BUTTON, EVENT, uint32_t)':

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:95:39: error: expected unqualified-id before ')' token

   95 |     if (Saber::TWO_BUTTONS_X_LONG_PUSH) {

      |                                       ^

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h: In member function 'void SaberBlasterProp<Saber, Blaster>::SetPreset(int, bool)':

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:103:39: error: expected unqualified-id before ')' token

  103 |     if (Saber::TWO_BUTTONS_X_LONG_PUSH) {

      |                                       ^

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h: In member function 'void SaberBlasterProp<Saber, Blaster>::Loop()':

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:111:39: error: expected unqualified-id before ')' token

  111 |     if (Saber::TWO_BUTTONS_X_LONG_PUSH) {

      |                                       ^

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h: In member function 'void SaberBlasterProp<Saber, Blaster>::DoMotion(const Vec3&, bool)':

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:119:39: error: expected unqualified-id before ')' token

  119 |     if (Saber::TWO_BUTTONS_X_LONG_PUSH) {

      |                                       ^

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h: In member function 'void SaberBlasterProp<Saber, Blaster>::Clash(bool, float)':

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:127:39: error: expected unqualified-id before ')' token

  127 |     if (Saber::TWO_BUTTONS_X_LONG_PUSH) {

      |                                       ^

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h: In member function 'void SaberBlasterProp<Saber, Blaster>::SB_Effect(EffectType, float)':

C:\Users\Olivier\Desktop\Lego Manuals\LightSabers\$Oli\ProffieOS_7.14\props\multi_prop_attempt_001.h:135:39: error: expected unqualified-id before ')' token

  135 |     if (Saber::TWO_BUTTONS_X_LONG_PUSH) {

      |                                       ^

Using library Wire at version 1.0 in folder: C:\Users\Olivier\AppData\Local\Arduino15\packages\proffieboard\hardware\stm32l4\3.6\libraries\Wire 

exit status 1

Error compiling for board Proffieboard V3.

I am missing some things, especially where it says “??what do I need to put here ??”

I saw a PR, but it was closed?

I think your prop is going to need an enum which can take three values. Then everywhere there is an if statement that figures out which prop to call, you need to replace that with a switch() which select which prop to call.

If none of the above makes sense, go read some C++ basics first.

I thought I was closing the first try. I guess I closed 1st & 2nd, sorry about that. It should be there now ?

That is for the prop to have all 3. For now I would be happy if I can switch from saber to blaster with a TWO_BUTTON_LONG_PUSH instead of BUTTON_BLADE_DETECT and I need to replace blade_detected_ with something else but what ?

  enum class PropState {
    BLASTER,
    SABER,
//    DETONATOR,
  };
#ifndef TWO_BUTTONS_LONG_PUSH
#define TWO_BUTTONS_LONG_PUSH
case EVENTID(BUTTON_POWER and BUTTON_AUX, EVENT_CLICK_LONG, switch (arg[0]) {
                 case 'LS': e = SABER; break;     //LS is for LightSaber
                 case 'BL': e = BLASTER; break;
/*              case 'TD': e = DETONATOR; break; */ }):
        StartOrStopTrack();
        return true;
#endif

#ifndef MULTI_PROP_CONDITION
#define MULTI_PROP_CONDITION TWO_BUTTONS_LONG_PUSH
#endif

Something like this ?

I do no need to read some C++ basics. Do you know of a good website to start ?

Once again, thank you for your time.

I have a feeling that I might be bugging you all with my (“crazy”) idea, if this is the case, let me know and I’ll stop.

Yeah, you got it up now. (You can check here btw :slight_smile: )

Not really, at least if I understand what you’re trying to do.

First and foremost, at least from the very first multi_prop.h file you posted, you’ve put an EVENTID case just outside of anything at the top of the file… which doesn’t make much sense. You define TWO_BUTTONS_X_LONG_PUSH and guard the EVENTID with it, but then later you use TWO_BUTTONS_X_LONG_PUSH (which is an empty define) to try and do an equality check and try to find it within the Saber namespace.

There’s a lot here that’s not right. That’s not necessarily a harp on you, there’s a lot here that’s easy to misunderstand, but it’s hard to really say how to correct it…

I think what you probably want is inside Event to have a case for whatever button combo you want to switch between your BLASTER, DETONATOR, and LIGHTSABER` state. Whenever that button combo is triggered (so within that case statement), you should cycle through. A very plain example would be:

// `multiState` is an instance of `PropState`
switch (multiState) {
    case PropState::BLASTER:
        multiState = PropState::LIGHTSABER;
        break;
    case PropState::LIGHTSABER:
        multiState = PropState::DETONATOR;
        break;
    case PropState::DETONATOR:
        multiState = PropState::BLASTER;
        break;

Then when you’re dealing with the other button actions, you would switch between the states and choose which prop function you need to call:

switch (multiState) {
    case PropState::BLASTER:
        // The `Blaster` class that's templated which you inherit from.
        Blaster::SomeFunction();
        break;
    case PropState::LIGHTSABER:
        // The `Saber` class that's templated which you inherit from.
        Saber::SomeFunction();
        break;
    case PropState::DETONATOR:
        // The `Detonator` class that's templated which you inherit from.
        Detonator::SomeFunction();
        break;
}

I don’t have any resources off the top of my head, but I compiled a few relevant links you might want to look over. Note that ProffieOS uses a lot more C syntax than C++ in many cases, so understanding C may be arguably more important than understanding C++.

I’d recommend searching online for some basic explanations of the C syntax (not C++) to understand fundamental usages of both C and C++. The reason I say C is because you’re far more likely to find things that are simpler and more fundamental for tutorials/explanations on C, and then you can find specific resources for C++ features.

Explanation of the preprocessor (To understand the #define, #ifdef, etc.)
Enum classes and enums
C++ Switch | More C++ Switch
C++ inheritance
A quick-ish explanation of templates

Also, you can just look through a bunch of existing ProffieOS code, like other props, and see how some of the stuff is formatted.
I learned a lot initially by finding something related, copying it and just making it my own version.
Then searched the web for similar error messages or what things meant.
Nowadays, ChatGPT knows a good amount of proper syntax, what things are and how to format them. I don’t suggest you let it 100% write code for you, but it’s good at explaining stuff in a way you can understand.

For a good C++ course that starts with the basics, I know of this easy to follow series:

I initially didn’t click pull, because for me it is like “pull the plug” and disconnect. Push would make more sense, like push the change.
Second time I closed it all, thinking I was closing the first attempt.
At least 3rd time’s the charm.

I am trying to make a prop (multi-prop.h) that can change from light-saber to blaster to thermal detonator by using a long (or extra-long) push with both buttons pressed at the same time. And without using blade detect.

It was more of a copy/paste mish-mash with some magic wish dust on it but thank you for your kind words.

For now I will forget the extra-long push as I do not want to have to modify any of the …\buttons*.h files or any of the POS files for that matter (or envents.h). I do not want to mess-up a good thing with my newbie fat fingers.

I would like to know how to define TWO_BUTTONS_LONG_PUSH or TWO_BUTTONS_X_LONG_PUSH if all the code can all fit within “my” multi_prop.h

I will be looking into them with great attention in the next few days. Thank you for the links.

Ho, rest assured I have been doing that. I want to learn how this stuff “works”.

That’s what I am doing too.

That is a great tip, I didn’t know ChatGPT could do that.

Thank you, I will be looking into it with great attention.

Have a great day (or night) to you all and thank you once again for your time and valuable insights.

1 Like

As a very general acknowledgement and general approval of your approach and attention to things: :+1: (I don’t really have much to say, lol, so just a thumbs up :sweat_smile:)

The events are fired off by ProffieOS and you handle them within the prop file, so you don’t actually define these yourself. There are predefined events that correspond to things like this. I’ll defer to Fredrik for that though, as he can probably provide better info.

My idea behind the “dual_buttons” & “extra long push” is that it does not exist somewhere else (that I have seen). I have found these (in events.h):

  EVENT_PRESSED,
  EVENT_RELEASED,
  EVENT_HELD,
  EVENT_HELD_MEDIUM,
  EVENT_HELD_LONG,
  EVENT_CLICK_SHORT,
  EVENT_SAVED_CLICK_SHORT,
  EVENT_CLICK_LONG,

  EVENT_FIRST_PRESSED,
  EVENT_FIRST_RELEASED,
  EVENT_FIRST_HELD,
  EVENT_FIRST_HELD_MEDIUM,
  EVENT_FIRST_HELD_LONG,
  EVENT_FIRST_CLICK_SHORT,
  EVENT_FIRST_SAVED_CLICK_SHORT,
  EVENT_FIRST_CLICK_LONG,
    
  EVENT_SECOND_PRESSED,
  EVENT_SECOND_RELEASED,
  EVENT_SECOND_HELD,
  EVENT_SECOND_HELD_MEDIUM,
  EVENT_SECOND_HELD_LONG,
  EVENT_SECOND_CLICK_SHORT,
  EVENT_SECOND_SAVED_CLICK_SHORT,
  EVENT_SECOND_CLICK_LONG,

  EVENT_THIRD_PRESSED,
  EVENT_THIRD_RELEASED,
  EVENT_THIRD_HELD,
  EVENT_THIRD_HELD_MEDIUM,
  EVENT_THIRD_HELD_LONG,
  EVENT_THIRD_CLICK_SHORT,
  EVENT_THIRD_SAVED_CLICK_SHORT,
  EVENT_THIRD_CLICK_LONG,

  EVENT_FOURTH_PRESSED,
  EVENT_FOURTH_RELEASED,
  EVENT_FOURTH_HELD,
  EVENT_FOURTH_HELD_MEDIUM,
  EVENT_FOURTH_HELD_LONG,
  EVENT_FOURTH_CLICK_SHORT,
  EVENT_FOURTH_SAVED_CLICK_SHORT,
  EVENT_FOURTH_CLICK_LONG,

And also these in button_base.h

#ifndef BUTTON_DOUBLE_CLICK_TIMEOUT
#define BUTTON_DOUBLE_CLICK_TIMEOUT 500
#endif

#ifndef BUTTON_SHORT_CLICK_TIMEOUT
#define BUTTON_SHORT_CLICK_TIMEOUT 500
#endif

#ifndef BUTTON_HELD_TIMEOUT
#define BUTTON_HELD_TIMEOUT 300
#endif

#ifndef BUTTON_HELD_MEDIUM_TIMEOUT
#define BUTTON_HELD_MEDIUM_TIMEOUT 800
#endif

#ifndef BUTTON_HELD_LONG_TIMEOUT
#define BUTTON_HELD_LONG_TIMEOUT 2000
#endif

So if I can define & use “EXTRA_LONG” or “X_LONG”, since it does not exists yet, I would be sure not to cause any interference or conflict with the existing code. And also since I did not find anything about two buttons being pushed at the same time (plus it seems simpler to perform than “multi button push” combo that if you do it wrong, it could enter a mode you don’t want to go in), same thing, no conflict, no interference, and I can always disable multi_prop.h and revert to dual_prop.h if things are not going to plan.

Anyways, I am now going to check-out your’s (ryryog25 and NoSloppy’s links and hopefully in an hour or two, I’ll know all I need to know. Wink, wink (I know it will take much longer than that. I’ll get back here with an update - or more questions - as soon as I can.

Oh, and I read this:

Do I need a capacitor for my Bluetooth on my Proffie board V3 or is it just for the V2 ? Thanks

Unfortunately, it may not be that simple, because some props may do something as soon as you press the button, or after it’s been held for some time (but not released yet.)

You still need a capacitor, but the V3 board has a nice spot for it in the middle of the board which makes things easier.

1 Like

So I will forget the “X_LONG” push then. Can you confirm that both buttons (pow & aux) long push type of event is even possible ?

Is this the spot, under the 5V pad ?


What is the capacitor that I need for the BT909 module ?

I just noticed I misspelled the title of this thread.
It should be: " If you don’t mind to review my config. …" instead of “I you don’t mind to review my config. …” Can this be changed ?

Yes, there are already long click/held events with other button.
Not sure if they are already being used or not though.

Yes

At least 22uF, 47uF might be better.

Scroll up and click the pen next to the title?
(If there is no pen there, I can fix it.)

Whould this do ?

This is from my local electronic shop.

Thanks, done. Yes there is a pencil but I never noticed it.