#!/usr/bin/env python3 """ FILE: hack-temp.py DESCRIPTION: Incremental firmware patcher with minimal, conservative steps to bias readings. BRIEF: Provides three modes: - pool_only: change only the literal pool constant (scaling effect; least invasive) - temp_only_vadd: convert temperature path to vadd.f32 and set a small negative pool - both_vadd: convert both paths to vadd.f32 and set a small negative pool Intended to let you test changes incrementally, keeping humidity stable while you evaluate temperature bias first. AUTHOR: Kevin Thomas CREATION DATE: November 1, 2025 UPDATE DATE: November 1, 2025 """ import sys import os import struct BIN_PATH = "build/0x001a_operators.bin" # Offsets OFF_410 = 0x410 OFF_414 = 0x414 OFF_POOL = 0x42C # Original encodings (for visibility only) ORIG_410 = bytes.fromhex("a6ee257a") # vfma.f32 s14, s12, s11 ORIG_414 = bytes.fromhex("e6eea57a") # vfma.f32 s15, s13, s11 ORIG_POOL = bytes.fromhex("cccccc3d") # 0.1f # Encodings for vadd.f32 s14, s14, s11 and vadd.f32 s15, s15, s11 VADD_S14_S11 = struct.pack(" 1 else "pool_only").strip().lower() if mode == "pool_only": patch_pool_only(new_pool_float=-1.0) elif mode == "temp_only_vadd": patch_temp_only_vadd(new_pool_float=-2.0) elif mode == "both_vadd": patch_both_vadd(new_pool_float=-2.0) else: print(f"Unknown mode: {mode}") print("Use: pool_only | temp_only_vadd | both_vadd") sys.exit(2) if __name__ == "__main__": main() print("Patch complete. Convert to UF2 and flash. Test each mode incrementally.")