Skip to content

Commit 24b2eed

Browse files
committed
Updated documentation with new features and directory structure #285
1 parent 4e0ff96 commit 24b2eed

37 files changed

Lines changed: 724 additions & 293 deletions

File tree

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The user manual is available in the openHAB documentation at <https://next.openh
1212

1313
---
1414

15-
# Table of Contents
15+
## Table of Contents
1616

1717
This README covers the following topics:
1818

@@ -34,7 +34,7 @@ This README covers the following topics:
3434

3535
---
3636

37-
# Introduction
37+
## Introduction
3838

3939
This app is built using the Garmin Connect IQ SDK and is based on [openHAB sitemaps](https://www.openhab.org/docs/ui/sitemaps.html).
4040

@@ -43,7 +43,9 @@ It includes two application types:
4343
- _**Glance**_: A lightweight, quick-access entry point.
4444
- _**Widget**_: The main, full-screen interface for interacting with the sitemap.
4545

46-
## _Widget_ Overview
46+
<br>
47+
48+
### _Widget_ Overview
4749

4850
The _Widget_:
4951

@@ -55,7 +57,7 @@ The _Widget_:
5557

5658
<br>
5759

58-
## _Glance_ Overview
60+
### _Glance_ Overview
5961

6062
The _Glance_:
6163

@@ -70,11 +72,11 @@ The _Glance_:
7072

7173
---
7274

73-
# Project Structure
75+
## Project Structure
7476

7577
The project is organised into the following directories:
7678

77-
## Root Folder `/`
79+
### Root Folder `/`
7880

7981
The root directory contains essential project files.
8082

@@ -91,19 +93,19 @@ The root directory contains essential project files.
9193

9294
<br>
9395

94-
## Folder `/.vscode`
96+
### Folder `/.vscode/`
9597

9698
Contains VS Code customizations.
9799

98100
<br>
99101

100-
## Folder `/docs`
102+
### Folder `/docs/`
101103

102104
Contains the user manual, published at <https://next.openhab.org/docs/apps/garmin/>.
103105

104106
<br>
105107

106-
## Folder `/resources`
108+
### Folder `/resources/`
107109

108110
In the Connect IQ SDK, resources define:
109111

@@ -129,20 +131,20 @@ In the Connect IQ SDK, resources define:
129131

130132
<br>
131133

132-
## Folder `/source`
134+
### Folder `/source/`
133135

134136
The app is written in **Monkey C**, Garmin's programming language, using the Connect IQ SDK API for UI, settings, persistent storage, and HTTP requests to openHAB.
135137

136138
For more details, continue reading the folder’s [README](source/README.md).
137139

138140
<br>
139141

140-
# Build Instructions
142+
## Build Instructions
141143

142144
Follow the steps below to build, run, and test the app using the Connect IQ SDK and Garmin simulator.
143145
<br>
144146

145-
## To Run the App in the Garmin Simulator
147+
### To Run the App in the Garmin Simulator
146148

147149
1. Install:
148150
- Visual Studio Code
@@ -158,13 +160,13 @@ Follow the steps below to build, run, and test the app using the Connect IQ SDK
158160

159161
<br>
160162

161-
## To Compile for a Single Device
163+
### To Compile for a Single Device
162164

163165
1. Press `CTRL+SHIFT+P``Monkey C: Build Current Project`
164166

165167
<br>
166168

167-
## Generating the `.iq` File for Garmin Connect IQ Store Upload
169+
### Generating the `.iq` File for Garmin Connect IQ Store Upload
168170

169171
Follow these steps to prepare and export your app for upload to the Garmin Connect IQ Store:
170172

@@ -194,7 +196,7 @@ Follow these steps to prepare and export your app for upload to the Garmin Conne
194196

195197
<br>
196198

197-
## To Add a New Device
199+
### To Add a New Device
198200

199201
To support a new device:
200202

@@ -211,11 +213,11 @@ To support a new device:
211213

212214
<br>
213215

214-
# Helpful Tips and Notes
216+
## Helpful Tips and Notes
215217

216218
A collection of useful information for working on this project.
217219

218-
## Removing Debug Statements
220+
### Removing Debug Statements
219221

220222
While debug statements are only printed in debug builds, they still occupy code space in release builds. Therefore, when building a release, all debug statements should be commented out.
221223

@@ -233,7 +235,7 @@ To deactivate the debug statements, replace them with:
233235

234236
This will comment them out without affecting any lines that are already commented.
235237

236-
# Copyright Notice
238+
## Copyright Notice
237239

238240
```text
239241
Copyright (c) 2025 Contributors to the openHAB project
@@ -245,6 +247,6 @@ http://www.eclipse.org/legal/epl-2.0
245247
SPDX-License-Identifier: EPL-2.0
246248
```
247249

248-
# Attributions
250+
## Attributions
249251

250252
The [interface icons](resources/icons-interface), except for the openHAB logo, are licensed under CC BY 3.0 by [Adrien Coquet](https://adrien-coquet.com/) from [Noun Project](https://thenounproject.com/creator/coquet_adrien/).

source/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ All `.mc` files include inline comments and documentation describing the purpose
3636

3737
# Folder Structure
3838

39-
## Folder `config`
39+
## Subfolder `config`
4040

4141
This folder defines device-specific configuration using code-based _Constants_, which replace Garmin SDK _Properties_ due to their limitations. Unlike _Properties_, _Constants_ are embedded in the code, update automatically with new app versions, and benefit from compiler validation.
4242

4343
For more details, continue reading the folder’s [README](config/README.md).
4444

4545
<br>
4646

47-
## Folder `main`
47+
## Subfolder `main`
4848

4949
Contains the core application source code that is shared across all target devices. This includes the data layer, infrastructure and service components, as well as the user interface logic and views.
5050

@@ -54,7 +54,7 @@ For additional details, refer to the folder’s [README](main/README.md).
5454

5555
<br>
5656

57-
## Folder `themes`
57+
## Subfolder `themes`
5858

5959
Themes define the color schemes used in the app and can change dynamically at runtime. This also includes icons whose colors must be adapted to the active theme. Themes are used to implement the light and dark mode on Edge devices.
6060

source/config/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This folder defines device-specific configuration via code-based constants, replacing Garmin SDK _Properties_, which have significant limitations.
44

5+
---
6+
57
## Why Constants?
68

79
The Garmin SDK’s _Properties_ are stored externally from the app and persist across installations. This means that when a new version of the app is installed, any existing properties from the previous version remain, unless the user performs a full uninstall and reinstall. To avoid this issue and allow reliable updates, the app uses _Constants_ instead:
@@ -10,19 +12,23 @@ The Garmin SDK’s _Properties_ are stored externally from the app and persist a
1012
- The compiler validates constant usage, reducing runtime errors.
1113
- Constants can be cleanly overridden for specific devices.
1214

13-
### Structure and Usage
15+
---
16+
17+
## Structure and Usage
1418

1519
All devices inherit default values from `BaseConfig` and `GlanceBaseConfig`, which define all configuration values used in the _Widget_ and _Glance_, respectively.
1620

1721
In the source code, these are accessed via the `Config` and `GlanceConfig` classes. Each supported device may override the defaults by providing its own implementation of these classes.
1822

1923
Additional base classes can be introduced for specific device families. For example, `EdgeBaseConfig` inherits from `BaseConfig` and overrides values that apply to all Edge devices. Concrete `Config` implementations for individual Edge models can then further override selected values defined in the Edge base configuration.
2024

21-
### Key Files and Directories
25+
---
26+
27+
## Key Files and Directories
2228

23-
- `base`:
29+
- `base/`:
2430
Contains `BaseConfig` and `GlanceBaseConfig`, which define the baseline values for all devices.
25-
- `device-default`:
31+
- `device-default/`:
2632
Contains default `Config` and `GlanceConfig` implementations. These inherit all values from the base without overrides.
27-
- `device-<device-name>`:
33+
- `device-<device-name>/`:
2834
Contains device-specific implementations of `Config` and `GlanceConfig`, overriding select values to adapt the UI for the particular device.

source/main/README.md

Lines changed: 20 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,43 @@
11
# Folder `main`
22

3-
This folder contains the source code of the app, written in **Monkey C**, Garmin’s programming language. It uses the Connect IQ SDK for user interface components, application settings, persistent storage, and HTTP communication with the openHAB server.
3+
Contains the primary application source code shared across all target devices.
4+
This folder includes the core implementation of the app, covering the data layer, infrastructure services, and the user interface.
45

5-
---
6-
7-
## Key Concepts
8-
9-
### **Annotations**
10-
11-
- `(:glance)` marks code that must be included in the _Glance_ view.
12-
- Exclude annotations are used to tailor the code for each target device. See the [`monkey.jungle`](../README.md#root-folder-) file in the root directory for details.
13-
14-
### **Inline Documentation**
15-
16-
All `.mc` files include inline comments and documentation describing the purpose and internal workings of each class.
17-
18-
### **Further Reading**
19-
20-
- [Connect IQ Core Topics](https://developer.garmin.com/connect-iq/core-topics/)
21-
- [Connect IQ API Docs](https://developer.garmin.com/connect-iq/api-docs/)
22-
23-
---
24-
25-
## Folder Structure
26-
27-
### Root Folder `/`
28-
29-
Contains the `OHApp` class, the main entry point for the app. It handles:
30-
31-
- Initialization of the initial view in both _Glance_ and _Widget_ modes
32-
- Startup and shutdown logic
33-
- Reactions to app updates and settings changes
34-
35-
---
36-
37-
### Folder `exceptions`
38-
39-
Defines all custom exception types used by the app. All exception classes extend the base class `GeneralException`.
6+
While most code in this directory is shared, certain parts are conditionally included or excluded per device using build annotations. Device-specific [constants](../config/README.md) and [themes](../themes/README.md) are maintained separately.
407

418
---
429

43-
### Folder `logging`
10+
## Subfolder Structure
4411

45-
Contains the `Logger` class, which provides utility methods to output debug statements and exceptions to the system log.
12+
### `data/`
4613

47-
---
48-
49-
### Folder `settings`
14+
Implements the data layer of the application.
5015

51-
Includes the `AppSettings` class, which reads, validates, and exposes application settings through static accessor methods.
16+
This includes:
5217

53-
**Related Resources:**
18+
- The internal sitemap representation
19+
- Synchronization with the server (receiving updates and sending commands)
20+
- Communication handling
21+
- Persistence of sitemap data in storage
5422

55-
- [Connect IQ SDK Core Topics – Resources](https://developer.garmin.com/connect-iq/core-topics/resources/)
56-
- [Connect IQ API Docs – `Toybox.Application.Properties`](https://developer.garmin.com/connect-iq/api-docs/Toybox/Application/Properties.html)
57-
- See also: [Folder `resources`](https://github.com/TheNinth7/ohg#folder-resources)
23+
For more details, see the folder’s [README](data/README.md).
5824

5925
---
6026

61-
### Folder `sitemap`
62-
63-
This folder defines the data model for parsing and representing sitemap content from openHAB. It forms the foundation for building the user interface menus. The following subdirectories and files are included:
64-
65-
- `base/SitemapElement`: The abstract base class for all sitemap elements.
66-
- `factory/SitemapElementFactory`: Responsible for instantiating the appropriate `SitemapElement` subclass from a JSON representation of a sitemap element.
67-
- `item-descriptions`: Contains classes that model the state and command descriptions of openHAB items.
68-
- `sitemap-pages`: Contains `SitemapElement` subclasses that act as containers, grouping other sitemap elements (e.g., frames, groups).
69-
- `sitemap-primitives`: Contains `SitemapElement` subclasses representing basic UI components such as switches, sliders, and text labels.
70-
71-
---
72-
73-
### Folder `storage`
74-
75-
Handles reading from and writing to persistent storage. As of now, the following data is stored:
76-
77-
- **JSON Dictionary**: Caches the latest sitemap data for use on app startup.
78-
- **Sitemap Label**: Stored for display by the _Glance_, in case the sitemap cannot be loaded due to memory constraints.
79-
- **Sitemap Error Count**: Tracks non-fatal communication errors across _Glance_ and _Widget_ modes. If errors persist, they are escalated to fatal errors. This count is preserved across sessions and shared between both app modes.
27+
### `infrastructure/`
8028

81-
**Related Resources:**
29+
Provides the technical foundation of the application.
8230

83-
- [Connect IQ Core Topics – Persisting Data](https://developer.garmin.com/connect-iq/core-topics/persisting-data/)
84-
- [Connect IQ API Docs – `Toybox.Application.Storage`](https://developer.garmin.com/connect-iq/api-docs/Toybox/Application/Storage.html)
31+
It contains the main `OHApp` class responsible for managing the application lifecycle, along with cross-cutting services such as logging, memory management, task coordination, and other shared technical utilities.
8532

86-
---
87-
88-
### Folder `user-interface`
89-
90-
Contains all user interface implementations. For detailed documentation, see the folder’s [README](https://github.com/TheNinth7/ohg/tree/main/source/user-interface#folder-user-interface).
33+
For more details, see the folder’s [README](infrastructure/README.md).
9134

9235
---
9336

94-
### Folder `web-requests`
95-
96-
Implements communication with the openHAB server using the Connect IQ SDK's `Communication` module.
97-
98-
#### Subfolders:
99-
100-
- **`base/`**
101-
Contains `BaseRequest`, the base class for all HTTP requests. It includes shared logic such as applying basic authentication and checking HTTP response codes.
102-
103-
- **`command/`**
104-
Implements requests for sending commands to openHAB. Supports both:
105-
106-
- The JSON-based REST API (available in openHAB 5 and as a backport for openHAB 4.3.x)
107-
- A custom webhook integration
108-
_(See the user manual for configuration details.)_
109-
110-
- **`sitemap/`**
111-
Handles sitemap retrieval, polling, and processing logic:
37+
### `user-interface/`
11238

113-
- `SitemapRequest`: Periodically fetches sitemap data from openHAB and triggers its processing.
114-
- `SitemapProcessor` and `SitemapProcessorTasks`: Process the retrieved sitemap data and act as the interface between `SitemapRequest` and the menu update logic in `/user-interface/sitemap-menu`.
39+
Contains all presentation-layer code.
11540

116-
**Further reading:**
41+
This folder defines how the application is rendered and how users interact with it. It includes feature screens, reusable UI components, global fallback states (e.g., error and loading views), and UI-specific infrastructure such as view management and theming.
11742

118-
- [Connect IQ Core Topics - JSON REST Requests](https://developer.garmin.com/connect-iq/core-topics/https/)
119-
- [Connect IQ API Docs - `Toybox.Communications`](https://developer.garmin.com/connect-iq/api-docs/Toybox/Communications.html)
43+
For more details, see the folder’s [README](user-interface/README.md).

source/main/data/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Folder `data`
2+
3+
Implements the data layer of the application.
4+
5+
---
6+
7+
## Subfolder Structure
8+
9+
### Folder `communications/`
10+
11+
Responsibel for keeping the data layer in sync with the openHAB server.
12+
13+
For more details, see the folder’s [README](communications/README.md).
14+
15+
---
16+
17+
### Folder `sitemap/`
18+
19+
This folder defines the data model for parsing and representing sitemap content from openHAB. The classes defined in sitemap feed the data to be displayed to the user interface.
20+
21+
For more details, see the folder’s [README](sitemap/README.md).
22+
23+
---
24+
25+
### Folder `storage/`
26+
27+
Handles reading from and writing to persistent storage.
28+
29+
For more details, see the folder’s [README](storage/README.md).

0 commit comments

Comments
 (0)