fn="F:\03.pr"
fd=mopen(fn,'rb');
mseek(0,fd,'end');
flen=mtell(fd);
mseek(0,fd);
ns=floor(flen/2);
pr=mget(ns,'usl',fd); //specify big-endian ('usb') or little-endian ('usl')
//lower number corresponds to higher pressure
mclose(fd);

function u=unwrap2(d,j) //scilab unwrap() is finicky
    f=[j/2-j/4,j/2+j/4];
    r1=(d<f(1));
    r2=(d>f(2));
    r3=r1(1:$-1)&r2(2:$);//jumping down point
    r4=r2(1:$-1)&r1(2:$);//jumping up point
    r5=cumsum(-1*r3+1*r4);
    u=d+[0,r5]*j;
endfunction

function o=movavg(d,n) // moving average filter
    c=cumsum(d);
    o=(c(n:$)-[0,c(1:$-n)])./n;
endfunction

prticks=unwrap2(pr,65536)+22*65536;//scale to full frequency 150 MHz timer ticks at each sample by adding in approximate wrap-around amount, depending on divider settings determine this using nominal frequency
prtime=cumsum(prticks/150e6);//time difference between samples
fr=(150e6./prticks)*298;//scale to sensor frequency by multiplying by pulse divider
// Frequency goes up with higher pressure, pr goes down
//plot(prtime, fr);//plot frequency over time
//ylabel("Freq / Hz");

pres=getpressure(fr);//apply sensor calibration function to get pressure in Pa from frequency in Hz
//plot(prtime, pres);//plot pressure over time
plot(prtime(5:$-5), movavg(pres,10));//plot filtered pressure over time
ylabel("Pressure / Pa");
xlabel("Time / s");