feat(infrared): expand remote library and creation flow (#13)
## Summary - replace the crowded add-remote dialog with a full-screen three-step flow - make the first step explicitly choose between adding from the infrared library and creating through learning - add a full-screen remote editor with read-only library configuration, editable custom layouts, and delete confirmation - append newly created remotes to the bottom of the management list and right side of the remote switcher - remove the fan emoji from the device type label - add a curated CC0 Flipper-IRDB preset subset with real NEC/NECext protocol codes - add projector, audio/receiver, set-top box, streaming device, and lighting categories - require a test power command and explicit device-response confirmation before creating library remotes - include source attribution and a repeatable converter for parsed NEC/NECext signals ## Compatibility scope - imported formats: parsed NEC and NECext only - excluded: raw pulse data and other protocols because the ABox irCode encoding contract is not publicly specified for them - existing devices, remotes, and scenes are not migrated or renamed ## Verification - ./gradlew.bat :android:app:assembleDebug --no-daemon - converter reproduced Reviewed-on: #13 Co-authored-by: KremeCN <3265494849@qq.com>
This commit was merged in pull request #13.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$InputFile
|
||||
)
|
||||
|
||||
$lines = Get-Content -LiteralPath $InputFile
|
||||
$signals = @()
|
||||
|
||||
function Convert-Signal([string]$Protocol, [string]$Address, [string]$Command) {
|
||||
$addressBytes = $Address -split '\s+' | Where-Object { $_ }
|
||||
$commandBytes = $Command -split '\s+' | Where-Object { $_ }
|
||||
|
||||
if ($Protocol -eq 'NEC') {
|
||||
if ($addressBytes.Count -lt 1 -or $commandBytes.Count -lt 1) { return $null }
|
||||
$addressValue = [Convert]::ToInt32($addressBytes[0], 16)
|
||||
$commandValue = [Convert]::ToInt32($commandBytes[0], 16)
|
||||
return '0x{0:X2}{1:X2}{2:X2}{3:X2}' -f $addressValue, (255 - $addressValue), $commandValue, (255 - $commandValue)
|
||||
}
|
||||
|
||||
if ($Protocol -eq 'NECext') {
|
||||
if ($addressBytes.Count -lt 2 -or $commandBytes.Count -lt 2) { return $null }
|
||||
return '0x{0}{1}{2}{3}' -f $addressBytes[0].ToUpper(), $addressBytes[1].ToUpper(), $commandBytes[0].ToUpper(), $commandBytes[1].ToUpper()
|
||||
}
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
for ($index = 0; $index -lt $lines.Count; $index++) {
|
||||
if ($lines[$index] -notmatch '^name:\s*(.+)$') { continue }
|
||||
|
||||
$name = $matches[1].Trim()
|
||||
$type = ''
|
||||
$protocol = ''
|
||||
$address = ''
|
||||
$command = ''
|
||||
|
||||
for ($lookahead = $index + 1; $lookahead -lt [Math]::Min($index + 8, $lines.Count); $lookahead++) {
|
||||
if ($lines[$lookahead] -match '^name:' -or $lines[$lookahead] -eq '#') {
|
||||
if ($lookahead -gt $index + 1) { break }
|
||||
}
|
||||
if ($lines[$lookahead] -match '^type:\s*(.+)$') { $type = $matches[1].Trim() }
|
||||
if ($lines[$lookahead] -match '^protocol:\s*(.+)$') { $protocol = $matches[1].Trim() }
|
||||
if ($lines[$lookahead] -match '^address:\s*(.+)$') { $address = $matches[1].Trim() }
|
||||
if ($lines[$lookahead] -match '^command:\s*(.+)$') { $command = $matches[1].Trim() }
|
||||
}
|
||||
|
||||
if ($type -ne 'parsed' -or $protocol -notin @('NEC', 'NECext')) { continue }
|
||||
$hexCode = Convert-Signal $protocol $address $command
|
||||
if ($null -ne $hexCode) {
|
||||
$signals += [pscustomobject]@{
|
||||
name = $name
|
||||
protocol = $protocol
|
||||
code = $hexCode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$signals | ConvertTo-Json -Depth 3
|
||||
Reference in New Issue
Block a user