Fix incorrect speed calculation

This commit is contained in:
Davide Depau 2018-08-15 18:10:39 +02:00
parent ea9c68eaad
commit 8c158c8cef

View file

@ -81,7 +81,7 @@ abstract class UsbWriteService(name: String) : IntentService(name) {
if (time <= prevTime + 1000) if (time <= prevTime + 1000)
return return
val speed = ((bytes - prevBytes).toDouble() / (time - prevTime).toDouble()).toHRSize() val speed = ((bytes - prevBytes).toDouble() / (time - prevTime).toDouble() * 1000).toHRSize()
prevTime = time prevTime = time
prevBytes = bytes prevBytes = bytes
@ -104,7 +104,7 @@ abstract class UsbWriteService(name: String) : IntentService(name) {
.setContentText("$usbDevice may have been unplugged while writing.") .setContentText("$usbDevice may have been unplugged while writing.")
.setSubText(dt.toHRTime()) .setSubText(dt.toHRTime())
else { else {
val speed = (dt.toDouble() / bytes.toDouble()).toHRSize() + "/s" val speed = (bytes.toDouble() / dt.toDouble() * 1000).toHRSize() + "/s"
b.setContentTitle("Write finished") b.setContentTitle("Write finished")
.setContentText("$filename successfully written to $usbDevice") .setContentText("$filename successfully written to $usbDevice")
.setSubText("${dt.toHRTime()}${bytes.toHRSize()}$speed") .setSubText("${dt.toHRTime()}${bytes.toHRSize()}$speed")