Skip to content

Commit

Permalink
fix infrared encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg committed Aug 14, 2024
1 parent 3647b1c commit cdc350c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 41 deletions.
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()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.flipperdevices.ifrmvp.generator.config.device.api.DeviceKeyNamesProvi
import com.flipperdevices.ifrmvp.model.IfrKeyIdentifier
import com.flipperdevices.infrared.editor.encoding.ByteArrayEncoder
import com.flipperdevices.infrared.editor.encoding.JvmEncoder
import com.flipperdevices.infrared.editor.util.InfraredRemoteEncoder
import com.flipperdevices.infrared.editor.encoding.InfraredRemoteEncoder
import java.io.File

class DefaultDeviceConfigGenerator(private val keyNamesProvider: DeviceKeyNamesProvider) : DeviceConfigGenerator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ import com.flipperdevices.ifrmvp.backend.db.signal.table.InfraredFileToSignalTab
import com.flipperdevices.ifrmvp.backend.db.signal.table.SignalKeyTable
import com.flipperdevices.ifrmvp.backend.db.signal.table.SignalTable
import com.flipperdevices.ifrmvp.backend.db.signal.table.UiPresetTable
import com.flipperdevices.ifrmvp.backend.model.SignalModel
import com.flipperdevices.ifrmvp.model.IfrKeyIdentifier
import com.flipperdevices.ifrmvp.parser.util.ParserPathResolver
import com.flipperdevices.infrared.editor.encoding.ByteArrayEncoder
import com.flipperdevices.infrared.editor.encoding.JvmEncoder
import com.flipperdevices.infrared.editor.model.InfraredRemote
import com.flipperdevices.infrared.editor.util.InfraredRemoteEncoder
import com.flipperdevices.infrared.editor.encoding.InfraredRemoteEncoder
import com.flipperdevices.infrared.editor.viewmodel.InfraredKeyParser
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.JoinType
import org.jetbrains.exposed.sql.andWhere
Expand Down

0 comments on commit cdc350c

Please sign in to comment.