Just some notes:
this does logically not make sense. In order to connect to the Particle cloud you need the WiFi on before that.
And WiFi.on() alone does not cause WiFi.ready() ever to become true. For that you'd need to call WiFi.connect() - or let Particle.connect() do that, but as said after you switched the WiFi module on.
Also this is an impossible condition
You can under no circumstance ever be still in the "trying to connect" to the WiFi network state but already connected to Particle cloud.
There is no need to convert event to String(). Particle.publish() will happily accept a C-string as is. And I'd use %.1f instead of full width floats via %f.
And your code is quite convoluted with all these Serial.println() lines. You can have the same thing happen with adding a set of \r\n at the end of any actual Serial.print() statement. And there is also a Serial.printf()/Serial.printlnf() that allows you to format your string like with sprintf() which helps reducing these mulit-line blocks of Serial.print() statements into a single line of code.
You may also want to add some sanity checks in your Particle.function() callbacks to guard against invalid command parameters.
You are also EEPROM.write()ing a float but that will give you wrong values in many cases as the second parameter is a uint8_t.
In your place I'd rather create a struct that holds your values and use EEPROM.put() and EEPROM.get() instead. That also reduces write cycles and hence flash wear.
I'm also not quite getting the use of this statement
The result of that is not 2000 but rather write_time so what is all that extra effort for?
When you put the values for Photon in, you get
clear = (2047 - 48) - (2047 - 48 - x) =
= 2047 - 48 - 2047 + 48 + x = x