Code reorganization

Some more general function is relocated to Settings from Menu.
Waveform functions are partly written.