1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package com
.nokia
.mid
.ui
;
12 import cc
.squirreljme
.jvm
.mle
.constants
.UIMetricType
;
13 import cc
.squirreljme
.runtime
.cldc
.annotation
.Api
;
14 import cc
.squirreljme
.runtime
.cldc
.debug
.Debugging
;
15 import cc
.squirreljme
.runtime
.lcdui
.mle
.UIBackend
;
16 import cc
.squirreljme
.runtime
.lcdui
.mle
.UIBackendFactory
;
17 import cc
.squirreljme
.runtime
.lcdui
.mle
.Vibration
;
20 * This is used to utilize special hardware that exists on the device for
25 public class DeviceControl
28 * Flashes the LED on the device.
30 * @param __ms The number of milliseconds to flash for.
31 * @throws IllegalArgumentException If the duration is negative.
35 public static void flashLights(long __ms
)
36 throws IllegalArgumentException
38 // {@squirreljme.error EB2z Cannot blink for a negative duration.}
40 throw new IllegalArgumentException("EB2z");
42 throw Debugging
.todo();
45 Assembly.sysCall(SystemCallIndex.DEVICE_FEEDBACK,
46 DeviceFeedbackType.BLINK_LED, ((__ms > (long)Integer.MAX_VALUE) ?
47 Integer.MAX_VALUE : (int)__ms));*/
51 * Sets the level of the backlight.
53 * @param __num The light number, this is always zero for the backlight.
54 * @param __lvl The level to set within the range of {@code [0, 100]}
55 * @throws IllegalArgumentException If the light number is not zero or
56 * the level is out of range.
60 public static void setLights(int __num
, int __lvl
)
61 throws IllegalArgumentException
63 // {@squirreljme.error EB31 Only light number zero is supported.
64 // (The light number)}
66 throw new IllegalArgumentException("EB31 " + __num
);
68 // {@squirreljme.error EB32 Light level out of range. (The level)}
69 if (__lvl
< 0 || __lvl
> 100)
70 throw new IllegalArgumentException("EB32 " + __lvl
);
72 // If controlling the backlight is supported, allow it to be changed
73 UIBackend backend
= UIBackendFactory
.getInstance(true);
74 if (backend
.metric(backend
.displays()[0],
75 UIMetricType
.SUPPORTS_BACKLIGHT_CONTROL
) == 0)
78 throw Debugging
.todo();
80 // Get maximum backlight level, stop if it is zero which means the
81 // property is not supported or there is no backlight that can be
83 throw Debugging.todo();
85 int max = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
86 Framebuffer.CONTROL_BACKLIGHT_LEVEL_MAX);
90 // Set the desired level as a percentage of the max
91 int val = (max * __lvl) / 100;
92 Assembly.sysCall(SystemCallIndex.FRAMEBUFFER,
93 Framebuffer.CONTROL_BACKLIGHT_LEVEL_SET,
94 (val < 0 ? 0 : (val > max ? max : val)));*/
98 * Starts vibrating at the given frequency for the given duration.
100 * @param __freq The frequency of the vibration, must be in the range of
102 * @param __ms The length to vibrate for in milliseconds.
103 * @throws IllegalArgumentException If the duration is negative or the
104 * frequency is out of range.
108 public static void startVibra(int __freq
, long __ms
)
109 throws IllegalArgumentException
111 // {@squirreljme.error EB33 Cannot vibrate for a negative duration.}
113 throw new IllegalArgumentException("EB33");
115 // {@squirreljme.error EB34 Frequency out of range. (The frequency)}
116 if (__freq
< 0 || __freq
> 100)
117 throw new IllegalArgumentException("EB34 " + __freq
);
119 // Perform the vibration
120 Vibration
.vibrate((int)Math
.min(Integer
.MAX_VALUE
, __ms
));
124 * Stops any vibration that is happening.
129 public static void stopVibra()
131 Vibration
.vibrate(0);