P2 is the number of times the speed sensor flashes per revolution. For no sensors, use P2=0 .For an external sensor, P2=1. Many bafang motors with internal sensors use P2=6, while others use P2=1.
P1 refers to the number of magnets in the motor x the gearing. This is used to calculate the speed when the motor is spinning, If you have a direct drive motor, it's just the number of magnets. There's no need to be exact, as you can only enter a few preset wheel sizes. I've got two bikes where the tire size is a 1/2" apart, and one of these days, I'll try to adjust P1 so they aren't 5% apart after 20 miles. If you don't know this number, it can be measured by counting how many times a Hall sensor flashes in one turn. Just set P1 so the speedometer is giving you something close. Oddly enough, if I set P1 arbitrarily low, like 30 when it should be 200, it actually slows down the no lpad rpm, meaning there is a performance impact.