├── glyph-matrix-sdk-1.0.aar
├── .gitignore
├── LICENSE.md
├── README.md
└── image
└── Phone 3 Glyph Matrix LED allocation.svg
/glyph-matrix-sdk-1.0.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nothing-Developer-Programme/GlyphMatrix-Developer-Kit/HEAD/glyph-matrix-sdk-1.0.aar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # macOS system files
2 | .DS_Store
3 | .DS_Store?
4 | ._*
5 | .Spotlight-V100
6 | .Trashes
7 | ehthumbs.db
8 | Thumbs.db
9 |
10 | # IDE files
11 | .idea/
12 | .vscode/
13 | *.iml
14 |
15 | # Build files
16 | *.class
17 | *.log
18 | build/
19 | out/
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | **PLEASE READ THESE LICENCE TERMS CAREFULLY BEFORE USING YOUR NOTHING SOFTWARE OR DOWNLOADING THE SOFTWARE UPDATE ACCOMPANYING THIS LICENCE.**
2 |
3 | # Glyph SDK End User License Agreement
4 |
5 | ## 1. License Grant
6 |
7 | Nothing Technology Limited (along with our affiliates, "Nothing", "us" or "we", as the case may be) grants you ("User") a limited, non-exclusive, non-transferable license to use the Glyph Matrix SDK ("Software") as provided, solely for the purpose of integrating and using the Software's functionality within your applications.
8 |
9 | ## 2. User Rights and Restrictions
10 |
11 | ### 2.1 You undertake that you will:
12 |
13 | (a) not remove, alter, or obscure any proprietary notices (including copyright, trademark, and license notices) contained in or affixed to the Software;
14 |
15 | (b) only use the Software to develop your own applications that interface with the Software's public APIs, and not modify, reverse engineer, decompile, disassemble, decrypt, or create derivative works of the Software, except to the extent such restrictions are prohibited by applicable law or by licensing terms of open source components included in the Software;
16 |
17 | (c) not lend, lease, rent, sublicense, sell, redistribute, or otherwise transfer the Software except as expressly authorized by this Agreement;
18 |
19 | (d) not transfer this Agreement or your rights under it to any third party, except for a one-time permanent transfer in connection with the sale of the device on which the Software is pre-installed, provided that the transferee agrees to be bound by the terms of this Agreement, and you retain no copies of the Software after the transfer;
20 |
21 | (e) acknowledge that the Software is licensed as a closed-source product and that no rights to access or modify its source code are granted.
22 |
23 | ### 2.2 Commercial use of the Software is strictly prohibited unless you obtain prior written permission from Nothing.
24 |
25 | ### 2.3 Nothing may at its discretion make available to you software updates, feature enhancements or system restore software, bug fixes, service upgrades or deletion to or new versions of the Nothing Software after the date you obtain your initial copy of the Nothing Software ("Updates"). The terms of this Licence Agreement will govern any Updates, unless such Update is accompanied by a separate or replacement licence, in which case you agree that the terms of that licence will govern.
26 |
27 | ## 3. Third-Party Software
28 |
29 | The Software contains or relies on third-party components licensed under the following terms:
30 | - Android Open Source Project (Apache License 2.0)
31 | - Java Open JDK (GNU General Public License version 2, with the Classpath Exception)
32 |
33 | You agree to comply with these third-party licenses as applicable.
34 |
35 | ## 4. Intellectual Property Rights
36 |
37 | All intellectual property rights in the Software and any copies thereof remain with Nothing. No rights are granted except as expressly set forth in this Agreement. Nothing reserves all rights not expressly granted to you in this Licence Agreement. The Software is protected by copyright and other intellectual property laws and treaties. Nothing or its suppliers own the title, copyright and other intellectual property rights in the Software. We license use of the Nothing Software to you on the basis of this Licence Agreement. We do not sell the Nothing Software to you. Nothing retains ownership of the Nothing Software at all times.
38 |
39 | ## 5. Disclaimer of Warranty
40 |
41 | TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS IS" AND ON AN "AS AVAILABLE" BASIS, WITH ALL FAULTS AND WITHOUT WARRANTIES OF ANY KIND, AND NOTHING AND NOTHING'S LICENSORS (COLLECTIVELY REFERRED TO AS "NOTHING" FOR THE PURPOSES OF SECTION 5) HEREBY DISCLAIM ALL WARRANTIES, DUTIES AND CONDITIONS WITH RESPECT TO THE SOFTWARE, EITHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, WARRANTIES: (i) OF MERCHANTABILITY; (ii) OF SATISFACTORY QUALITY; (iii) OF FITNESS FOR A PARTICULAR PURPOSE; (iv) OF RELIABILITY; (v) OF AVAILABILITY; (vi) ACCURACY; (vii) OF QUIET ENJOYMENT; AND (viii) OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
42 |
43 | YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT, TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, USE OF THE SOFTWARE AND ANY SERVICES PERFORMED BY OR ACCESSED THROUGH THE SOFTWARE IS AT YOUR SOLE RISK AND THAT THE ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY AND EFFORT IS WITH YOU. INSTALLATION OF THE NOTHING SOFTWARE MAY AFFECT THE AVAILABILITY AND USABILITY OF THIRD-PARTY SOFTWARE, APPLICATIONS OR THIRD-PARTY SERVICES, AS WELL AS NOTHING PRODUCTS AND SERVICES.
44 |
45 | ## 6. Limitation of Liability
46 |
47 | TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, IN NO EVENT SHALL NOTHING, ITS AFFILIATES, PRINCIPALS OR AGENTS OR LICENSORS BE LIABLE FOR PERSONAL INJURY, OR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, LOSS OR CORRUPTION OF DATA, FAILURE TO TRANSMIT OR RECEIVE ANY DATA, BUSINESS INTERRUPTION OR ANY OTHER COMMERCIAL LOSSES OR DAMAGES, ARISING OUT OF OR RELATED TO YOUR USE OR INABILITY TO USE THE SOFTWARE AND SERVICES OR ANY THIRD PARTY SOFTWARE, APPLICATIONS OR SERVICES IN CONJUNCTION WITH THE SOFTWARE OR SERVICES, HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILITY (CONTRACT, TORT OR OTHERWISE) AND EVEN IF NOTHING HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
48 |
49 | ## 7. Termination
50 |
51 | This Agreement is effective until terminated. Nothing may terminate this Agreement immediately if you fail to comply with any terms. Upon termination, you must cease all use of the Software and delete all copies.
52 |
53 | ## 8. Governing Law
54 |
55 | This Agreement shall be governed by and construed in accordance with the laws of England and Wales.
56 |
57 | ## 9. Commercial Licensing
58 |
59 | For commercial use or licensing inquiries, please contact: [GDKsupport@nothing.tech](mailto:GDKsupport@nothing.tech)
60 |
61 | ---
62 |
63 | **By installing, accessing or using the Software, you acknowledge that you have read, understood, and agree to be bound by this License Agreement.**
64 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Glyph Matrix Developer Kit
2 |
3 |
4 | The Glyph Matrix Developer Kit provides everything you need to know before creating a custom Glyph Matrix experience **in your app** or **building your own Glyph Toy** on compatible devices.
5 |
6 | At its core is the Glyph Matrix Android library that can convert your designs into Glyph Matrix Data and rendering it frame by frame on the Glyph Matrix. It also provides you with identifiers so you can handle events relevant to Glyph Button.
7 |
8 |
9 | This documentation contains the following three sections
10 |
11 | - [**Getting Started**](#getting-started): How to integrate the Glyph Matrix Android Library, configure your development environment and create preview images for your Glyph Toys.
12 | - [**Developing a Glyph Toy Service**](#developing-a-glyph-toy-service): How to manage the service life cycle for Glyph Toy, handle interaction, and behavior of toy service if it has AOD capability.
13 | - [**API Reference**](#api-reference): Complete documentation of classes, methods.
14 |
15 | Note that while the sample code in this README is written in Java, we also provide a complete demo project for learning building Glyph Toys that you can reference in [GlyphMatrix-Example-Project](https://github.com/KenFeng04/GlyphMatrix-Example-Project)
16 |
17 | ## Getting Started
18 |
19 |
20 | ### 1. Glyph Matrix Library Integration
21 |
22 | 1. After creating a new Android project, create a libs folder under your main app module.
23 | 2. Copy the Android library e.g. GlyphMatrixSDK.aar file from this repository into the libs directory.
24 | 3. Add the library as a library dependency in your build.gradle file. If you're using Android Studio, you can also refer to the "Add your AAR or JAR as a dependency" section on [developer.android.com](https://developer.android.com/studio/projects/android-library#psd-add-aar-jar-dependency) to learn
25 | how to do it, make sure the path you use is something like "libs/GlyphMatrixSDK.aar"
26 |
27 | ### 2. AndroidManifest.xml Configuration
28 |
29 | You can find the AndroidManifest.xml file at the following path `/app/src/main/AndroidManifest.xml`
30 |
31 | #### 2.1. Required Permission
32 |
33 | Add the following line within the `` tag in AndroidManifest.xml
34 |
35 | ```xml
36 |
37 | ```
38 |
39 | #### 2.2 Service Registration For Glyph Toys
40 |
41 | > **Note**: This section is only required if you're developing Glyph Toys. If you're only integrating the Glyph Matrix Library into your existing application, you can skip this section.
42 |
43 | To ensure your Nothing Phone setting recognises and can display your Glyph Toys, you'll need to register each toy as a service within the `` tag of your `AndroidManifest.xml ` file.
44 | The following code demonstrates how to register two toys. Each service includes metadata for the toy's name, preview image, and supported behaviour(optional).
45 |
46 | To prepare a preview image, please refer to [Section 3: Create your Glyph Toy preview](#3-create-your-glyph-toy-preview).
47 |
48 |
49 |
50 |
51 | The first example provides a complete setup with optional features, while the second shows a minimal configuration.
52 |
53 | **Note**: Replace the class names, and resource references in the examples below with your own before using.
54 |
55 | ```xml
56 |
57 |
58 |
60 |
61 |
62 |
63 |
64 |
65 |
68 |
69 |
70 |
73 |
74 |
75 |
78 |
79 |
80 |
83 |
84 |
85 |
88 |
89 |
90 |
93 |
94 |
95 |
96 |
98 |
99 |
100 |
101 |
102 |
103 |
106 |
107 |
108 |
111 |
112 | ```
113 |
114 | #### 3 Create your Glyph Toy preview
115 |
116 | To create a Glyph Toy preview image that matches the official toy and provides your users with a consistent experience, you can reference the specifications below and the [Figma template](https://www.figma.com/design/ryjvvPM2ZxI3OGdajSzb5J/Glyph-Toy--preview-icon-template?node-id=1-12&t=HvVOxxNmb5EK2i2g-1). We have also created a [Figma plugin](https://www.figma.com/community/plugin/1526505846480298025) that can automatically convert any 1:1 design image into a Glyph Matrix Preview image to save you some time :)
117 |
118 | We recommend exporting your preview image as an SVG and to learn how to import your SVG preview into your project, check [Running Vector Asset Studio](https://developer.android.com/studio/write/vector-asset-studio#svg) section in the Android studio documentation.
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | ## Developing a Glyph Toy Service
130 |
131 | ### User Interaction with Glyph Button
132 |
133 | `Glyph Toys` are commonly controlled using `Glyph Button` on the back of the device. There are mainly three types of interaction with `Glyph Button`:
134 |
135 | - **Short press**: A quick press on `Glyph Button` cycles through available toys. When your toy is selected and shown on the `Glyph Matrix`, its functions start. Tapping again navigates to the next toy.
136 | - **Long press**: A long press on `Glyph Button` sends a `"change"` event to the currently selected toy, triggering an action you defined. For example, in the preinstalled camera toy, the first long press activates the camera and subsequent presses capture photos. For the timer toy, it toggles start/stop. (This feature must be enabled in `AndroidManifest.xml`).
137 | - **Touch-down & Touch-up**: If the user keeps the `Glyph Button` held down & released, it will trigger `"action_down"` & `"action_up"` events
138 |
139 | Additionally, toys can also utilize other control inputs such as the device's gyroscope and accelerometer, to create more engaging experiences like the `Magic 8 Ball` & `Leveler Toy` we co-created with community members. Please note that only one toy can be activated at a time.
140 |
141 | ### Development Implementation
142 |
143 | #### Responding to Toy Selection (Managing the Lifecycle)
144 |
145 | When a user selects your toy, the system binds your Service. You must implement onBind() to start its functions and onUnbind() to stop them cleanly.
146 |
147 | The following example shows how to manage the start/stop lifecycle.
148 |
149 | ```java
150 | @Override
151 | public IBinder onBind(Intent intent) {
152 | init();// Experience that you want to create when Glyph Toy is selected
153 | return null;
154 | }
155 |
156 | @Override
157 | public boolean onUnbind(Intent intent) {
158 | mGM.unInit();
159 | mGM = null;
160 | mCallback = null;
161 | return false;
162 | }
163 | ```
164 |
165 | #### Handling the "Change" Event
166 |
167 | Glyph Button relevant event is handled using GlyphToy class. To react with user's interaction to the Glyph Button, you must create a `Handler` to process the event and a `Messenger` to communicate with the system. The `IBinder` from this `Messenger` must be returned by your `onBind()` method.
168 |
169 | The code below shows how to receive and handle the event, in this case the long press (change) event.
170 |
171 | ```java
172 | @Override
173 | public IBinder onBind(Intent intent) {
174 | init();
175 | return serviceMessenger.getBinder();
176 | }
177 |
178 | private final Handler serviceHandler = new Handler(Looper.getMainLooper()) {
179 | @Override
180 | public void handleMessage(Message msg) {
181 | switch (msg.what) {
182 | case GlyphToy.MSG_GLYPH_TOY: {
183 | Bundle bundle = msg.getData();
184 | String event = bundle.getString(GlyphToy.MSG_GLYPH_TOY_DATA);
185 | if (GlyphToy.EVENT_CHANGE.equals(event)) {
186 | // Your reaction for the long press.
187 | }
188 | break;
189 | }
190 | default:
191 | super.handleMessage(msg);
192 | }
193 | }
194 | };
195 | private final Messenger serviceMessenger = new Messenger(serviceHandler);
196 | ```
197 |
198 | ### Toy with AOD capability
199 | If you have set your toy as an AOD toy, your toy will receive EVENT_AOD every minute when your toy has been selected as aod toy.
200 |
201 |
202 |
203 | ```java
204 | private final Handler serviceHandler = new Handler(Looper.getMainLooper()) {
205 | @Override
206 | public void handleMessage(Message msg) {
207 | switch (msg.what) {
208 | case GlyphToy.MSG_GLYPH_TOY: {
209 | Bundle bundle = msg.getData();
210 | String event = bundle.getString(GlyphToy.MSG_GLYPH_TOY_DATA);
211 | if (GlyphToy.EVENT_AOD.equals(event)) {
212 | // Your action for aod
213 | }
214 | break;
215 | }
216 | default:
217 | super.handleMessage(msg);
218 | }
219 | }
220 | };
221 | ```
222 |
223 | ### Best Practice: Guiding Users to Glyph Toys Manager
224 |
225 | We highly recommend using the intent action provided below when your Glyph Toy application is ready for distribution. It is valid for system version on 20250829 or later.
226 |
227 | This intent directs users to the system's Manage Glyph Toys screen, allowing them to add your toy to their active toy queue. Without this guidance, users can become confused about how to activate the toy after installing your application.
228 | ```java
229 | Intent intent = new Intent();
230 | intent.setComponent(new ComponentName("com.nothing.thirdparty", "com.nothing.thirdparty.matrix.toys.manager.ToysManagerActivity"));
231 | startActivity(intent);
232 | ```
233 |
234 | Here are two common implementation scenarios:
235 |
236 | 1. For simple toys: Your application interface can feature a basic introduction to the toy with a button, such as "Activate toy," which triggers the intent.
237 |
238 | 2. For toys requiring setup: It is best to present the button that triggers this intent at the end of the configuration process. This guides the user to activate the toy immediately after they have finished setting it up. For instance, a toy designed to show a YouTube channel's subscriber count would first require the user to select the channel as part of the setup before it can work properly.
239 |
240 | ## API Reference
241 |
242 | ### GlyphMatrixManager
243 |
244 | GlyphMatrixManager is responsible for:
245 |
246 | - **Connecting to and disconnecting from** an underlying service or device.
247 | - **Registering your application** to use that service/device.
248 | - **Updating the display** of a Glyph Matrix with either raw color data or structured frame objects.
249 |
250 | In addition to displaying content on the Glyph Matrix through the Glyph Toy service, you can directly control Glyph Matrix from your own app using GDK. For app-based control, always use the `setAppMatrixFrame` function instead of `setMatrixFrame`, as the latter may conflict with active Glyph Toys. This feature requires the phone system version on 20250801 or later.
251 |
252 | Note: The Glyph Toy has a higher display priority than third party app usage on Glyph Matrix. If the user interacts with the Glyph Button, the Glyph Toy carousel it triggers will override your app’s content on the Matrix.
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 | #### Public Methods
261 |
262 | | Return type | Method | Description |
263 | |:-------------------------------|:-------------------------------|:-------------------------------|
264 | | void | `init(Callback callback)` | Used for binding the Service. It is recommended to be created when components start. |
265 | | void | `unInit()` | Used for unbinding the Service. It is recommended to be destroyed when components end. |
266 | | void | `closeAppMatrix()` | Closes the app matrix display. Use this function to stop displaying content on the Glyph Matrix from your app. Required phone system version on 20250801 or later. |
267 | | void | `register(String target)` | Register your app for service. You need to send which target device you are working on. For Phone 3, this should be Glyph.DEVICE_23112|
268 | | void | `setMatrixFrame(int[] color)` | Updates the Glyph Matrix display using raw color data. This overload expects a 25x25 integer array. |
269 | | void | `setMatrixFrame(GlyphMatrixFrame)` | Updates the Glyph Matrix display using a structured GlyphMatrixFrame object. |
270 | | void | `setAppMatrixFrame(int[] color)` | Same as setMatrixFrame(int[] color). If you want to use Glyph Matrix in your app. Please use this function to update Glyph Matrix display. Required phone system version on 20250801 or later. |
271 | | void | `setAppMatrixFrame(GlyphMatrixFrame frame)` | Same as setMatrixFrame(GlyphMatrixFrame frame). If you want to use Glyph Matrix in your app. Please use this function to update Glyph Matrix display. phone system version on 20250801 or later. |
272 |
273 |
274 | ### GlyphMatrixFrame
275 |
276 | GlyphMatrixFrame is in charge of handling and displaying the Glyph Matrix. Its default size is 25x25, but you can easily customise it using the Builder.
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 | Developers can use this class to render GlyphMatrix objects into the necessary Matrix data and control how multiple objects can be overlaid on the Glyph Matrix based on the layer they are in using the builder.
285 |
286 | #### Public Methods
287 |
288 | | Return type | Method name | Description |
289 | |:-------------------------------|:-------------------------------|:-------------------------------|
290 | | int[] | `render()` | Renders all objects previously added via the **Builder** and integrates them into the corresponding **Glyph Matrix data**. The implementation of this method may vary depending on project requirements. This method can either directly drive hardware to display on an actual Glyph Matrix, or return an array or bitmap data to the caller for further processing. |
291 |
292 | ### GlyphMatrixFrame.Builder
293 |
294 | GlyphMatrixFrame.Builder is a static inner class that uses the Builder pattern to help you construct and configure a GlyphMatrixFrame. This frame is essentially an array of data that defines how each LED on the matrix should light up, and it can be read by the GlyphMatrixManager.
295 |
296 | You can have maximum 3 GlyphMatrixObject for each GlyphMatrixFrame,1 for each layer before you finally call `build()` to generate your finished GlyphMatrixFrame instance.
297 |
298 | #### Public Constructors
299 |
300 | | Return type | Method name | Description |
301 | |:-------------------------------|:-------------------------------|:-------------------------------|
302 | | N/A | `Builder()` | Initializes a new `Builder` instance. This creates an empty `GlyphMatrixFrame.Builder` ready for configuration. By default, the Matrix size is set to 25x25. |
303 |
304 | #### Public Methods
305 |
306 | | Return type | Method | Description |
307 | |:-------------------------------|:-------------------------------|:-------------------------------|
308 | | void | `addTop(GlyphMatrixObject object)` | Adds object to top layer, rendered above middle and low layers |
309 | | void | `addMid(GlyphMatrixObject object)` | Adds object to middle layer, rendered between top and low layers |
310 | | void | `addLow(GlyphMatrixObject object)` | Adds object to bottom layer, rendered below top and middle layers |
311 | | GlyphMatrixFrame | `build(Context context)` | Constructs and returns a new GlyphMatrixFrame instance based on the currently accumulated settings. This instance is ready for display or further manipulation. |
312 | #### Example
313 | The following example shows how to create a GlyphMatrixFrame with a butterfly object on the top layer, and then render it to the actual Glyph Matrix using mGM (GlyphMatrixManager), the class mentioned above that manages the actual matrix.
314 | ```java
315 | GlyphMatrixFrame.Builder frameBuilder = new GlyphMatrixFrame.Builder();
316 | GlyphMatrixFrame frame = frameBuilder.addTop(butterfly).build();
317 | mGM.setMatrixFrame(frame.render());
318 | ```
319 |
320 | ### GlyphMatrixObject
321 |
322 | The GlyphMatrixObject encapsulates a single image or frame for display on the Glyph Matrix, along with its configurable properties.
323 |
324 | These properties, such as image source, position coordinates (X, Y), clockwise rotation angle, scaling, brightness, and transparency, can all be adjusted using the `GlyphMatrixObject.Builder`.
325 |
326 | #### Public Accessor Methods
327 |
328 | | Return type | Method name | Description |
329 | |:-------------------------------|:-------------------------------|:-------------------------------|
330 | | Object | `getImageSource()` | Returns the image source object|
331 | | Int | `getPositionX()` | Returns the X-coordinate of the object's top-left corner. |
332 | | Int | `getPositionY()` | Returns the Y-coordinate of the object's top-left corner. |
333 | | Int | `getOrientation()` | Returns the counterclockwise rotation angle of the object from the original (default: 0) |
334 | | Int | `getScale()` | Returns the **scaling factor** of the object. (0-200, default: 100) |
335 | | Int | `getBrightness()` | Returns the brightness **level** of the object. (0-255, default: 255) |
336 |
337 | ### GlyphMatrixObject.Builder
338 |
339 | GlyphMatrixObject.Builder is a static inner class of GlyphMatrixObject, used to create and configure an image object's display parameters.
340 |
341 | #### Public Constructors
342 |
343 | | Return type | Method name | Description |
344 | |:-------------------------------|:-------------------------------|:-------------------------------|
345 | | N/A | `Builder()` | If not explicitly set by other methods, the `Builder` will use the following default values for the `GlyphMatrixObject`: - Position: (0, 0) - Orientation: 0 degrees - Scale: 100 - Brightness: 255 |
346 |
347 | #### Public Methods
348 |
349 | | Return type | Method name | Description |
350 | |:-------------------------------|:-------------------------------|:-------------------------------|
351 | | void | `setImageSource(Object imagesource)` | Sets the image source. Must be a 1:1 bitmap - other formats require conversion. Higher resolutions may impact performance. |
352 | | void | `setText(String text)` | Sets the string content to be displayed in the Glyph Matrix. |
353 | | void | `setPosition(int x, int y)` | Sets the object's top-left corner position on the Glyph Matrix |
354 | | void | `setOrientation(int)` | Sets the object's clockwise rotation angle in degrees, anchored at center. 0 = no rotation (default). Values normalized to 0-360° range |
355 | | void | `setBrightness(int brightness)` | Sets the brightness level for the object.
Acceptable values range from 0 (LED off) to 255 (maximum brightness, default). Any value above 255 will be automatically capped at 255. |
356 | | void | `setScale(int scale)` | Sets the scaling factor for the object. The anchor point is in the middle of the object
Valid range: 0-200 0: Object is not visible 100: Original size (default) 200: Double size |
357 | | GlyphMatrixObject | `build()` | Constructs and returns a GlyphMatrix Object instance based on the current settings. |
358 |
359 | ### Example
360 | The following example shows how to construct a GlyphMatrixObject called butterfly.
361 |
362 | ```java
363 | GlyphMatrixObject.Builder butterflyBuilder = new GlyphMatrixObject.Builder();
364 | GlyphMatrixObject butterfly = butterflyBuilder
365 | .setImageSource(GlyphMatrixUtils.drawableToBitmap(getResources().getDrawable(R.drawable.butterfly)))
366 | .setScale(100)
367 | .setOrientation(0)
368 | .setPosition(0, 0)
369 | .setReverse(false)
370 | .build();
371 | ```
372 |
373 | ## See Also
374 | ### Full Example of Glyph Toy Service
375 |
376 | The following code block shows a full implementation of a Glyph Toy Service in Java. It demonstrate how to initialize the GlyphMatrixManager, register a device, and display a custom GlyphMatrixObject (for example, a butterfly image) on the Glyph Matrix.
377 | ```java
378 | @Override
379 | public IBinder onBind(Intent intent) {
380 | init();
381 | return null;
382 | }
383 |
384 | @Override
385 | public boolean onUnbind(Intent intent) {
386 | mGM.turnOff();
387 | mGM.unInit();
388 | mGM = null;
389 | mCallback = null;
390 | return false;
391 | }
392 |
393 | private void init() {
394 | mGM = GlyphMatrixManager.getInstance(getApplicationContext());
395 | mCallback = new GlyphMatrixManager.Callback() {
396 | @Override
397 | public void onServiceConnected(ComponentName componentName) {
398 | mGM.register(Glyph.DEVICE_23112);
399 | action();
400 | }
401 | @Override
402 | public void onServiceDisconnected(ComponentName componentName) {
403 | }
404 | };
405 | mGM.init(mCallback);
406 | }
407 |
408 | private void action() {
409 | GlyphMatrixObject.Builder butterflyBuilder = new GlyphMatrixObject.Builder();
410 | GlyphMatrixObject butterfly = butterflyBuilder
411 | .setImageSource(GlyphMatrixUtils.drawableToBitmap(getResources().getDrawable(R.drawable.butterfly)))
412 | .setScale(100)
413 | .setOrientation(0)
414 | .setPosition(0, 0)
415 | .setReverse(false)
416 | .build();
417 |
418 | GlyphMatrixFrame.Builder frameBuilder = new GlyphMatrixFrame.Builder();
419 | GlyphMatrixFrame frame = frameBuilder.addTop(butterfly).build();
420 | mGM.setMatrixFrame(frame.render());
421 | }
422 | ```
423 |
424 |
425 | ### Other userful resource
426 |
427 | For a practical demo project on building Glyph Toys, see the [GlyphMatrix-Example-Project](https://github.com/KenFeng04/GlyphMatrix-Example-Project)
428 | Kits for building a Glyph Interface experience around devices with a Glyph Light Stripe [Glyph-Developer-Kit](https://github.com/Nothing-Developer-Programme/Glyph-Developer-Kit)
429 |
430 | ## Support
431 |
432 | If you've found an error in this kit, please file an issue.
433 |
434 | If there is any problem related to development,you can contact: [GDKsupport@nothing.tech](mailto:GDKsupport@nothing.tech)
435 |
436 | However, you may get a faster response from our [community](https://nothing.community/t/glyph-sdk)
437 |
438 |
439 |
--------------------------------------------------------------------------------
/image/Phone 3 Glyph Matrix LED allocation.svg:
--------------------------------------------------------------------------------
1 |
666 |
--------------------------------------------------------------------------------