Showing posts with label Smartwatch. Show all posts
Showing posts with label Smartwatch. Show all posts

Sunday, January 1, 2017

From Pebble Time to the Striiv Fusion Bio 2

As we all know, the Pebble smartwatches are a thing of the past.  I did owned the Pebble classic and the Pebble Time.  After the Fitbit acquisition of the Pebble company, I was a bit worried that my lovely Pebble Time would turn into a nice light paper weight...

In my search for an alternative smartwatch, I did review the whole internet for the next best thing.  The main features I was looking for was battery life time and a good notification system.  I don't really care for health tracking data.  It's nice to know how many steps I did today, but I am more into getting my notifications on my wrist.

This got me to think about on how I was using my smartwatch...  Basically, I look at the time, read my notifications and that's about it.  Even if the Pebble Time can display thousands of watchfaces and supports many apps to play with, the main usage is still looking at the date and time.

So I started to consider those trackers/smartwatches having less features but providing a good battery lifetime, a good readability and displaying notifications from my iPhone.  And the price became an issue as I did spent a few bucks on those fancy watches...

I finally found the Striiv Fusion Bio 2.


As I said earlier, the price became an issue.  I actually bought the Fusion 2 for 50$ (CAD) at Best Buy...  I did get lucky and got the Fusion Bio 2 instead for the same price.  For some strange reason, the package did show the Fusion 2, but the content was actually the Fusion Bio 2 priced at 100$ (CAD).

This is mainly a health tracker but it does have some nice features:  30 days battery lifetime, displays all notifications from my iPhone, heath tracking data is a nice and this is a touch interface so no more buttons.  The Fusion 2 is small and good looking.  It does everything beside heart rate monitoring.  Since I was lucky enough to end up with the Fusion Bio 2, I do have also the heart rate monitor.

Look at the detailed features here: https://www.striiv.com/pages/striiv-fusion-bio-2

Compared to the Pebble Time, it does lack apps and custom facewatch but it does it's job nicely for a fraction of the cost.  For 50$, I still get the time, notifications and alarms.  I have a better battery lifetime (5 days to 30 days...).

It was nice to have all these possibilities with the Pebble Time but in the end, I did not need them that much.  Was it worth it the price?  I don't think so...

So if you're looking for a nice alternative for a good price, check out the Striiv Fusion (Bio) 2 at your nearest retailer...

Friday, January 22, 2016

Transform your Pebble Watch into a mouse

Here's a neat little project that I created for my Pebble smartwatch:  MouseRock.

No it's not about Rock'n Roll but about using the Pebble as a mouse for a computer.  I must admit, it's not a very efficient way to interact with a computer but it was fun to experiment with.

The Pebble App

Use CloudPebble.net to create the watch app in Javascript.  Nothing fancy but the following source code was created using Pebble.js

var UI = require('ui');
var serverIP = "http://192.168.0.121:8000";
var Accel = require('ui/accel');

serverIP = localStorage.getItem("serverip");
Accel.config({
  rate:10,
  samples: 1,
  subscribe:true
});
Accel.on('data', function(e) {
  var x = 0;
  var y = 0;
  if (e.accel.x  > 200) x = e.accel.x / 50;
  if (e.accel.y  > 200) y = e.accel.y / 50 *-1;
  if (e.accel.x  < -200) x = e.accel.x / 50;
  if (e.accel.y  < -200) y = e.accel.y / 50 *-1;
  if (x !== 0 || y !== 0){
    //console.log("Z: " + e.accel.z);
    getXML(serverIP + "/?mousex="+x+"&mousey="+y);
  }

});
function getXML(url) {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("GET", url, true);
    xmlhttp.send();
}
var main = new UI.Card({
  title: 'PebbleRock',
  icon: 'images/menu_icon.png',
  subtitle: 'Current server',
  body: serverIP,
  subtitleColor: 'indigo', // Named colors
  bodyColor: '#9a0036' // Hex colors
});
main.show();
main.on("click","up",function(){
  getXML(serverIP + "/?mouseclick=1");
});
main.on("click","down",function(){
  getXML(serverIP + "/?mouserightclick=1");
});
main.on("click","select",function(){

});
The basic idea is to retrieve the data from the accelerometer and send the information to the computer via the HTTP protocol.  Some tweaking has been included for a better mouse handling.  Left and Right buttons have been integrated using the "click" event...

