function showRf()
  local mon = peripheral.wrap("back")
  local rfin = peripheral.wrap("left")
  local rfout = peripheral.wrap("right")
  
  local rfinFee = (rfin.getAvgPowerUsage() - 2 - 6) * 2
  local rfoutFee = (rfout.getAvgPowerUsage() - 2 - 6) * 2
  
  local rfinPower = rfinFee * 20
  local rfoutPower = rfoutFee * 20 + rfout.getAvgPowerInjection() * 2
  local net = rfinPower - rfoutPower
  local netColor = colors.white
  if net > 0 then
    netColor = colors.green
  end
  
  if net < 0 then
    netColor = colors.red
  end
  
  mon.clear()
  mon.setTextScale(3)
  mon.setTextColor(colors.green)
  mon.setCursorPos(1, 1)
  mon.write(string.format(" Input: %d RF/t", rfinPower))
  
  mon.setTextColor(colors.red)
  mon.setCursorPos(1, 2)
  mon.write(string.format("Output: %d RF/t", rfoutPower))
  
  mon.setTextColor(netColor)
  mon.setCursorPos(1, 3)
  mon.write(string.format("   Net: %d RF/t", net))
  
  mon.setTextColor(colors.orange)
  mon.setCursorPos(1, 5)
  mon.write(string.format(" InFee: %d RF/t", rfinFee))
  
  mon.setCursorPos(1, 6)
  mon.write(string.format("OutFee: %d RF/t", rfoutFee))
end

while true do
  showRf()
  os.sleep(1)
end
