|
1 | 1 | # Folder `main` |
2 | 2 |
|
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. |
4 | 5 |
|
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. |
40 | 7 |
|
41 | 8 | --- |
42 | 9 |
|
43 | | -### Folder `logging` |
| 10 | +## Subfolder Structure |
44 | 11 |
|
45 | | -Contains the `Logger` class, which provides utility methods to output debug statements and exceptions to the system log. |
| 12 | +### `data/` |
46 | 13 |
|
47 | | ---- |
48 | | - |
49 | | -### Folder `settings` |
| 14 | +Implements the data layer of the application. |
50 | 15 |
|
51 | | -Includes the `AppSettings` class, which reads, validates, and exposes application settings through static accessor methods. |
| 16 | +This includes: |
52 | 17 |
|
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 |
54 | 22 |
|
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). |
58 | 24 |
|
59 | 25 | --- |
60 | 26 |
|
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/` |
80 | 28 |
|
81 | | -**Related Resources:** |
| 29 | +Provides the technical foundation of the application. |
82 | 30 |
|
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. |
85 | 32 |
|
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). |
91 | 34 |
|
92 | 35 | --- |
93 | 36 |
|
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/` |
112 | 38 |
|
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. |
115 | 40 |
|
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. |
117 | 42 |
|
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). |
0 commit comments