re-written to do calculations in php. Should fix compatibility

not using the hw controller 'cause am not sure how. todo revisit this
at some point.