This program already exists for XPERIA X1, HTC HD2, Touch Pro2  and it’s tested and works. So here is the task29 program for your HTC Diamond (GSM version).