Skip to content

Arduino Overview

Mikkel edited this page Jun 2, 2026 · 5 revisions

The device can operate in two modes:

Normal Mode - Connects to a configured WiFi network and periodically updates the display. Configuration Mode - Creates a WiFi access point and web interface that allows users to configure WiFi credentials.


System Startup Flow

The following diagram illustrates the overall startup process of the device.

After power on, the device either enters configuration mode when the button is pressed or attempts to connect using previously saved WiFi credentials. Once connected, the display update process begins.

flowchart TD
    A[loop] --> B{canClickBtn?}

    B -->|Yes| C[ButtonClick]
    B -->|No| D

    C --> D

    D{Not canClickBtn AND Not configMode AND Not connectFail OR isSaved?}

    D -->|No| E
    D -->|Yes| F{WiFi Connected?}

    F -->|No| G[WiFiConnect]
    F -->|Yes| H

    G --> H

    H{EPD refresh timer expired?}

    H -->|Yes| I[updateDisplay]
    H -->|No| E

    I --> E

    E{configMode?}

    E -->|Yes| J[APConnect]
    E -->|No| K[End Loop]

    J --> L{isSaved?}

    L -->|No| M[updateLED]
    L -->|Yes| K

    M --> K
Loading

Main Loop

The loop() function is the central controller of the application. It continuously evaluates the current device state and determines which actions should be performed.

Its responsibilities include:

  • Handling button interactions.
  • Managing WiFi connectivity.
  • Triggering display refreshes.
  • Running the configuration access point.
  • Updating status LEDs.
flowchart TD
    A[ButtonClick] --> B[Read button state]

    B --> C{Released? LOW -> HIGH}

    C -->|Yes| D[Enable config mode]
    D --> E[isSaved = false]
    E --> F[Disconnect WiFi]

    C -->|No| G

    F --> G

    G{State changed OR previous HIGH?}

    G -->|Yes| H[canClickBtn = false]
    G -->|No| I[Return]
Loading

ButtonClick

The ButtonClick() function monitors the state of the physical configuration button.

When the button is released, the device enters configuration mode, clears the current connection state, and disconnects from WiFi. This allows new WiFi credentials to be configured through the access point web interface.

flowchart TD
    A[Power On] --> B[Wait for Button]

    B --> C{Button Pressed?}

    C -->|Yes| D[Start Access Point]
    D --> E[User enters WiFi credentials]
    E --> F[Save credentials to EEPROM]

    F --> G[Connect to WiFi]

    C -->|No| G

    G --> H{Connected?}

    H -->|No| I[LED Error State]
    H -->|Yes| L[updateDisplay]
Loading

Display Update Process

The updateDisplay() function is responsible for retrieving content from the server and rendering it on the e-paper display.

The process consists of:

  • Fetching JSON from the configured endpoint.
  • Parsing the received JSON document.
  • Converting the JSON data into drawing commands.
  • Executing the generated drawing commands.
  • Updating the refresh timer.

If the JSON request fails, the update process is aborted and an error is logged.

flowchart TD
    A[updateDisplay] --> B[Fetch JSON]
    B --> C{Fetch Successful?}

    C -->|No| D[Log Error]
    D --> E[Return]

    C -->|Yes| F[Parse JSON]

    F --> H[Convert JSON to Draw Commands]

    H --> I[Execute Draw Commands]

    I --> J[Set Refresh Timer]

    J --> K[Return]
Loading

Clone this wiki locally