slint/demos/energy-monitor
2025-07-04 18:35:52 +02:00
..
src Prospective build fix for non-esp mcu-board-support crate builds 2025-04-15 11:32:27 +02:00
ui Examples/Demos: fix warning about unused padding 2025-07-04 18:35:52 +02:00
build.rs Move printer demo and energy-monitor into new top-level demos/ folder 2024-10-25 12:09:32 +02:00
Cargo.toml Bump version number to 1.13.0 2025-06-26 13:30:43 +00:00
index.html Move printer demo and energy-monitor into new top-level demos/ folder 2024-10-25 12:09:32 +02:00
ios-project.yml iOS: Disable the sandbox for the cargo build script by default 2025-05-20 11:07:19 +02:00
README.md Add iOS build of the Energy Monitor and Home Automation demos 2025-05-20 11:07:19 +02:00

Energy Monitor Demo

Energy Monitor Demo Screenshot

This is a demonstration of the Slint toolkit. This demo can be executed on various platforms.

Displaying Real-Time Weather Data

To showcase real-time weather data, you will need an application key from https://www.weatherapi.com/. You can inject the API key by setting the WEATHER_API environment variable. The geographical location for the weather data can be set using the WEATHER_LAT and WEATHER_LONG variables. By default, the location is set to Berlin.

Platform Compatibility

Desktop (Windows/Mac/Linux) or Embedded Linux

You can run the demo on a desktop or embedded Linux environment with the following command:

cargo run -p energy-monitor

Microcontrollers (MCU)

Refer to the MCU backend Readme for instructions on how to run the demo on smaller devices like the Raspberry Pi Pico.

To run the MCU-like code on desktop, use the --features=simulator

cargo run -p energy-monitor --no-default-features --features=simulator --release

Android

First, set up your Android environment. Then, you can run the demo on an Android device with the following command:

cargo apk run -p energy-monitor --target aarch64-linux-android --lib

Web

cargo install wasm-pack
cd demos/energy-monitor/
wasm-pack build --release --target web --no-default-features --features slint/default,chrono
python3 -m http.server

Building and running on iOS

This demo can be cross-compiled to iOS to run on iPhones, iPads, and the respective simulators.

Prerequisites

  • A computer running macOS.
  • An up-to-date installation of Xcode.
  • Xcodegen
  • Rust. Add the target and simulator toolchains using rustup target add aarch64-apple-ios and rustup target add aarch64-apple-ios-sim

Building

  1. Run xcodegen -s ios-project.yml to generate an XCode project file (.xcodeproj).
  2. Open XCode and open the generated .xcodeproj in it.
  3. Run, deploy, and debug the demo from within Xcode.