   for (int i=0; i<8; i++) {
     if (movement > (t<<i)) mask = (mask << 1) | 1;
   }
-  if (movement==0) {
+  if (movement==0) { // no movement
     if (stillMillis==0) {
       stillBegin = millis();
       stillMillis = 1;

  return seqNum;
}
bool rollSent = false;

// ************* IMU **************************************************
int16_t vraw[10]; // raw readings from IMU and info for sending via BLE
                  // [0:5]=AxAyAzGxGyGz, [6]=movement, [7]=stillMs, [8]=diceId, [9]=seqNum
int vprev[6];     // previous reading

int16_t movement=0;
unsigned long stillBegin;
unsigned long stillMillis=0;   // number of sequential zero movements


int16_t imuRead() {
  for (int i=0; i<6; i++) vprev[i] = vraw[i];
  CurieImu.getMotion6(&vraw[0], &vraw[1], &vraw[2], &vraw[3], &vraw[4], &vraw[5]);
  movement = 0;
  for (int i=0; i<6; i++) {
    int m = (abs(vprev[i]-vraw[i])) >> 8;
    if (m>movement) movement = m;
  }
  // movement is 8 bits
  int mask = 0x0;

BLEUnsignedCharCharacteristic diceCommandCharacteristic("0x2A9F", BLERead|BLEWrite|BLENotify);

boolean gConnect = false;
unsigned char diceId = 1;
uint16_t  seqNum = 0;
uint16_t nextSeqNum() {
