Esempio n. 1
0
//--------------------------------------------------------------
void DonutCop::update(int size) {
  if (currentSecond() != lastSecond) {
    sendStatusMessage(size);
    if (id == 0) {
      sendControlMessage();
      removeExpiredIds();
    }
    lastSecond = currentSecond();
    createdSprinkles = 0;
  }
  checkForMessages();
}
Esempio n. 2
0
//--------------------------------------------------------------
void DonutCop::removeExpiredIds() {

  int expiredTime = currentSecond();
  if (expiredTime <= ID_EXPIRATION_IN_SECONDS) {
    return;
  } else {
    expiredTime -= ID_EXPIRATION_IN_SECONDS;
  }

  for (auto iter = knownIds.begin(); iter != knownIds.end();) {
    if (iter->second < expiredTime) knownIds.erase(iter++);
    else ++iter;
  }
}
Esempio n. 3
0
void DigitalFace::displayDigital(DateTime now, Adafruit_SharpMem display, uint32_t x_offset, uint32_t y_offset) {
  // draw the epoch
  unsigned long epoch = now.unixtime();
  display.setCursor(x_offset + 1,y_offset);
  currentHour(epoch / 3600 % 12);
  currentMinute(epoch / 60 % 60);
  currentSecond(epoch % 60);

  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.print(hour+":"+minutes+":");
  display.setTextSize(1);
  display.setCursor(x_offset + 72,y_offset+4);
  display.print(seconds);
}
Esempio n. 4
0
//--------------------------------------------------------------
void DonutCop::handleStatusMessage(const ofxOscMessage &m) {
  int statusId = m.getArgAsInt32(0);
  int sprinkles = m.getArgAsInt32(1);
  knownIds[statusId] = currentSecond();
  ofLogVerbose() << "Received an update from ID " << statusId << ": it has " << sprinkles << " sprinkles.";
}