[lib] Added pwm_str_set_len()

This functions sets the buffers len and ensures 0 termination after
checking the buffers bounds.