Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix and Xmas profiles #26

Merged
merged 6 commits into from
Dec 29, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
string literal removed, enable and disable transition added
enum removed during debug attempt, left out because we're just translating from num -> enum -> num unnecessarily.
enable and disable transition were missing/handled differently to key-state
  • Loading branch information
Rzah authored Dec 19, 2018
commit 19d205d95dd50a33b0bebda0ef13e464f625c4f1
43 changes: 34 additions & 9 deletions src/channel-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export class ChannelState {
private effectId?: number;

private keyInfo: KeyModel;
private desiredColorChannel: "red" | "green" | "blue";
private desiredColorChannel?: number;
private effectFlag: EffectFlag = new EffectFlag();

constructor(
keyInfo: KeyModel,
channel: "red" | "green" | "blue"
channel: number,
) {
this.keyInfo = keyInfo;
this.desiredColorChannel = channel;
Expand Down Expand Up @@ -109,12 +109,23 @@ export class ChannelState {
return this;
}

public setTransition(enable: boolean) {
if (enable) {
this.effectFlag.setEnableTransition();
} else {
this.effectFlag.setDisableTransition();
}
public setTransition() {
this.effectFlag.setDecrementIncrement();
return this;
}

public setTransitionReverse() {
this.effectFlag.setIncrementDecrement();
return this;
}

public enableTransition() {
this.effectFlag.setEnableTransition();
return this;
}

public disbleTransition() {
this.effectFlag.setDisableTransition();
return this;
}

Expand All @@ -140,6 +151,7 @@ export class ChannelState {
const colorChannels = this.keyInfo.getRGBChannels();

let ourColorChannel = 0;
/*
if (this.desiredColorChannel === "red") {
ourColorChannel = colorChannels[0];
}
Expand All @@ -149,10 +161,24 @@ export class ChannelState {
if (this.desiredColorChannel === "blue") {
ourColorChannel = colorChannels[2];
}
*/

if (this.desiredColorChannel === 0) {
ourColorChannel = colorChannels[0];
} else if (this.desiredColorChannel === 1) {
ourColorChannel = colorChannels[1];
} else if (this.desiredColorChannel === 2) {
ourColorChannel = colorChannels[2];
} else {
ourColorChannel = colorChannels[0];
}

// ourColorChannel = colorChannels[this.desiredColorChannel];

for (const ledId of this.keyInfo.ledIds) {
packetsToSend.push(new StatePacket(
ledId.id,
// this.desiredColorChannel,
ourColorChannel,
this.effectFlag,
this.upHoldLevel,
Expand All @@ -169,7 +195,6 @@ export class ChannelState {
this.effectId,
).buildPacketBytes());
}

return packetsToSend;

}
Expand Down