1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

[IR] universal remote additions (#3922)

* multiple new additions
  Hisense K321UW, Soniq E55V13A, Soniq E32W13B and 2 others
* updated with proper names
  Viano STV65UHD4K
  Hisense K321UW
  Hisense EN2B27
  Soniq E55V13A
  Soniq E32W13B
* format tv.ir
* Update tv.ir
* new universal ac additions
  Maytag M6X06F2A
  Panasonic CS-E9HKR
* new universal audio additions
  Sony MHC_GSX75
  Elac EA101EQ-G
  Philips FW750C
  Pioneer VSX-D1-S
* remove final # audio.ir
* Scripts: update deprecated methods use in python scripts
* Scripts: add comment reading support to fff, preserve comments in infrared cleanup script
* Scripts: improved infrared files cleanup script
* Scripts: add missing new line at the end of file in infrared file cleanup script
* Infrared: cleanup universal remotes

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
jay candel
2024-10-03 00:28:24 +08:00
committed by GitHub
parent 09a7cc2b46
commit 3c93761d1d
8 changed files with 345 additions and 190 deletions

View File

@@ -32,6 +32,16 @@ class FlipperFormatFile:
raise Exception("Unexpected line: not `key:value`")
return data[0].strip(), data[1].strip()
def readComment(self):
if self.cursor == len(self.lines):
raise EOFError()
line = self.lines[self.cursor].strip()
if line.startswith("#"):
self.cursor += 1
return line[1:].strip()
else:
return None
def readKey(self, key: str):
k, v = self.readKeyValue()
if k != key:
@@ -67,7 +77,7 @@ class FlipperFormatFile:
self.writeLine("")
def writeComment(self, text: str):
if text:
if text and len(text):
self.writeLine(f"# {text}")
else:
self.writeLine("#")
@@ -104,3 +114,4 @@ class FlipperFormatFile:
def save(self, filename: str):
with open(filename, "w", newline="\n") as file:
file.write("\n".join(self.lines))
file.write("\n")

View File

@@ -27,37 +27,51 @@ class Main(App):
return 1
data = []
unique = {}
unique_combo = {}
unique_payload = {}
while True:
try:
d = {}
d["comments"] = []
while (comment := f.readComment()) is not None:
d["comments"].append(comment)
d["name"] = f.readKey("name")
d["type"] = f.readKey("type")
key = None
key_combo = f'{d["name"]}'
key_payload = None
if d["type"] == "parsed":
d["protocol"] = f.readKey("protocol")
d["address"] = f.readKey("address")
d["command"] = f.readKey("command")
key = f'{d["protocol"]}{d["address"]}{d["command"]}'
key_payload = f'{d["protocol"]}{d["address"]}{d["command"]}'
key_combo += key_payload
elif d["type"] == "raw":
d["frequency"] = f.readKey("frequency")
d["duty_cycle"] = f.readKey("duty_cycle")
d["data"] = f.readKey("data")
key = f'{d["frequency"]}{d["duty_cycle"]}{d["data"]}'
key_payload = f'{d["frequency"]}{d["duty_cycle"]}{d["data"]}'
key_combo += key_payload
else:
raise Exception(f'Unknown type: {d["type"]}')
if not key in unique:
unique[key] = d
if not key_combo in unique_combo:
unique_combo[key_combo] = d
data.append(d)
# Check payload only
if not key_payload in unique_payload:
unique_payload[key_payload] = d
else:
self.logger.warning(f"Duplicate payload, check manually: {d}")
else:
self.logger.warn(f"Duplicate key: {key}")
self.logger.info(f"Duplicate data removed: {d}")
except EOFError:
break
# Form new file
f = FlipperFormatFile()
f.setHeader(filetype, version)
for i in data:
f.writeComment(None)
for comment in i["comments"]:
f.writeComment(comment)
f.writeKey("name", i["name"])
f.writeKey("type", i["type"])
if i["type"] == "parsed":

View File

@@ -121,7 +121,7 @@ class Main(App):
try:
shutil.rmtree(self.output_dir_path)
except Exception as ex:
self.logger.warn(f"Failed to clean output directory: {ex}")
self.logger.warning(f"Failed to clean output directory: {ex}")
if not exists(self.output_dir_path):
self.logger.debug(f"Creating output directory {self.output_dir_path}")

View File

@@ -152,7 +152,7 @@ class Main(App):
return 3
if not self.layout_check(updater_stage_size, dfu_size, radio_addr):
self.logger.warn("Memory layout looks suspicious")
self.logger.warning("Memory layout looks suspicious")
if self.args.disclaimer != "yes":
self.show_disclaimer()
return 2
@@ -205,7 +205,7 @@ class Main(App):
def layout_check(self, stage_size, fw_size, radio_addr):
if stage_size > self.UPDATER_SIZE_THRESHOLD:
self.logger.warn(
self.logger.warning(
f"Updater size {stage_size}b > {self.UPDATER_SIZE_THRESHOLD}b and is not loadable on older firmwares!"
)
@@ -217,13 +217,13 @@ class Main(App):
self.logger.debug(f"Expected reserved space size: {fw2stack_gap}")
fw2stack_gap_pages = fw2stack_gap / self.FLASH_PAGE_SIZE
if fw2stack_gap_pages < 0:
self.logger.warn(
self.logger.warning(
f"Firmware image overlaps C2 region and is not programmable!"
)
return False
elif fw2stack_gap_pages < self.MIN_GAP_PAGES:
self.logger.warn(
self.logger.warning(
f"Expected reserved flash size is too small (~{int(fw2stack_gap_pages)} page(s), need >={self.MIN_GAP_PAGES} page(s))"
)
return False