Skip to content

IndyJoeA/CANgage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

CANgage

CANgage displays CAN data in real-time on a mini display, meant to be placed near the driver's line of sight like on the steering column or dash. It is highly configurable to the user's own requirements. Multiple pages can be configured and scrolled between, each showing different data via a variety of widgets.

scr

Requirements

  • CANserver: A device that connects to a vehicle's canbus and sends decoded data over wifi.
    • More about CANserver: http://www.jwardell.com/canserver
    • Firmware 2.2 is required on the CANserver to support UDP communication. To receive this version you will have to switch your CANserver Release Channel to Development and then have it check for updates to install the latest version.
  • Display Module: Many ESP32-based display modules will ultimately be supported, firmware is currently available for the following. NOTE: The following boards also have touch-screen variants available. Touch control is not currently implemented, but the touch variants will still work as display only devices.

Feel free to join the CANserver Discord and the channel #displays-apps-accessories for discussion and the latest updates on development.

Firmware Installation

To install CANgage, a firmware file from the Releases page must be flashed to the device.

New firmware installation

If the firmware is being flashed to a device that does not currently have a version of CANgage installed, you will have to flash the binary file CANgage-HardwareType-USB-Factory.bin, where HardwareType must match the device you have. This binary file must be written to address 0x0000 and will overwrite the entire flash contents of the device, so it's not recommended to be used for upgrading versions. There are several utilities that can write firmware to ESP32-based devices, but here is a list of those that have been proven to work with CANgage:

  • ESPWebTool: https://esp.huhn.me/
    • Online flash tool, no download needed. Using this tool will require putting the device into programming mode (hold the boot button while quickly pressing the reset button, then release the boot button). Also make sure to change the address to 0x0000.

Upgrading firmware

If your device already has CANgage installed, you can update its firmware from the Status page. The file CANgage-HardwareType-OTA.zip is recommended as it contains both firmware and the WebUI files.

The firmware file options match those of the CANserver. More can be learned about these options from the CANserver manual.

Configuring CANgage

The device running CANgage must be in proximity to the CANserver so that it can connect to its wifi network. Once the CANgage is powered on, it will automatically connect to the CANserver. Browse to the CANserver's web config page located at http://canserver.local, then from the Network tab, you should see an entry for CANgage in the Clients list. Click the gear icon to be re-directed to CANgage's web configuration page.

Status page

The first tab is Status, and this displays the state of CANgage. You can also upload new firmware for CANgage at the bottom of this page.

status

Backup

Near the bottom of the Status page is a Backup button. This will download a CANgage-HardwareType-OTA-Data.bin file that serves as a complete backup of all display configuration and files that have been uploaded to CANgage. This file can be restored to the same device or a different device by using the Update feature and selecting this bin file.

Display page

The Display page is where all display related settings are configured. On this page are two sections, the Global Elements section and the Tiles section. Read below for details on how to use these sections to create your configuration.

display

Data settings

Many items in the configuration have a Data Type and Data Name setting. This allows you to select what data from the CANserver will be displayed by each item. From the Data Type dropbown box, select Analysis to pick from the CANserver's Analysis Items, Lua to pick from the CANserver's Lua scripting variables, or Accessory to pick from supported accessory data (see Accessories), and then select the specific data name from the Data Name dropdown. For more information about these data sources, see the CANserver manual sections on Analysis Items and LUA Scripting.

Accessories

Data from other devices connected to the same WiFi network as the CANgage device can also be shown on the display. Currently, the only accessory device supported is the Heated Steering Retrofit Controller for the Tesla Model 3/Y. Data from this device is retrieved every 2 seconds, so if using the Chart widget to graph data you don't need an update interval of less than 2 seconds. The following four data values from are available:

  • hswLevel: A number between 0 - 3 which represets the wheel heating level currently selected
  • hswTemp: The current temperature of the steering wheel in celsius
  • hswSetpoint: The current temp setpoint of the steering wheel in celsius
  • hswOutput: A value between 0 - 1024 representing the power being applied to the wheel heater

Settings editor

Most settings in the main configuration editor are required, with the exception of Description and Settings.

Items can be moved up or down in the editor. Moving Widgets will move them before or after the other Widgets in the same row/column, and moving Tiles will place them before or after other Tiles and change their index number.

The Delete button will delete the item or Tile.

The Settings button will display a popup window with specific settings for that item, if available. The text to the left of the Settings button will show the word Default if no changes have been made, or a number indicating how many settings have been configured. All of these settings are optional. If they are not configured then the item will be displayed with its default configuration.

Common settings

There are many settings that are repeated across the various elements & widgets described below. Here are descriptions of those settings that are referenced throughout below sections:

