Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Motor integration #49

Open
3 tasks
sdorre opened this issue Jul 17, 2020 · 1 comment
Open
3 tasks

[feature] Motor integration #49

sdorre opened this issue Jul 17, 2020 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@sdorre
Copy link
Collaborator

sdorre commented Jul 17, 2020

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 sdorre added the enhancement New feature or request label Jul 17, 2020
@endian-albin
Copy link
Collaborator

endian-albin commented Jul 17, 2020

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 endian-albin self-assigned this Jul 17, 2020
@endian-albin endian-albin removed their assignment Aug 9, 2020
@endian-albin endian-albin added the good first issue Good for newcomers label Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants