pinetime-hypnos icon indicating copy to clipboard operation
pinetime-hypnos copied to clipboard

[feature] Motor integration

Open sdorre opened this issue 4 years ago • 1 comments

The pinetime watch has a small motor to produce vibration. Let's imake it work !

The motor is plugged on the GPIO P0.16 of the NRF52. See image. image

I guess simply driving low and high this GPIO would make it work. We will need some kind of thread or timer if we want to make some special vibration pattern. How should we integrate these patterns ? hardcoded ? or is there some way to generate them from a config file ?

  • [ ] Device Tree GPIO declaration
  • [ ] Vibrator Module
  • [ ] Vibrate on screen Tap ?

sdorre avatar Jul 17 '20 07:07 sdorre

I've already experimented with this.

I guess simply driving low and high this GPIO would make it work.

That's right.

Here is vibrator.c that I had only saved locally:

#include <zephyr.h>
#include <stdbool.h>
#include <drivers/gpio.h>
#include <display.h>
#include "vibrator.h"
#include "log.h"

/* ********** ********** DEFINES ********** ********** ********** */
#define VIBRATOR        16

/* ********** ********** VARIABLES  ********** ********** */
static struct device* vibrator_dev;

/* ********** ********** FUNCTIONS ********** ********** */
void vibrator_init()
{
	vibrator_dev = device_get_binding("GPIO_0");
	gpio_pin_configure(vibrator_dev, VIBRATOR, GPIO_OUTPUT);
	LOG_DBG("Vibrator init: Done");
}

void vibrator_enable(bool enable) {
	gpio_pin_set_raw(vibrator_dev, VIBRATOR, enable ? 0 : 1);
}

How should we integrate these patterns ? hardcoded ? or is there some way to generate them from a config file ?

I think we should work iteratively. We could begin by trying out a few useful patterns such as alarm and notification (could be the same for low battery warning and incoming message) and make the patterns configurable afterwards. Adding port 16 to the Device Tree would also be great of course.

endian-albin avatar Jul 17 '20 08:07 endian-albin