syncsign

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2022 License: MIT Imports: 19 Imported by: 1

README

Go Reference GitHub go.mod Go version GitHub release (latest by date) Go Report Card Actions Status

HomeDashboard Renderer for SyncSign® eInk Displays

Renders listen to a data source and generates content for SyncSign® eInk displays.

Renderers

All renderers implement the Renderer interface to provide generic way for content generation.

Response Renderers

Response renderers generates response payload used in SyncSign template servers, in JSON format.

Successful Response

Renderer for a successful response generates JSON content with necessary structure and includes items from depending renderes passed on initialization. Use NewResponseRenderer for initialization.

Config

Response renderer config contains template file, only.

hdb:
  response:
    template: "response.json"
Error Response

In case something went wrong during content genration, error renderer can be used to generate a suitable server response for an error. Use NewErrorRenderer for initialization.

Config

Error renderer config contains template file, only.

hdb:
  error_response:
    template: "error_response.json"

Item Renderer

Item renderers generates items which should be display on eInk screen. This can be simple text, geometric shapes or icons.

Indoor Climate Renderer

This renderer listen to a data source for indoo climate, which includes temperature, humidity and, depending on used sensor, battery status. Indoor climate data can be processed for diferent devices and can be assigned by config to seperate rooms. Same template is used for each room and all rooms will be displayed in a row until scrren width exceeds. Initialized by NewIndoorClimateRenderer.

Config

Following example config contains all available config options for indoor climate renderer.

hdb:
  indoorclimate:
    template: "indoorclimate.json"
    anchor: 
      x: 10
      y: 10
    size:
      height: 200
      width: 200
    border: 5
    rooms:
      - id: "1"
        name: "Room1"
        displayIndex: "0"
      - id: "2"
        name: "Room2"
        displayIndex: "1"
    devices:
      - id: "Device2"
        roomId: "1"
      - id: "Device1"
        roomId: "2"
Template

Config option to set template file which should be used to generate a single room element. This file will be reused for all rooms.

Anchor

An anchor defines the upper left corner of element for first room.

Size

Defines the entire size of a romm element which includes temperature, humidity and battery status icon.

Border

Defines a space in pixel between each room element. Border can be set in general for top, right, bottom and left or for each attribute separately.

Rooms

List of room which should be displayed as single element on screen, DisplayIndex defines the order of rooms on the screen from left to right. Name will be displayed on screen and id is used to assign devices.

Devices

Each room needs at least one assigned device to be displayed on screen.

General Config

Tempalte Directory

Use following config to set directory of templates for all renderers. Default value is folder "templates" at runtime location.

hdb:
  template_dir: "templates"

Supported Display

Only 7.5 inch display is supported for HomeDashboard project.

Documentation

Index

Constants

View Source
const (
	COLOR_WHITE textColor = "WHITE"
	COLOR_BLACK textColor = "BLACK"
	COLOR_RED   textColor = "RED"
)
View Source
const (
	BATTERY_LEVEL_4_4 batteryLevelIcon = "\uf240"
	BATTERY_LEVEL_3_4 batteryLevelIcon = "\uf241"
	BATTERY_LEVEL_2_4 batteryLevelIcon = "\uf242"
	BATTERY_LEVEL_1_4 batteryLevelIcon = "\uf243"
	BATTERY_LEVEL_0_4 batteryLevelIcon = "\uf244"
)

Variables

This section is empty.

Functions

func NewErrorRenderer

func NewErrorRenderer(template core.Template, nodeId string, err error) core.Renderer

NewErrorRenderertemplate returns a renderer which generates items with passed error message.

func NewIndoorClimateRenderer

func NewIndoorClimateRenderer(conf config.Config, logger log.Logger, template core.Template, datasource core.DataSource) core.Renderer

NewIndoorClimateRenderer returns a new renderer for infoor climate data. Room will be taken from passed config, template and datasource have to be passed.

func NewResponseRenderer

func NewResponseRenderer(template core.Template, nodeId string, itemRenderer []core.Renderer) core.Renderer

NewResponseRenderer returns a new renderer for eInk main content. Passed data have to contain all items which shloud be displayed.

Types

type DisplayConfig

type DisplayConfig struct {
	// contains filtered or unexported fields
}

func NewDisplayConfig

func NewDisplayConfig(conf config.Config) *DisplayConfig

NewDisplayConfig extracts list of display ids from passed config and returns a DisplayCondig which can be used to ensure valid display ids.

func (*DisplayConfig) All

func (cfg *DisplayConfig) All() []string

All returns the list of all available display ids.

func (*DisplayConfig) Exists

func (cfg *DisplayConfig) Exists(displayId string) bool

Exists returns true if passed display id is available in internal display list.

type ErrorRenderer

type ErrorRenderer struct {
	// contains filtered or unexported fields
}

func (*ErrorRenderer) Content

func (renderer *ErrorRenderer) Content() (string, error)

Content returns errpr message passed at initialization as items. Together with a title and a timestamp.

func (*ErrorRenderer) ObserveDataSource

func (renderer *ErrorRenderer) ObserveDataSource(ctx context.Context)

ObserveDataSource has no effect for error renderer, because there's no datasource.

func (*ErrorRenderer) Size

func (renderer *ErrorRenderer) Size() core.Size

Size returns size of entire error message box.

type ResponseRenderer

type ResponseRenderer struct {
	// contains filtered or unexported fields
}

func (*ResponseRenderer) Content

func (renderer *ResponseRenderer) Content() (string, error)

Content returns the main layout for eInk display which includes renderer/node id and all passed items.

func (*ResponseRenderer) ObserveDataSource

func (renderer *ResponseRenderer) ObserveDataSource(ctx context.Context)

ObserveDataSource has no effect for response renderer, because there's no datasource.

func (*ResponseRenderer) Size

func (renderer *ResponseRenderer) Size() core.Size

Size is equal to size of 7.5 inch screen.

Directories

Path Synopsis
k8s module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL