-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3647b1c
commit cdc350c
Showing
4 changed files
with
33 additions
and
41 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...ared/src/main/kotlin/com/flipperdevices/infrared/editor/encoding/InfraredRemoteEncoder.kt
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,31 @@ | ||
package com.flipperdevices.infrared.editor.encoding | ||
|
||
import com.flipperdevices.infrared.editor.model.InfraredRemote | ||
|
||
/** | ||
* To encode [InfraredRemote] we write its objects into list, in specified order. | ||
* Then converting all objects inside list into byte arrays so we have lists of byte arrays. | ||
* Then we flatten it to have single byte array. | ||
*/ | ||
object InfraredRemoteEncoder { | ||
fun encode(remote: InfraredRemote): ByteArray { | ||
val bytesList = when (remote) { | ||
is InfraredRemote.Parsed -> listOf( | ||
remote.type, | ||
remote.protocol, | ||
remote.address, | ||
remote.command | ||
) | ||
|
||
is InfraredRemote.Raw -> listOf( | ||
remote.frequency, | ||
remote.dutyCycle, | ||
remote.data | ||
) | ||
} | ||
return bytesList | ||
.map(String::toByteArray) | ||
.flatMap(ByteArray::asList) | ||
.toByteArray() | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
...infrared/src/main/kotlin/com/flipperdevices/infrared/editor/util/InfraredRemoteEncoder.kt
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