Ejemplo n.º 1
0
        /// <summary>
        /// Stops the LED that is located at the front of the device.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
        /// <exception cref="NotSupportedException">In case the device does not support this behavior.</exception>
        /// <example>
        /// <code>
        ///     try
        ///     {
        ///         Led.Play(500, 200, Color.FromRgba(255, 255, 255, 1));
        ///         //wait for a while and stop...
        ///         Led.Stop();
        ///     }
        ///     Catch(Exception e)
        ///     {
        ///     }
        /// </code>
        /// </example>

        public static void Stop()
        {
            DeviceError res = (DeviceError)Interop.Device.DeviceLedStopCustom();

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "failed to stop Led.");
            }
        }
Ejemplo n.º 2
0
        public static void RequestCpuLock(int timeout)
        {
            DeviceError res = (DeviceError)Interop.Device.DevicePowerRequestLock(Interop.Device.PowerLock.Cpu, timeout);

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "unable to acquire power lock.");
            }
        }
Ejemplo n.º 3
0
        public static void ReleaseCpuLock()
        {
            DeviceError res = (DeviceError)Interop.Device.DevicePowerReleaseLock(Interop.Device.PowerLock.Cpu);

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "unable to release power lock.");
            }
        }
Ejemplo n.º 4
0
        public static void Reboot(string reason)
        {
            DeviceError res = (DeviceError)Interop.Device.DevicePowerReboot(reason);

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "unable to reboot the device.");
            }
        }
Ejemplo n.º 5
0
        public static void PowerOff()
        {
            DeviceError res = (DeviceError)Interop.Device.DevicePowerPowerOff();

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "unable to power off the device.");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Plays the LED that is located at the front of the device.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="on">Turn on time in milliseconds.</param>
        /// <param name="off">Turn off time in milliseconds.</param>
        /// <param name="color">
        /// The Color value
        /// The first byte means opaque and the other 3 bytes are the RGB values.
        /// </param>
        /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
        /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
        /// <exception cref="NotSupportedException">In case the device does not support this behavior.</exception>
        /// <example>
        /// <code>
        ///     try
        ///     {
        ///         Led.Play(500, 200, Color.FromRgba(255, 255, 255, 1));
        ///     }
        ///     Catch(Exception e)
        ///     {
        ///     }
        /// </code>
        /// </example>
        public static void Play(int on, int off, Color color)
        {
            //looks like only blink option is supported. So hard coded to default blink option.
            DeviceError res = (DeviceError)Interop.Device.DeviceLedPlayCustom(on, off, Convert.ToUInt32(color.GetArgb()), 1);

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "failed to play Led.");
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Transmits the IR command.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="carrierFreequency">
        /// The carrier frequency to transmit the IR command (Hertz).
        /// </param>
        /// <param name="pattern">
        /// The IR command list of type integer.
        /// </param>
        /// <exception cref="ArgumentException"> When an invalid parameter value is set.</exception>
        /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
        /// <exception cref="NotSupportedException">In case the device does not support this behavior.</exception>
        /// <example>
        /// <code>
        ///    try
        ///    {
        ///       List&lt;int&gt; pattern = new List&lt;int&gt;();
        ///       pattern.Add(10);
        ///       pattern.Add(50);
        ///       IR.Transmit(60657, pattern);
        ///    }
        ///    catch(Exception e)
        ///    {
        ///    }
        /// </code>
        /// </example>
        public static void Transmit(int carrierFreequency, IList <int> pattern)
        {
            int[]       patternArray = pattern.ToArray();
            DeviceError res          = (DeviceError)Interop.Device.DeviceIRTransmit(carrierFreequency, patternArray, pattern.Count());

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "unable to trasmit IR command.");
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Stops all the vibration effects which are being played.
 /// This function can be used to stop all the effects started by Vibrate().
 /// </summary>
 /// <since_tizen> 3 </since_tizen>
 /// <feature>
 /// http://tizen.org/feature/feedback.vibration
 /// </feature>
 /// <exception cref="ArgumentException"> In case an invalid vibrator instance is used.</exception>
 /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
 /// <exception cref="InvalidOperationException">In case of any system error.</exception>
 /// <exception cref="NotSupportedException">In case the device does not support this behavior.</exception>
 /// <example>
 /// <code>
 ///     Vibrator vibrator = Vibrator.Vibrators[0];
 ///     try
 ///     {
 ///         vibrator.Stop();
 ///     }
 ///     catch(Exception e)
 ///     {
 ///     }
 /// </code>
 /// </example>
 public void Stop()
 {
     if (_hapticHandle != IntPtr.Zero)
     {
         DeviceError res = (DeviceError)Interop.Device.DeviceHapticStop(_hapticHandle, IntPtr.Zero);
         if (res != DeviceError.None)
         {
             throw DeviceExceptionFactory.CreateException(res, "unable to stop the current vibrator.");
         }
     }
 }
