Skip to content

Commit

Permalink
Add support for single color LEDs
Browse files Browse the repository at this point in the history
  • Loading branch information
withinboredom committed Nov 24, 2019
1 parent f601fc9 commit fdc3524
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
16 changes: 14 additions & 2 deletions csharp/keyboards/Keyboards/Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class Keyboard
/// The right side of the keyboard
/// </summary>
protected Side? Right { get; set; }

/// <summary>
/// The single color zone
/// </summary>
protected Side? Single { get; set; }

/// <summary>
/// Default location of the left side of the keyboard
Expand All @@ -48,6 +53,11 @@ public class Keyboard
/// </summary>
protected const string RightFile = "/sys/class/leds/system76::kbd_backlight/color_right";

/// <summary>
/// Default location for a single color zone
/// </summary>
protected const string SingleFile = "/sys/class/leds/system76_acpi::kbd_backlight/color";

/// <summary>
/// Renders a keyboard
/// </summary>
Expand All @@ -57,7 +67,8 @@ private async Task Render(long time, long deltaTime)
{
await Task.WhenAll(Left == null ? Task.CompletedTask : Left.Render(time, deltaTime),
Center == null ? Task.CompletedTask : Center.Render(time, deltaTime),
Right == null ? Task.CompletedTask : Right.Render(time, deltaTime));
Right == null ? Task.CompletedTask : Right.Render(time, deltaTime),
Single == null ? Task.CompletedTask : Single.Render(time, deltaTime));
}

/// <summary>
Expand All @@ -79,7 +90,8 @@ public async Task<int> Run(CancellationToken token)
}
await Task.WhenAll(Left == null ? Task.CompletedTask : Left.Commit(Filters),
Center == null ? Task.CompletedTask : Center.Commit(Filters),
Right == null ? Task.CompletedTask : Right.Commit(Filters));
Right == null ? Task.CompletedTask : Right.Commit(Filters),
Single == null ? Task.CompletedTask : Single.Commit(Filters));
var timeToNext = (startRender + TimeSpan.FromSeconds(Frequency)) - DateTime.Now;
if(timeToNext.Ticks > 0)
await Task.Delay(timeToNext, token);
Expand Down
1 change: 1 addition & 0 deletions csharp/keyboards/Keyboards/Monitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public Monitor()
Left = new CpuSide(LeftFile, 95, 75, 50);
Center = new MemSide(CenterFile, 80, 45, 15);
Right = new DiskSide(RightFile, 90, 66, 30);
Single = new CpuSide(SingleFile, 95, 75, 50);
}
}
}
1 change: 1 addition & 0 deletions csharp/keyboards/Keyboards/Rainbow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public Rainbow()
Left = new RainbowSide(rp, gp, bp, 0, LeftFile);
Center = new RainbowSide(rp, gp, bp,100, CenterFile);
Right = new RainbowSide(rp, gp, bp, 200, RightFile);
Single = new RainbowSide(rp, gp, bp, 0, SingleFile);
}
}
}
1 change: 1 addition & 0 deletions csharp/keyboards/Keyboards/SolidColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public SolidColor(Rgb color)
Left = new Solid(color, LeftFile);
Center = new Solid(color, CenterFile);
Right = new Solid(color, RightFile);
Single = new Solid(color, SingleFile);
}
}
}

0 comments on commit fdc3524

Please sign in to comment.