-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- code cleanup
- Loading branch information
Showing
31 changed files
with
350 additions
and
265 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
global using Xunit; | ||
global using Xunit; | ||
global using FluentAssertions; | ||
global using RonSijm.ButtFish.Ascii; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using RonSijm.ButtFish.Models; | ||
using YeelightAPI; | ||
using YeelightAPI; | ||
|
||
namespace RonSijm.ButtFish.Connectors; | ||
|
||
|
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,43 @@ | ||
namespace RonSijm.ButtFish; | ||
|
||
public class DeviceBroadcaster | ||
{ | ||
private readonly ICharacterEncoder _characterEncoder; | ||
|
||
public DeviceBroadcaster(ICharacterEncoder characterEncoder) | ||
{ | ||
_characterEncoder = characterEncoder; | ||
} | ||
|
||
public async Task SendNextMoveToDevice(string nextPosition, IList<IDeviceAbstraction> devices) | ||
{ | ||
Console.WriteLine(nextPosition); | ||
|
||
foreach (var nextPositionChar in nextPosition) | ||
{ | ||
var morseCodeForChar = _characterEncoder.EncodeCharacter(nextPositionChar); | ||
|
||
if (morseCodeForChar == null) | ||
{ | ||
continue; | ||
} | ||
|
||
Console.Write($"({nextPositionChar})"); | ||
|
||
foreach (var durationToSend in morseCodeForChar.Select(morseCodeChar => morseCodeChar == '.' ? TimeUnitConfig.DotTime : TimeUnitConfig.DashTime)) | ||
{ | ||
Task.WaitAll(devices.Select(device => device.SendDuration(durationToSend)).ToArray()); | ||
|
||
// Wait 1 time unit | ||
Console.Write(" "); | ||
await Task.Delay(TimeUnitConfig.SpaceBetweenSymbols); | ||
} | ||
|
||
// wait 3 time units | ||
await Task.Delay(TimeUnitConfig.SpaceBetweenLetters); | ||
} | ||
|
||
Console.WriteLine(); | ||
Console.WriteLine("Finished sending command to device.", Color.Green); | ||
} | ||
} |
Oops, something went wrong.