Ejemplo n.º 9
0
        private Vibrator(int id)
        {
            _vibratorId = id;
            DeviceError res = (DeviceError)Interop.Device.DeviceHapticOpen(_vibratorId, out _hapticHandle);

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "unable to create Vibrator for given Id");
            }
            res = (DeviceError)Interop.Device.DeviceHapticGetCount(out _maxcount);
            if (res != DeviceError.None)
            {
                Log.Warn(DeviceExceptionFactory.LogTag, "unable to get Vibrators count.");
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Increase the cpu clock within timeout.
        /// </summary>
        /// <param name="type">Performance Control Type</param>
        /// <param name="timeout">Cpu clock increasing duration in milliseconds.</param>
        /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
        /// <exception cref="NotSupportedException">In case the device does not support this behavior.</exception>
        /// <example>
        /// <code>
        ///     try
        ///     {
        ///         PerformanceController.Request(PerformanceControlType.AppLaunchHome, 100);
        ///     }
        ///     Catch(Exception e)
        ///     {
        ///     }
        /// </code>
        /// </example>
        public static void Request(PerformanceControlType type, int timeout)
        {
            PerformanceControlFunc func = null;

            if (!PerformanceControlFunctions.TryGetValue(type, out func))
            {
                throw new ArgumentException("Invalid Arguments");
            }

            DeviceError res = (DeviceError)func(timeout);

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "unable to transmit PmQos command.");
            }
        }
Ejemplo n.º 11
0
        private static IReadOnlyList <Vibrator> GetAllVibrators()
        {
            int             count     = 0;
            List <Vibrator> vibrators = new List <Vibrator>();
            DeviceError     res       = (DeviceError)Interop.Device.DeviceHapticGetCount(out count);

            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "unable to get Vibrators count.");
            }
            for (int i = 0; i < NumberOfVibrators; i++)
            {
                vibrators.Add(new Vibrator(i));
            }
            return(vibrators);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Vibrates during the specified time with a constant intensity.
        /// This function can be used to start monotonous vibration for the specified time.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="duration">The play duration in milliseconds.</param>
        /// <param name="feedback">The amount of the intensity variation (0 ~ 100).</param>
        /// <feature>
        /// http://tizen.org/feature/feedback.vibration
        /// </feature>
        /// <exception cref="ArgumentException"> When an invalid parameter value is set.</exception>
        /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
        /// <exception cref="NotSupportedException">In case the device does not support this behavior.</exception>
        /// <example>
        /// <code>
        ///     Vibrator vibrator = Vibrator.Vibrators[0];
        ///     try
        ///     {
        ///         vibrator.Vibrate(2000, 70);
        ///     }
        ///     catch(Exception e)
        ///     {
        ///     }
        /// </code>
        /// </example>

        public void Vibrate(int duration, int feedback)
        {
            IntPtr      effect;
            DeviceError res = DeviceError.None;

            if (_hapticHandle == IntPtr.Zero)
            {
                res = (DeviceError)Interop.Device.DeviceHapticOpen(_vibratorId, out _hapticHandle);
                if (res != DeviceError.None)
                {
                    throw DeviceExceptionFactory.CreateException(res, "unable to get vibrator.");
                }
            }

            res = (DeviceError)Interop.Device.DeviceHapticVibrate(_hapticHandle, duration, feedback, out effect);
            if (res != DeviceError.None)
            {
                throw DeviceExceptionFactory.CreateException(res, "unable to vibrate the current vibrator.");
            }
        }