Kenneth Yang
Published © GPL3+

MotionWear

Want to measure your activity over the course of 12 hours? Here's your gadget! This could be your sleep or even your daily activity.

BeginnerFull instructions provided4 minutes1,013
MotionWear

Things used in this project

Hardware components

Hexiwear
NXP Hexiwear
×1

Software apps and online services

mBed OS online compiler

Story

Read more

Custom parts and enclosures

Enclosure with Reset Button (.f3d)

The title says it all. This is a case for the Hexiwear! This case also make it easier to press the MK64 reset button located inside the Hexiwear.

MotionWearCaseForPrint.f3d

Print ready version in .f3d format
File missing, please reupload.

MotionWearCaseForPrint.stl

Print ready version in .stl format

Schematics

Development board

In order to get the program on the Hexiwear, you will need a Hexiwear Docking Station

Code

main.cpp

C/C++
The main code file
#include "mbed.h"
#include "FXAS21002.h"
#include "Hexi_OLED_SSD1351.h"

SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15);
FXAS21002 gyro(PTC11,PTC10);

float gyDat[3];
int Dat[30];
//int Dat[6];
float rms=0.0;
char txt[20];
int x=0, y;
long notAvDat;

// main() runs in its own thread in the OS
// (note the calls to Thread::wait below for delays)
int main() {
    //setup oled
    oled_text_properties_t txtProp = {0};
    oled.GetTextProperties(&txtProp);
    oled.DimScreenON();
    oled.FillScreen(COLOR_BLACK);
    
    gyro.gyro_config();
    for(int l=0;l<24;l++){
        for(int l=0;l<30;l++){
        //for(int l=0;l<6;l++){
            gyro.acquire_gyro_data_dps(gyDat);
            rms = sqrt(((gyDat[0]*gyDat[0])+(gyDat[1]*gyDat[1])+(gyDat[2]*gyDat[2]))/3);
            int rrms= (int) rms;
            y= rrms*96/1000;
          
            Dat[l]=y;
            //Thread::wait(10000);
            Thread::wait(60000);
        }
        for(int l=0;l<30;l++){
        //for(int l=0;l<6;l++){
            notAvDat+= Dat[l];
        }
        y=notAvDat/30;
        //y=notAvDat/6;
        oled.DrawBox(x, 95-y, 4, y, COLOR_WHITE);
        x+=4;
    } 
    x=0;
}

Motion_HEXIWEAR

Binary code of MotionWear. Drag and drop this into the "DAPLINK" Mass storage drive.

Credits

Kenneth Yang

Kenneth Yang

9 projects • 100 followers
Maker, developer, 3D content creator

Comments