Avatar for Adam79

Adam79

Member since Jan 2017 • Last active Jul 2017
  • 3 conversations
  • 26 comments

Most recent activity

  • in Puck.js
    Avatar for Adam79

    I didn't :-)

  • in Puck.js
    Avatar for Adam79

    Pins for external battery

  • in Porting to new Devices
    Avatar for Adam79

    Oh wow, that is small.

    The idea of using a small/basic ble esprunino in a plug an play manner would be great, BYOB - Bring Your Own Bluetooth if you like.

    Also 3.7V compatible :-)

  • in Porting to new Devices
    Avatar for Adam79

    I'd love to have an "Original" espruino in the nano2 form :-).

  • in Puck.js
    Avatar for Adam79

    Think he means this for example

    Connected to device UUID: 5D9D6DC0-8162-4DF5-97F7-544733A0B978 Named: Puck.js de81

  • in Projects
    Avatar for Adam79

    It did cross my mind, but wasn't sure how it handled analog input so thought I'd role my own. Could also of bought a Parrot controller for £40 but there's no fun in that :-)

  • started
    • 3 comments
    • 378 views
  • in Projects
    Avatar for Adam79

    Thought I'd share my progress on my latest project the PuckPad. Currently a breadboard project which I'll hopefully move onto a custom PCB once I've ironed out all the issues ( and found another adafruit joypad pcb available in the UK ).

    The puck will read the relevant pins every 750ms ( will be 200ms outside of testing ) and update the custom BLE characteristic.

    // Author : Adam 
    // Project: PuckPad
    // Firmware: 0.10
    // BLE Services : Battery, Device and Custom controller
    // 
    //  Battery: 0x180F ->  0x2A19
    //  Device:  0x180A - > 0x2A29 (Manufactor Name)
    //                  - > 0x2A26 (Firmware Version)
    //  Custom: 0x9AD0 -> 0x9AD1 ( Int8 * 4 ) left xy right xy
    //                 -> 0x9AD2 ( 0 or 1 ); extra BTN
    //
    //
    // Puckpad has two analog joysticks and two buttons.
    // The pad will simply send each joysticks XY vlaues to a proxy IOS application to fly a parrot drone.
    //
    //   GND -> GND
    //   3V  -> 3V
    //   D2  -> X left joypad
    //   D31  -> Y left joypad
    //   D30  -> X right joypad
    //   D29  -> Y right joypad
    //   D28  -> BTN
    
    pinMode( D30, "input_pulldown" ); //currently not in use 
    pinMode( D29, "input_pulldown" ); // currnetly not in use
    
    var fwVersion = "0.9";
    var flashy = [150,200,150,200,150];
    var vflashy = [50,50,50];
    var connected = false;
    var refreshRate = 750;
    var isReading = false;
    var loopy = null;
    
    var xyxy = [0x00,0x00,0x00,0x00];
    
    var padBTN = 'D28';
    var pins = [ 'D2','D31','D30','D29'];
    // joypad     LX   LY    RX    RY  
    
    NRF.on('connect', function(addr) {
      connected = true;
      updateBattery();
      digitalPulse(LED3,1,flashy);
      
    });
    
    NRF.on('disconnect', function(addr) {
      connected = false;
      isReading = false;
      digitalPulse(LED1,1,flashy);
     }
    );
    
    NRF.setServices({
      0x180F : {
        0x2A19: {
          readable: true,
          notify: true,
          value : [100]
        }
      },
      0x9AD0 : {
        0x9AD1 : {
          readable: true,
          notify: true,
          value: xyxy
        },
        0x9AD2 : {
          readable : true,
          notify: true,
          value: [0x00]
        }
      },
      0x180A : {
        0x2A29 : {
          readable: true,
          value: 'PuckPad'
        },
        0x2A26 : {
          readable: true,
          value: fwVersion
        }
      }
    });
    
    function updateBattery () {
      NRF.updateServices({
      0x180F : {
        0x2A19: {
          notify: true,
          value : [Puck.getBatteryPercentage()]
        }
      }
    });
    }
    
    function updateXYXY(){
    
      xyxy.forEach(function(pinData,index) {
        xyxy[index] = Math.floor(analogRead(pins[index]) * 100);
      });
      
      // some manual calibration 
      xyxy[0] += 1;
      xyxy[1] += 2;
      xyxy[2] += 1;
      xyxy[3] += 1;
    
      NRF.updateServices({
        0x9AD1 : {
          0x9AD1 : {
            notify: true,
            value: xyxy
          }
        }
      });
    }
    
    function updateBTN1 (buttonIs) {
     NRF.updateServices({
      0x9AD0 : {
        0x9AD2 : {
          notify: true,
          value: buttonIs
        }
      }
    });
    }
    
    setWatch(function(e){
      isReading = !isReading;
      if (connected) { 
        if (isReading) {
          digitalPulse(LED3,1,vflashy);
          updateXYXY();
          loopy = setInterval(updateXYXY,refreshRate);
        } else {
        clearInterval(loopy);
        digitalPulse(LED1,1,vflashy);
        }
      } else {
        digitalPulse(LED2,1,flashy);
      }
    }, BTN, {repeat:true, debounce:50, edge:"falling"});
    
    

    TODO

    • Add second joystick
    • Complete IOS app - pure software controller working just need to connect to the puck and get the values.
    • Create custom PCB - adafruit have already created a single PCB file
    • Check battery usage

    I'll hopefully post back my progress in the coming weeks :)

Actions