JSFiddle - React, Tailwind, and code Playground
by riaanc
HTML
<textarea rows=50 style="width: 100%">E0A310
EA5D10
EA5E0D
E0A311
EAEB00
EAED00
E00F01
E00005
E00100
E00205
E007C2
E00901
E00B00
E01008
E01198
E01200
E013C0
E01407
E01580
E01604
E01765
E01800
E01929
E01A04</textarea>
<button >Decode</button>
CSS
@import url(//fonts.googleapis.com/css?family=Share+Tech+Mono&display=swap0);
body{
font-family: "Share Tech Mono"
}
JavaScript
const regex = /(?:I2CSend_Data)*.*?([0-9a-f][0-9a-f]).*?([0-9a-f][0-9a-f]).*?([0-9a-f][0-9a-f])/gmi;
function sw(val, options)
{
for (var opt of options)
{
if (val == opt[0])
{
return opt[1];
}
}
return "N/A";
}
function decodeLine(line)
{
var r = regex.exec(line);
if (r == null || r.length < 4)
return "Parse Error";
line = r[1]+r[2]+r[3];
line = line.toUpperCase();
regex.lastIndex = 0;
var targetAddr = line.substring(0,2);
var targetReg = line.substring(2,4);
var targetValue = parseInt("0x"+line.substring(4,6));
console.log(targetAddr);
switch (targetAddr)
{
case "E0":
switch (targetReg)
{
case "00": return targetValue == 0b101 ? "HDMI RX Enable" : "HDMI RX Disable";
case "01": return targetValue == 0b000 ? "eDP TX Enable" : "eDP TX Disable";
case "02": return `${targetValue & 0b1 ? "Scaler Disable" : "Scaler Enable"} | ${(targetValue >> 1) & 0b1 ? "RX Timing Auto" : "RX Timing Manual"} | ${(targetValue >> 2) & 0b1 ? "TX Timing Auto" : "TX Timing Manual"}`;
case "07": return `${targetValue & 0b111 == 0b001 ? "1 eDP Lane" : targetValue & 0b111 == 0b010 ? "2 eDP Lanes" : "4 eDP Lanes"} | ${targetValue >> 4 & 0b1 ? "RBR (1.62Gbps)" : "HBR (2.7Gbps)"} | ${targetValue >> 5 & 0b1 ? "18-bit" : "24-bit"} | ${targetValue >> 6 & 0b1 ? "eDP Hardware Training" : "eDP Software Training"}`;
case "09": return "Set as 0x01";
case "0B": return `${targetValue & 0b1 ? "BIST Enable" : "BIST Disable"} | ${sw(targetValue >> 4 & 0b1111, [
[0b0000, "None"],
[0b0001, "Checker"],
[0b0011, "Color Bar"],
[0b1011, "Outline"],
[0b1100, "Color Gray"],
[0b1111, "Scan"]
])}`;
case "0F": return `${targetValue & 0b1 ? "Reset Enable" : "Reset Disable"}`;
case "10": return `Input H-Total Upper: ${targetValue * 256}`;
case "11": return...