% Jon Newman
% Make triangle stimulus waveforms with various slopes but preserved areas.
function [tri, time] = make_max_power_triangles(T,Vmax,dt,aoff)

% v_pd_offset 
det_offset = 0.08; 
det_offset = 0.00; 

% Area preserving max amplitude
P = Vmax*ones(size(T));         % Area preserving; Results are in mW/mm^2

% Waveform storage
tri = cell(numel(T),1); % Storage
time = cell(numel(T),1); % Storage

for i = 1:length(T)
    t = dt:dt:T(i);  
    s = P(i)/T(i);
    tri{i} = [t*s + det_offset, aoff];  
    time{i} = [t, t(end) + dt]/1000;
end

end