The code is based on the awesome arduino-foc project, just is implemented in zig and uses a timer for the servo control loop.
The video shows closed loop velocity control but it also works with position control.
Since it's closed loop when a load is put on the motor the controller will increase the voltage up to a limit in order to try and achive the desired output.
It uses the stm32's hardware encoder timer mode with a 2000 cpr encoder. There are 3 pwm signals to set the phase voltages. Also shows the i2c driver running the LCD and a software encoder for the rotary encoder knob.
Just for kicks. Here's it using position/angle control.
The motor is a really old Pittman Elcom BLDC servo (model 4232B514) with a huge HP HEDS-6310 encoder. I think 3 motors with encoders were something like 30 yankee bucks shipped on ebay so I can't complain. They seem to work fine up to about 1.5A and can go higher just not continously (or the coating starts to melt and smell (oops)).
I couldn't find the exact datasheet for the encoder but found a similar model and this is the pinout (A).
Have a good day!