(*Helper functions*)
delta[x_,val_]:=DiracDelta[x-val](*Delta*)
step[x_,start_]:=UnitStep[x-start] (*Step*)
ramp[x_,start_]:=x step[x,start] (*Ramp*)
rect[x_,lower_,upper_]:=step[x,lower]-step[x,upper] (*Rectangle*)

(*Static function*)
f[x_,a_]:=(step[x,2] - step[x, a])
	(*Slider parameters*)
	fVarMin=3;
	fVarMax=15;
	fStep=1;
	fVarDefault=13;

(*Function that's swept with t*)
g[x_,a_]:=(step[x, 5] - step[x, a])
	(*Slider parameters*)
	gVarMin=6;
	gVarMax=13;
	gStep=1;
	gVarDefault=11;

(*t parameters*)
tMin=-10;
tMax=30;
tStep=1;
tDefault=tMin;

(**************************************************)
(***Shouldn't need to change any code below this point***)
(**************************************************)


(*Symbolic calculation of the convolution*)
ClearAll[fVar,gVar,t]
h[y_,fVar_,gVar_]:=Evaluate@DiscreteConvolve[f[x,fVar],g[x,gVar],x,y]

(*Set plot variables*)
min=Min[
MinValue[{f[tt, ff],tMin≤tt≤tMax&&fVarMin≤ff≤fVarMax},{tt,ff}],
MinValue[{g[tt, gg],tMin≤tt≤tMax&&gVarMin≤gg≤gVarMax },{tt,gg}],
MinValue[{h[tt, ff, gg],tMin≤tt≤tMax&&fVarMin≤ff≤fVarMax&&gVarMin≤gg≤gVarMax },{tt,ff,gg}]
];
max=Max[
MaxValue[{f[tt, ff],tMin≤tt≤tMax&&fVarMin≤ff≤fVarMax},{tt,ff}],
MaxValue[{g[tt, gg],tMin≤tt≤tMax&&gVarMin≤gg≤gVarMax },{tt,gg}],
MaxValue[{h[tt, ff, gg],tMin≤tt≤tMax&&fVarMin≤ff≤fVarMax&&gVarMin≤gg≤gVarMax },{tt,ff,gg}]
];
xMin=tMin-0.1;
xMax=tMax+0.1;
yMin=min-0.1(max-min);
yMax=max+0.1(max-min);
range={{xMin,xMax},{yMin,yMax}};

(*Set default slider values*)
fVar=fVarDefault;
gVar=gVarDefault;
t=tDefault;
m=Manipulate[
Show[
DiscretePlot[{f[x,fVar],g[t-x,gVar],f[x,fVar] g[t-x,gVar]},{x,tMin-3,tMax+1},PlotRange->range,PlotStyle->{Blue,Green,Black},Filling->{3->Axis}],
DiscretePlot[h[x,fVar,gVar],{x,tMin-3,t},PlotRange->range,PlotStyle->Red,PlotLegends->LineLegend[{Blue,Green,Black,Red},
{"f(τ)="<>ToString[ f[τ, fVar],FormatType->TraditionalForm],
"g(t-τ)="<>ToString[g[t-τ,gVar],FormatType->TraditionalForm],
"f(τ) × g(t-τ)",
"f(τ) ⋆ g(τ)"}],PerformanceGoal->"Speed"],
Graphics[{
Dashed,Line[{{t,yMin},{t,yMax*0.85}}],
Text[Style["t",16],{t,yMax 0.95}]
}]
],
{fVar,fVarMin,fVarMax,fStep,Appearance->"Labeled"},
{gVar,gVarMin,gVarMax,gStep,Appearance->"Labeled"},
{t,tMin,tMax,tStep,Appearance->"Labeled"},
SaveDefinitions->True,
LocalizeVariables->False
]