LED issue

magicizaproblem

2018-07-18 17:31:54

Hey Steve, I have a question about an issue thats been bothering me with trying to program led lights with my controller. Im looking to understand why this is happening so that i can program with MT better.

Im providing sample project files to demonstrate the issue. I do understand you might not be able to get the same result but hopefully you can understand this. test 1 file is the original led code you gave me a while back it allows the leds to make a color change. Test 1 works fine every time.

Test 2 is where the issue begins. At the top of the preset list you'll see Burgundy and Red. In Test 2 only Burgundy triggers the LED change, but only when I have 2 identical LED translators active. Otherwise it ends up like the preset Red in project test 2 which only has one LED translator active. Which is like the translator in Test 1 which i feel should work but its not.

Ive also noticed in the test 2 project the Red preset led translator will change, but only after the burgundy is engaged. To clarify i dont mean that the burgundy directly triggers the Red led translator, but i mean after i trigger the burgundy led im able to get the red led translator to change color once, and it wont change until i reengage the burgundy led.

Project file Test 3 is the Test 2 file minus the other presets. In this file Burgundy wont change colors at all and the red preset changes as expected exactly like the test 1 project. Hopefully i explained this clear enough if not please allow me to clarify further. Ive been dealing with this the last couple of days and its been driving me nuts.

Why is this happening? Please let me know. Thanks!


Attachments:

test 1.bmtp
test 2.bmtp
test 3.bmtp

Steve-Bome Forum Moderator

2018-07-18 19:12:11

comment

I’m away from my computer but will look into this later today.

Steve-Bome Forum Moderator

2018-07-18 22:12:47

Hi Preston,

Are you trying to toggle various LED colors? Each LED will require a DIFFERENT variable to track. For the example I gave you I used “ga”. For the next button you will need “gb” and so on (unless you want to bitmap the LED’s where you could get up to 32 LED’ covered with a single global variable).

I modified test 3 as follows.

  1. Disabled the second translator under Burgundy
  2. Change the rules in the RED preset Send LED status to reference the global variable “gb” instead of “ga”.

Let me know if this helps.

Steve Caldwell
Bome Q and A Moderator and
Independent Bome Consultant/Specialist
bome@sniz.biz

 


Attachments:

test-3-steve-2018-07-18.bmtp

magicizaproblem

2018-07-19 01:00:36

comment

Thanks! So the way i had it i was basically inverting the binary?

magicizaproblem

2018-07-19 01:13:40

comment

Also ill take a shot at the bitmap whats the best way to go about understanding it?

Steve-Bome Forum Moderator

2018-07-19 04:01:17

A bitmap takes the 32 bits of a global variable and uses each bit individually to represent a lights LED on or off state.

To toggle the state of bit 1 you would use the formula.

ga=ga^1

To toggle the state of bit 2 you would use the formula:

ga=ga^2

For bit 3 it would be

ga=ga^4

The bits are number from right to left and each next bit up is 2 times the value of the bit to the right. So the pattern from right to left would be:

2,4,7,16,32,64,128,256,512,1024,2048,4196 and so on.

Or if you don’t want to remember the number you could use bit shift left based on the LED

1<<0 = 1

1<<1 =  2

1<<2 = 4

So essentially you could shift the bit left and then XOR it to toggle the state.

For instance, if you want to toggle the state of bit 24:

 

pp=1<<23

ga=ga^pp

That would toggle bit 24

To test the state of bit 23 you would do this

pp=ga>>23

pp=ga&1

The second formula above is to ensure any higher bits are cleared

Then you would do something like this to depending on the color you want

if pp==1 then qq=25

if pp==0 then qq=5

25 would be the ON color and 5 would be the off color

The you would output the note value

Output Note  On x on channel y value qq

The main thing you would need to be concerned about is making sure you keep the bits straight in you mind for the LED you want to toggle.

So there is the basics, for anything more, you might want to search for “bit logic” or “bit manipulation” on Google search or if you want a training session, I’m happy to do that for a fee.

I hope this helps, Preston!

Regards

Steve

 

 

magicizaproblem

2018-07-19 16:18:35

comment

Awesome thanks i will be workin through it next couple of days and will reach out if i need you.

Steve-Bome Forum Moderator

2018-07-19 16:31:43

comment

OK, I’ll be here. Good luck, Preston!

Steve