Category Description Settings
Value Value display settings. Values are the text component of most widgets.
  • Hide Value: Turns off the display of the text component showing the value. The data can still be shown through other visualizations if the Widget has other display components (like with the Arc, Bar, Chart, etc).
  • Font & Font Size: Font settings, see the Fonts section below.
  • Text Color: Selects the color of the value text.
  • Text Alignment: Selects the alignment of the value text.
Value Format Value format settings. Settings that allow the formatting of the data to be customized.
  • Format String: Specifies a custom formatting string for this value, following the printf formatting guidelines from programming langauges such as C/C++. The max length of the format string is 16 characters, and must contain an %f within the string since the values are floating point numbers. Some examples include:
    • %.1f - This is the CANgage default format, and shows one digit after the decimal (precision of 1).
    • %.0f - Shows no decimal (precision of 0).
    • %.0f kW - Shows a value with units at the end (kW).
  • Low Value & Low Value Color: This allows for conditional formatting. If the value goes below the specified Low Value, then it will be set to the Low Value Color.
  • High Value & High Value Color: This allows for conditional formatting. If the value goes above the specified High Value, then it will be set to the High Value Color.
Description Description settings. Descriptions are text components that are displayed in proximity to the widgets.
  • Font & Font Size: Font settings, see the Fonts section below.
  • Text Color: Selects the color of the description text.
  • Text Alignment: Selects the alignment of the description text.

Fonts

CANgage allows you to use a variety of built-in font sizes, or upload your own using the Files page. To use one of the built-in font sizes, leave the Font setting set to Default and select the desired size from the Font Size drop-down menu. If you have uploaded a custom font, select it from the Font drop-down menu and the Font Size menu will be disabled. Custom fonts are generated at a single font size per file, so if you want multiple sizes of the same font, you have to generate and upload the files individually.

Generating Custom Fonts

The file format used by CANgage for custom fonts is the LVGL binary bitmap font format. These files can be generated using common font files like TTF and WOFF with one of the following converters. For CANgage, it's recommended to generate fonts at 2 BPP (bits per pixel) which will help keep the file sizes small and will generally look just as good as higher settings on the small screens typically used. It's also recommended to turn off the compression option because compression will slow down text rendering. These converters require a character range to be specified, generally what works best is 0x20 - 0x7E, since this is the standard ASCII range. If you use any symbols outside this range, like the degrees symbol for example, you have to include the character codes for those as well.

Here are some resources for downloading free fonts online:

Global Elements

Global Elements are settings and screen elements that apply to the entire UI, regardless of which tile/page you are currently viewing. Click the + button in the top row to add a new Global Element to the configuration table.

Element Descriptions

The following explains the available element types and their settings:

Type Description Settings
Brightness Screen brightness control.
  • Data Type & Name: The data source that will provide the current screen brightness. The data should send a number between 0 (completely dark) and 255 (max brightness).
  • Default Brightness: The screen brightness used when the data source is not being used. Enter a number between 0 (completely dark) and 255 (max brightness).
Screen Default style settings for the screen.
  • Scrollbar: Turns on a scrollbar which is displayed when more than one Tile is configured.
  • Rotation: Rotates the screen clockwise from the starting position. Select between 0 degrees (landscape), 90 degrees (portrait), 180 degrees (inverted landscape), or 270 (inverted portrait).
  • Mirror: Mirrors the screen image, which is useful when reflecting the display onto a windshield for use as a HUD.
  • Background Color: This will set the color of the background of the entire screen.
  • Gradient Color: This color will be used along with the specified Background Color to create a vertical gradient.
Scroll Scroll settings for scrolling between Tiles.
  • Data Type & Name: The data source that will provide the current Tile to be shown. The data should send a number representing the Tile index number.
  • Disable Animation: This will disable the scrolling animation.
Status Ability to show various status items.
  • WiFi Status Icon: Turning this on will display a WiFi symbol in the top right of the screen which will change color depending on the WiFi connection status.
  • WiFi Icon Size: Sets the size of the WiFi icon if it has been enabled.
  • Debug Text: Turning this on will display debug information at the bottom of the screen, such as connection status and a WPS (websockets per second) counter.
Text Default style settings for screen text.
  • Default: Sets the default settings for all text on the screen, unless a more specific style has been selected.
  • Description: Sets the default settings for description text on the screen, unless a more specific style has been selected. This overrides the Default Font settings.
  • Value: Sets the default settings for value text on the screen, unless a more specific style has been selected. This overrides the Default Font settings.
  • More specifics about these text settings can be found under Common settings.
