TrigonometricSeries[f_,x_,n_]:=ComplexExpand[FourierSeries[f,x,n]]

f[x_] = x - Floor[x/(2π)] (2π)-π;
u[x_] := 1-UnitStep[f[x]]

Plot[u[x],{x,-2π,2π}]

Table[TrigonometricSeries[u[x],x,n],{n,3,15,2}]

Tn=%

Plot[Tn[[-1]],{x,-2π,2π}]