2 * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <device/haptic.h>
19 #include "smart_notification.h"
21 static haptic_device_h handle;
22 static haptic_effect_h effect_handle;
24 #define RED "\x1B[31m"
25 #define RESET "\033[0m"
28 * @brief Initializer for haptic module
31 void haptic_module_init(void)
35 if (!device_haptic_get_count(&num)) {
36 DEBUG(RED "Haptic device received!" RESET);
38 ERROR("Cannot receive haptic device count");
42 if (!device_haptic_open(0, &handle)) {
43 DEBUG(RED "Device connected!" RESET);
45 ERROR("Cannot open haptic device");
50 * @brief Disconnect haptic handle
53 void haptic_module_disconnect(void)
56 ERROR("Haptic handle lost");
59 if (!device_haptic_close(handle)) {
60 DEBUG("Haptic disconnected");
62 ERROR("Haptic close error");
67 * @brief Start vibrations
70 void haptic_vibrate_start(void)
73 ERROR("Haptic handle lost");
76 if (!device_haptic_vibrate(handle, 1000, 100, &effect_handle)) {
77 DEBUG(RED "Vibrations started!" RESET);
79 ERROR("Cannot start vibration");
84 * @brief Stop vibrations
87 void haptic_vibrate_stop(void)
90 ERROR("Haptic handle lost");
93 if (!device_haptic_stop(handle, &effect_handle)) {
94 ERROR("Vibrations stopped!");
96 DEBUG(RED "Cannot stop vibration" RESET);