Title Shows title information for the currently selected Tile.
  • Separator: Turns on a horizintal separator line under the Title area. The color matches the Title's Text Color.
  • Background Color: This will set the color of the background of the Title area. If this is left unset then no background will be shown.
  • Gradient Color: This color will be used along with the specified Background Color to create a vertical gradient on the Title's background.
  • Text: Settings for the Title text. See more about text settings under Common settings.

Tiles

Tiles are containers for individual widgets. You can create just a single Tile, or as many as you need for organizing your data, and then enable scrolling so that the Tiles can be rotated between while in use. Click the + button to add a Tile to the configuration, and then give it a Name and a Layout.

Each Tile also has an index number, starting at 0 for the first Tile. Any additional Tiles will add to the index, with the second Tile being 1, the third Tile being 2, and so on.

Layouts

There are currently two layout options to choose between, Row and Column. When Row is selected, all Widgets will be added into a single row from left to right. If Column is selected, the Widgets will be added in a single column from top to bottom. Regardless of which layout is selected, all Widgets will be sized automatically and given the same amount of space in their row/column. Each Widget has an option called Next, which will cause that Widget to be placed into a new row/column. Any additional Widgets will be added into the same row/column until another Next option is encountered.

Widget Descriptions

In addition to the following settings, each Widget also has an optional Description field that will put Description Text below the Widget.

The following explains the available Widgets and their settings:

Type Description Settings
Arc Circular widget showing the data value in an indicator arc with the numeric value in the center.
  • Min & Max Value: Sets the minimum and maximum value that the arc will display.
  • Mode: Normal mode will display the arc value from left to right, Reverse mode will display the arc value from right to left, and Symmetrical mode will put the mid-point in the middle of the arc.
  • Knob: Adds a solid circle at the current value point.
  • Foreground Color: Selects the color of the indicator arc and the knob.
  • Value, Value Format & Description: These settings are described under Common settings.
Bar Bar widget showing the data value in an indicator bar with the numeric value in the center. The bar will be drawn horizontally or vertically depending on the dimensions of the widget.
  • Min & Max Value: Sets the minimum and maximum value that the bar will display.
  • Mode: Normal mode will draw the bar from left to right, and Symmetrical mode will put the mid-point in the middle of the bar.
  • Foreground Color: Selects the color of the indicator bar.
  • Gradient Color: This color will be used along with the specified Foreground Color to create a color gradient on the bar's indicator.
  • Value, Value Format & Description: These settings are described under Common settings.
Blank Puts a blank space in this spot. Useful for adjusting the positioning of other widgets.
Chart Chart with lines connecting datapoints and the numeric value shown in the center by default. Additional data sources can be added to the same Chart with the ChartData Widget.
  • Min & Max Value: Sets the minimum and maximum value for the Y-axis of the chart.
  • Number of Points: Sets how many datapoints are shown on the Chart.
  • Indicators: Turns on small indicator circles that highlight where the datapoints are.
  • Update Interval (ms): The chart does not update like the other Widgets, which update immediately as new data arrives. Instead it updates on a fixed interval set in milliseconds (1000 milliseconds = 1 second).
  • Chart Data: See the section below on ChartData for a description of these settings.
  • Value, Value Format & Description: These settings are described under Common settings.
ChartData This will add a data source to whatever Chart Widget is listed above it in the settings editor. This allows for multiple data series to be shown on the same Chart.
  • Data Color: Sets the color of the lines and datapoints.
  • Show Gaps: This is off by default, which will connect all datapoints together even if the data has not changed since the last update. With Show Gaps turned on, the lines will be broken when data has not arrived since the last update.
Value Numeric value shown in the center of the widget.
  • Value, Value Format & Description: These settings are described under Common settings.

Save button

Upon clicking the Save button, the configuration will first be checked for any issues. If any are found they will be highlighted red and an alert message will apppear on the page. Once you correct the issues, click Save again to upload the configuration to the CANgage where it will be saved to flash storage and then generate the requested UI. When CANgage reboots, it will load this same config and display it on screen even before the device has connected to the CANserver.

Memory and status text

Between the Save and Import/Export buttons is a status message area that will generally display the current UI memory used percentage. As you create and save your configuration, this percentage will rise. Be careful not to go to close to 100% since the CANgage firmware could lockup if it runs out of memory.

The status area will also display the result of saving, and some error messages will be shown here as well.

Import/Export

The entire Display page can be imported and exported with the buttons at the top right of the page. Export will generate a .json file which can be kept as a backup, or shared with others. Import will request this same .json file and once loaded will replace all of the current settings with those from the .json file.

Files page

The Files page allows you to upload files to CANgage, which is divided into sections by file type. Currently the only section is for uploading Fonts. Click the + button to upload a new font, or the Delete button to delete a font. At the top of the page is a status indicator that shows the current Data Storage Used.

Files