The MouseRock Server

Now that you've created the watch app, you need to create the computer server to handle the data from the Pebble.  Again, nothing fancy, just a simple HTTP server built in Java.  Here's the source code...

package pebblemouse;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import java.awt.event.InputEvent;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Map;
/**
 *
 * @author patrick
 */
public class MouseRock {
    public static void main(String[] args) throws Exception {
        HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
        server.createContext("/", new MyHandler());
        server.setExecutor(null); // creates a default executor
        System.out.println("MouseRock Server:");
        System.out.println("Server Address: http://" + InetAddress.getLocalHost().getHostName() + ":" + 8000);
        System.out.println("----------------------------");
        System.out.println("Enter this URL into your MouseRock configuration page.");
        server.start();
    }
    static class MyHandler implements HttpHandler {
        @Override
        public void handle(HttpExchange t) throws IOException {
            try {
                java.awt.Robot robot = new java.awt.Robot();
                int currentX = (int) java.awt.MouseInfo.getPointerInfo().getLocation().getX();
                int currentY = (int) java.awt.MouseInfo.getPointerInfo().getLocation().getY();
                String response = "Command received...";
                if (t.getRequestURI().getQuery() != null) {
                    Map<String, String> maps = queryToMap(t.getRequestURI().getQuery());
                    for (String param : maps.keySet()) {
                        String value = maps.get(param);
                        switch (param) {
                            case "mousex":
                                int x = new Double(value).intValue();
                                currentX += x;
                                robot.mouseMove(currentX, currentY);
                                //System.out.println("Mouse X");
                                break;
                            case "mousey":
                                int y = new Double(value).intValue();
                                currentY += y;
                                robot.mouseMove(currentX, currentY);
                                //System.out.println("Mouse Y");
                                break;
                            case "mouseclick":
                                robot.mousePress(InputEvent.BUTTON1_MASK);
                                robot.mouseRelease(InputEvent.BUTTON1_MASK);
                                System.out.println("Mouse Clicked");
                                break;
                            case "mouserightclick":
                                robot.mousePress(InputEvent.BUTTON3_MASK);
                                robot.mouseRelease(InputEvent.BUTTON3_MASK);
                                System.out.println("Mouse Right Clicked");
                                break;
                        }
                    }
                }
                t.sendResponseHeaders(200, response.length());
                OutputStream os = t.getResponseBody();
                os.write(response.getBytes());
                os.close();
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
            }
        }
    }
    public static Map<String, String> queryToMap(String query) {
        Map<String, String> result = new HashMap<>();
        for (String param : query.split("&")) {
            String pair[] = param.split("=");
            if (pair.length > 1) {
                result.put(pair[0], pair[1]);
            } else {
                result.put(pair[0], "");
            }
        }
        return result;
    }
}
What the server does is get the Mouse X, Mouse Y values sent from the Pebble smartwatch and uses the Robot class to move the mouse.  The server is moving the mouse by adding/subtracting a value to the current mouse location.  Since the Pebble watch will send a lot of data, those values must be small increments.  Buttons were also handled by activating them when the "Up" and "Down" were pressed on the Pebble.

Since the server was coded in Java, it should work on any operating system: Linux, Windows or OSX.

The Result

This hack won't replace a real mouse as it is a bit cumbersome to use.  But it's a fun experiment to create a motion activated mouse.

Here's a video of the experiment:



Tuesday, December 15, 2015

Update your Pebble!

Today, Pebble has made available the their new firmware (3.8) for the Pebble Time.

The major new feature is the new app Health that can be synced with your smartphone Health Kit.  The Pebble Time smart watch is becoming more and more interesting with each new update and this one is a major one.



You need to update your Pebble Time companion app on your smartphone.  Then you will be able to upgrade your watch in just a few minutes.

At the same time, the original Pebble will also benefit a major revision as it is moving the the new Pebble Time interface.  I just finished installing it on my OP.  Even if the display is monochrome, the new interface is looking great, fast and smooth.