-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(universe): Change channel value manually
In order to change DMX values manually it is now possible to use the UniverseManager to change the values for each channel manually. fix #127
- Loading branch information
1 parent
e919583
commit 2b1c5f3
Showing
7 changed files
with
161 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { LitElement, html } from 'lit-element' | ||
import { shared } from '../../styles/shared.js' | ||
|
||
/* | ||
* Show DMX512 channels in a grid | ||
*/ | ||
class ChannelGrid extends LitElement { | ||
static get properties() { | ||
return { | ||
channels: { type: Array }, | ||
refresh: { type: Boolean } | ||
} | ||
} | ||
|
||
/** | ||
* When the value of a speicifc channel is updated, we send out an event. | ||
* | ||
* @param {Object} e - The event that contains the channel and it's value | ||
*/ | ||
handleChange(e) { | ||
const { value } = e.target | ||
const { channelIndex } = e.target.dataset | ||
const channelValue = parseInt(value, 10) | ||
|
||
this.dispatchEvent(new CustomEvent('update-channel', { | ||
detail: { | ||
channelIndex, | ||
channelValue | ||
} | ||
})) | ||
} | ||
|
||
shouldUpdate(changedProps) { | ||
const { refresh } = this | ||
|
||
// Make sure that when refresh is changed (especially to false) | ||
// that the component renders at least once so that something is visible for the user | ||
if (changedProps.has('refresh')) { | ||
return true | ||
} | ||
|
||
return refresh | ||
} | ||
|
||
render() { | ||
const { channels } = this | ||
|
||
return html` | ||
${shared} | ||
<style> | ||
.items { | ||
counter-reset: universe; | ||
} | ||
.item { | ||
flex: 0 0 3em; | ||
position: relative; | ||
padding: 0 .25em 0 1.75em; | ||
} | ||
.item:before { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
counter-increment: universe; | ||
content: counter(universe); | ||
font-size: 0.65em; | ||
opacity: 0.7; | ||
} | ||
</style> | ||
<div class="items"> | ||
${channels.map((channel, index) => html` | ||
<div class="item"> | ||
<input | ||
type="number" | ||
min=0 | ||
max=255 | ||
.value="${channel}" | ||
data-channel-index="${index}" | ||
@change="${e => this.handleChange(e)}" | ||
/> | ||
</div> | ||
` | ||
)} | ||
</div> | ||
` | ||
} | ||
|
||
} | ||
|
||
customElements.define('channel-grid', ChannelGrid) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters