Skip to content

Instantly share code, notes, and snippets.

@jinschoi
Last active October 6, 2022 01:44
Show Gist options
  • Save jinschoi/e184f2676cca1bf249d3d3041b9b6730 to your computer and use it in GitHub Desktop.
Save jinschoi/e184f2676cca1bf249d3d3041b9b6730 to your computer and use it in GitHub Desktop.
Plot Flipper RAW .sub captures
import plotly.express as px
import pandas as pd
import re
filename = 'Gar.sub'
points = [(0, 0)]
t = 0
with open(filename, 'r') as f:
for line in f:
m = re.match(r'RAW_Data:\s*([-0-9 ]+)\s*$', line)
if m:
for seg in [int(seg) for seg in m[1].split(r' ')]:
if seg > 0:
points.append((t, 1))
t += seg
points.append((t, 1))
else:
points.append((t, 0))
t -= seg
points.append((t, 0))
df = pd.DataFrame(points, columns=['µs', 'signal'])
fig = px.line(df, x='ms', y='signal', title=re.sub(r'\.sub$', '', filename))
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment