# Energy Monitor Demo

![Energy Monitor Demo Screenshot](https://slint.dev/resources/energy-monitor-screenshot.png "Energy Monitor")

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

## Displaying Real-Time Weather Data

Real-time weather data is fetched from [Open-Meteo](https://open-meteo.com/). No API key is required. The geographical location can be set using the `WEATHER_LAT` and `WEATHER_LONG` environment 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:
```sh
cargo run --manifest-path demos/energy-monitor/Cargo.toml
```

### Microcontrollers (MCU)

Refer to the [MCU backend Readme](../../examples/mcu-board-support) 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`

```sh
cargo run --manifest-path demos/energy-monitor/Cargo.toml --no-default-features --features=simulator --release
```

### Android

First, [set up your Android environment](https://slint.dev/snapshots/master/docs/rust/slint/android/#building-and-deploying).
Then, you can run the demo on an Android device with the following command:

```sh
cargo apk run --manifest-path demos/energy-monitor/Cargo.toml --target aarch64-linux-android --lib
```

### Node.js

```sh
cd demos/energy-monitor
pnpm install
pnpm start
```

Set `WEATHER_LAT` and `WEATHER_LONG` to change the location (defaults to Berlin).

### Web

```sh
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](https://developer.apple.com/xcode/).
 - [Xcodegen](https://github.com/yonaskolb/XcodeGen?tab=readme-ov-file#installing)
 - [Rust](https://rustup.rs). 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.

