Skip to content

Configuration

captncode edited this page May 2, 2021 · 4 revisions

Configuring the application

The appsettings.json and appsettings.Development.json files house all the configuration options. Visual Studio automatically uses the Development file when you are running in debug mode, so you can omit the E-Paper driver in that file and test everything else locally.

There are also separate appsettings files for the API, Console and Desktop apps. Since they each use different sections from the configuration file, you can combine their contents into one common file, either locally or on the Raspberry Pi for simplicity.

Here is a sample combined configuration file.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "Api": {
    "Drivers": [
      {
        "DriverType": "eXoCooLd.Waveshare.EPaperDisplay",
        "Driver": "WaveShare7In5_V2",
        "RefreshTime": "2:00"
      },
      {
        "DriverType": "TCPSocket",
        "Driver": "127.0.0.1:20000"
      },
      {
        "DriverType": "IPCSocket",
        "Driver": "/tmp/iotdisplay.sock"
      }
    ],
    "Width": 800,
    "Height": 480,
    "Rotation": 0,
    "StateFolder": "/home/iotdisplay/",
    "BackgroundColor": "#ffffff",
    "ForegroundColor": "#000000"
  },
  "Console": {
    "BaseUrl": "http://localhost:5000/api/Action/"
  },
  "Desktop": {
    "SocketType": "TCPSocket",
    "Host": "127.0.0.1:20000"
  }
}

Logging is used by .NET Core and AllowedHosts is a Kestrel Web Server host filtering configuration option. They are only needed by the API application. The remaining three sections, Api, Console and Desktop, are used by their corresponding applications to configure important features.

Api Section

Drivers You can have zero to many drivers configured at a time. Having no drivers in this section is useful for testing and development since the Web API is still available for viewing screen contents.

  • A DriverType of eXoCooLd.Waveshare.EPaperDisplay adds the application's WsEpaperDisplayService for E-Paper display. The supported Driver values can be found here. Render activity is not sent immediately to the E-Paper display by this service. See the wiki Home page for more detail.

    • RefreshTime is the time of day to flush and refresh the E-Paper display. This helps keep the display as clear as possible. If omitted, the display will not be refreshed.
  • A DriverType of TCPSocket adds the application's SocketDisplayService for sending screen contents to a TCP IPEndPoint using a custom protocol. The Driver is the host and port of the listener. A blank value will default to the system IP and port 11000.
    See the wiki Home page for more information on clients and delays.

  • A DriverType of IPCSocket adds the application's SocketDisplayService for sending screen contents to a UnixDomainSocketEndPoint using a custom protocol. The Driver is the path to the socket file, which will be created when the application starts. See the wiki Home page for more information on clients and delays.

Width and Height configure the screen dimensions. If you use an eXoCooLd.Waveshare.EPaperDisplay driver, any values entered here will be ignored, and the screen dimensions of the chosen E-Paper display will be used instead.

Rotation configures the screen orientation. Allowed values are 0, 90, 180 and 270 with 0° being landscape and 180° being landscape flipped.

StateFolder configures the folder for RenderService and the ClockService to store state files. These files are used when the application restarts to restore the screen to its previous state. /tmp will not work as the folder is flushed after reboot.

BackgroundColor is used by the clocks to erase the previous text. It should be entered using a hexadecimal color string, with or without a preceding '#' character formatted like: AARRGGB, RRGGBB, ARGB or RGB.

ForegroundColor defines the default text color. It should be entered using a hexadecimal color string, with or without a preceding '#' character formatted like: AARRGGB, RRGGBB, ARGB or RGB.

Console Section

The only configuration here is the BaseUrl which is the URL used by the console app to communicate to the Web API.

Desktop Section

SocketType allowed values are TCPSocket and IPCSocket.

For TCPSocket, Host is the host and port that the SocketDisplayService is listening on.

For IPCSocket, Host is the path to the socket file.