Skip to content

Commit

Permalink
added FadeIn example
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysonh committed Sep 18, 2021
1 parent d2a604a commit 80f57ff
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
50 changes: 50 additions & 0 deletions examples/FadeIn/FadeIn.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
*
* Example: FadeIn
*
* This examples shows how you can set lights to fade to a value
* So instead of instantly changing the colour it softly moves that colour for nicer transitions
* Assumes you have connected a typical RGB can light where channel 0 is master fader and channel 1 is red (or white)
*/

import com.jaysonh.dmx4artists.*;

DMXControl dmx;

int numDmxChannels = 256; // number of channels we will use

int lightAddress = 1;
int lightChannels = 8;

DMXFixture fixture;

void setup()
{
size( 600, 600 );

// Connect to the first dmx usb device available
dmx = new DMXControl( 0, numDmxChannels );

dmx.setFixtureFade( true ); // Enable the fixture value fading in
dmx.setFixtureFadeRate( 0.1 ); // (0.0-1.0) closer to 0 then the slower it will fade

fixture = new DMXFixture( this, lightAddress, lightChannels );
dmx.addFixture( fixture );
}

void draw()
{
background( 0 );

// take the mouse pos and convert it to a number between 0 - 255
int brightness = ( int ) map( mouseX, 0, width, 0, 255 );

}

void mousePressed()
{
int brightness = (int)random(0,255);
// Send the mapped value to the dmx channels 1 and 2 to control the light
fixture.sendValue( 1, brightness );
fixture.sendValue( 2, 255);
}
18 changes: 2 additions & 16 deletions src/com/jaysonh/dmx4artists/DMXControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ public void updateFixtures()
dmxData[ channel + fixture.getAddress() - 1 ] = (byte)( (int)fixture.getParam( channel ).getValue());
}
}

if( fixtures.size())
}
}
}
Expand All @@ -188,13 +186,6 @@ public void updateFixtures()
*/
public void sendValue(int channel, int value)
{
/*if (channel > 0 && channel <= numChannels ) // Check channel is valid, first channel is always 1
{
dmxData[ channel - 1] = (byte)value; // store the value in the dmx value
} else
{
System.out.println("Warning! Channel out of bounds, channel 0 not used"); // Print an error message
}*/
if (channel > 0 && channel <= numChannels ) // Check channel is valid, first channel is always 1
{
// get the channel value from the fixture, and convert to a byte to send
Expand Down Expand Up @@ -263,14 +254,9 @@ private void setupDevice( int numChannels )
*
* @param status true/false to fade
*/
public void setFade( boolean status )
public void setFixtureFade( boolean status )
{
fadeVals = status;

if(fadeVals)
{

}
}

/**
Expand All @@ -279,7 +265,7 @@ public void setFade( boolean status )
*
* @param fadeVal - rate to fade into new value
*/
public void setFadeRate( float fadeVal )
public void setFixtureFadeRate( float fadeVal )
{
fadeRate = fadeVal;
}
Expand Down

0 comments on commit 80f57ff

Please sign in to comment.