Failed Camera Slide

Ok,

My Wife had her first day back at work after maternity leave, so i have only just had the chance to run some more tests.

I went back to basic with the bluetooth module and made sure the Android App and the Bluetooth module were communicating.

I had to change some coding from this:

/* ...hardware SPI, using SCK/MOSI/MISO hardware SPI pins and then user selected CS/IRQ/RST */
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

To this:

/* ...software SPI, using SCK/MOSI/MISO user-defined SPI pins and then user selected CS/IRQ/RST */
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_SCK, BLUEFRUIT_SPI_MISO,
                             BLUEFRUIT_SPI_MOSI, BLUEFRUIT_SPI_CS,
                             BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

I did a factory reset of the bluetooth module while i was at it.

Now when i use the app on my phone, the serial monitor picks it up!

From the serial monitor:


Adafruit Bluefruit App Controller Example

Initialising the Bluefruit LE module: OK!
Performing a factory reset:
AT+FACTORYRESET

<- OK
ATE=0

<- OK
Requesting Bluefruit info:

BLESPIFRIEND
nRF51822 QFACA10
A3E6FB9642754858
0.7.7
0.7.7
Dec 13 2016
S110 8.0.0, 0.2

Please use Adafruit Bluefruit LE app to connect in Controller mode
Then activate/use the sensors, color picker, game controller, etc!


Change LED activity to MODE
Switching to DATA mode!


Button 1 pressed
Button 1 released
Button 2 pressed
Button 2 released
Button 3 pressed
Button 3 released
Button 4 pressed
Button 4 released


I have then modded a simple code to work roughly for my needs.

Pressing 1 now moves the rail 1000 steps at 1 RPM

 if (pressed) {
      switch(buttnum) {
        case 1: { // 1 - Moves forward at 1 rpm
          myMotor->step(1000, FORWARD, MICROSTEP);
          break;

:) Happy(er) now!

However, I have not got 8 buttons to play with!

On the advanced code they have used, you can set up different time scales!

For example:

// A few different time periods are supported, but not a whole lot.  Since
// there's no display connected, we just blink the onboard LED to indicate
// which setting is active, and there's only so many speed changes one can
// reliably 'read' this way.  Feel free to edit, but keep in mind there are
// upper and lower limits to the time interval -- the stepper can only move
// so fast and if you try to press beyond that it'll just move linearly
// regardless of the selected interpolation mode, and the micros() function
// rolls over about every 70 minutes, so the duration can't exceed that.
// Blink rate is similarly constrained due to BLE comm; about 2 Hz max.
struct {
  uint32_t totalTime;    // Total duration of movement along slider
  uint32_t LEDflashTime; // LED blink rate indicates selected speed
} speed[] = {
   5 * 60 * 1000000L, 1000000L / 2, //  5 min slide,   2 Hz blink
  10 * 60 * 1000000L, 1000000L,     // 10 min slide,   1 Hz blink
  20 * 60 * 1000000L, 1000000L * 2, // 20 min slide, 1/2 Hz blink
  60 * 60 * 1000000L, 1000000L * 3  // 60 min slide, 1/3 Hz blink
};
#define N_SPEEDS (sizeof(speed) / sizeof(speed[0]))

uint32_t startTime = 0;      // micros() value when slider movement started
interp   mode      = linear; // Selected interpolation mode
uint8_t  speedIdx  = 0;      // Selected speed index (0 to N_SPEEDS-1)
boolean  moving    = false;  // True if motor active & interpolating

I would really like this function, but i have no idea how to add that to my code?