The INIT state is the initialization state for the state
machine and it is only entered once when the ESP8266
device is first powered up. In this state, the display page
number variable is set to one; display page 1 is shown on
the LCD, and the dataAcquisitionCount and the
displayAdvanceCount variables are initialized to a time in
the future when new weather data is to be acquired and
when the next display page is to be shown. The
CHECK_EVENTS state is then selected for the next iteration
of the loop() function.
The FSM will stay in the CHECK_EVENTS state until
one of the following things happen:
1. Activity is detected on the DST pushbutton switch.
2. The weather data acquisition count has expired and
new weather data needs to be acquired.
3. It is time to advance to the next display page.
The state of the FSM will change to
UPDATE_DST_STATUS if number one occurs; it will
change to ACQUIRE_DATA if number two occurs; and it
will change to ADVANCE_DISPLAY if number three occurs.
In the UPDATE_DST_STATUS state, the daylight saving
time (DST) status is toggled. If DST was on, it is turned off;
if it was off, it is turned on. Every change to the DST state
is stored in the ESP8266’s EEPROM so that it survives
The display page variable is then set so that display
page 7 (the NTP Time and Date page) will be displayed
the next time the ADVANCE_DISPLAY state is entered.
Finally, the state is changed to ADVANCE_DISPLAY for the
next trip through the loop.
In the ACQUIRE_DATA state, the retrieve WeatherData
function in the Weather class is called to acquire new
weather data. A call to this function causes a whole chain
26 November 2016
■ FIGURE 6. Display page 4: Night conditions
■ FIGURE 5. Display page 3: Day conditions forecast.
■ FIGURE 4. Display page 2: Current weather
■ FIGURE 3. Display page 1: Wi-Fi login and program