示例#1
0
bool SevenSegment::update(void)
{
	unsigned long cur = micros();
	uint16_t diff = cur - _lastUpdateTime;
	if(diff > _updateInterval){
		digitOff();
		_currentDigit++;
		if(_currentDigit >= _numberOfDigits)
			_currentDigit = 0;
		updateDigit();
		digitOn();
		_lastUpdateTime = micros();
		return _currentDigit == (_numberOfDigits-1);
	}
	return false;
}
示例#2
0
//show 1 pattern
void SegDisp::showPattern(int digit, int pattern[7], int ms, bool dot){
	
	if (ms < 0){
		Error(12);
	}
	else if (digit > 3 || digit < 0){
		Error(13);
	}
	/*
	if we need to include the dot, do so
	Otherwise, just show the pattern
	*/
	writePattern(pattern,dot);
	digitOn(digit);
	delay(ms);
	digitOff(digit);
	digitalWrite(pins[7],LOW); //this is the dot
}
示例#3
0
//clear everything
void SegDisp::clear(){
	/*
	clear all of the pins
	*/
	writePattern(numbers[sd_EMPTY],false);
	/*
	turn off the colon
	*/
	colonOff();
	/*
	turn off the dot
	*/
	digitalWrite(pins[7],LOW);
	/*
	disconnect ground
	*/
	for (int x=0; x<4; x++){
		digitOff(x);
	}
}