1 #include <device/haptic.h>
3 #include "smart_notification.h"
5 static haptic_device_h handle;
6 static haptic_effect_h effect_handle;
9 #define RESET "\033[0m"
12 * @brief Initializer for haptic module
15 void haptic_module_init(void)
19 if(!device_haptic_get_count(&num))
21 DEBUG(RED"Haptic device received!"RESET);
25 ERROR("Cannot receive haptic device count");
29 if(!device_haptic_open(0, &handle))
31 DEBUG(RED"Device connected!"RESET);
35 ERROR("Cannot open haptic device");
40 * @brief Disconnect haptic handle
43 void haptic_module_disconnect(void)
47 ERROR("Haptic handle lost");
50 if(!device_haptic_close(handle))
52 DEBUG("Haptic disconnected");
56 ERROR("Haptic close error");
61 * @brief Start vibrations
64 void haptic_vibrate_start(void)
68 ERROR("Haptic handle lost");
71 if(!device_haptic_vibrate(handle, 1000, 100, &effect_handle))
73 DEBUG(RED"Vibrations started!"RESET);
77 ERROR("Cannot start vibration");
82 * @brief Stop vibrations
85 void haptic_vibrate_stop(void)
89 ERROR("Haptic handle lost");
92 if(!device_haptic_stop(handle, &effect_handle))
94 ERROR("Vibrations stopped!");
98 DEBUG(RED"Cannot stop vibration"RESET);