This is a extension to the code from qmarco.
Biggest change is that the software controls the motor current based on the torque sensor insead of the battery current. Reason is that motor current is equal to torque so the result should be a smoother motor assistance.
discussions:
Endless Sphere: https://endless-sphere.com/forums/viewtopic.php?f=30&t=98281
italian forum: http://www.jobike.it/forum/topic.asp?TOPIC_ID=76426&whichpage=1
english forum: https://endless-sphere.com/forums/viewtopic.php?f=30&t=98281
german forum: https://www.pedelecforum.de/forum/index.php?threads/software-f%C3%BCr-tsdz2-sfm-du-250-350-mittelmotor-umbausatz.50939/