////////////////////// _genieWaitForIdle ////////////////////////
//
// Wait for the link to become idle or for the timeout period, 
// whichever comes first.
//
void _genieWaitForIdle (void) {
	uint16_t do_event_result;
	long timeout = millis() + _genieTimeout;

	for ( ; millis() < timeout;) {
		do_event_result = genieDoEvents();

		// if there was a character received from the 
		// display restart the timeout because doEvents
		// is in the process of receiving something
		if (do_event_result == GENIE_EVENT_RXCHAR) {
			timeout = millis() + _genieTimeout;
		}
		
		if (_genieGetLinkState() == GENIE_LINK_IDLE) {
			return;
		}
	}
	_genieError = ERROR_TIMEOUT;
	_handleError();
	return;
}
Beispiel #2
0
void loop() 
{ 
  static long waitPeriod = millis();
  static int gaugeAddVal = 1;
  static int gaugeVal = 50;

  genieDoEvents();

  if (millis() >= waitPeriod) 
  {
    // Write to CoolGauge0 with the value in the gaugeVal variable
    genieWriteObject(GENIE_OBJ_COOL_GAUGE, 0x00, gaugeVal); 
    gaugeVal += gaugeAddVal;
    if (gaugeVal == 99) gaugeAddVal = -1;
    if (gaugeVal == 0) gaugeAddVal = 1;

    // The results of this call will be available to myGenieEventHandler() after the display has responded
    // Do a manual read from the Slider0 object
    genieReadObject(GENIE_OBJ_SLIDER, 0x00);

    waitPeriod = millis() + 100;
  }
}