Time-domain LPF not showing expected behavior
Your math is correct but your code doesn't match it:

y = (wc*Ts*(x-xprev)+(2-wc*Ts)*yprev)/(2+wc*Ts)


It should be $x+xprev$ not $x-xprev$. The minus sign makes it a highpass and hence the attenuation.