示例#1
0
void LTM8328PKR04::pushLetter(char car,bool decimal)
{
	if(car==' ')
	{
		pushDigit(10,decimal);
		return;
	}
	if(car=='-')
	{
		pushDigit(11,decimal);
		return;
	}	
	if(car>='0' && car<='9')
	{
		pushDigit(car-0x30,decimal);
		return;
	}
	int index=-1;
	switch(car)
	{
		case 'A':
			index=0;
			break;
		case 'C':
			index=1;
			break;
		case 'E':
			index=2;
			break;
		case 'H':
			index=3;
			break;
		case 'L':
			index=4;
			break;
		case 'P':
			index=5;
			break;
		case 'U':
			index=6;
			break;
		case 'd': // ° symbol
			index=7;
			break;
		case 'q':
			index=8;
			break;
	}
	
	if(index==-1)
	{
		pushLetter(' ');
		return;
	}
	for(int segment=7;segment!=0;segment--)
		pushBit((letter[index]>>segment)&1);
	pushBit(decimal);
}
void LTM8328PKR04::clear()
{
	pushBit(1);
	pushDigit(10);
  pushDigit(10);
  pushDigit(10);
  pushDigit(10);
  pushBit(0);
  pushBit(0);
  pushBit(0);
};
示例#3
0
void comput(Digit *digit, OpStack *opStack)
{
	int b = popDigit(digit);
	int a = popDigit(digit);
	char ch = popOpStack(opStack);
	int result = 0;
	switch (ch) {
		case '+': 
			result = a + b; 
			break;
		case '-':
			result = a - b; 
			break;
		case '*':
			result = a * b;
			break;
		case '/':
			if(b != 0) {
				result = a / b;
			} else {
				printf("diviver can not be 0!\n");
				return;
			}
			break;
	}
	pushDigit(digit, result);
	printf("push result : %d in stack\n", result);
}
void LTM8328PKR04::print(int number)
{
  // send a "1" first
  pushBit(1);
  if( number<-999 or number>9999)
	{
    // ---- out of range
    pushDigit(11);
    pushDigit(11);
    pushDigit(11);
    pushDigit(11);
    pushBit(0);
  	pushBit(0);
  	pushBit(0);
  	return;
  }
  bool positive=number>=0;
  number=abs(number);
  if( number>999)
  {
    pushDigit(number/1000);
    pushDigit((number%1000)/100);
    pushDigit((number%100)/10);
    pushDigit(number%10);
  }
  else if( number>99)
  {
    if(positive)
    	pushDigit(m_leadingZeros?0:10);
    else
    	pushDigit(11);
    pushDigit(number/100);
    pushDigit((number%100)/10);
    pushDigit(number%10);
  }
  else if( number>9)
  {
    if(positive)
    {
    	pushDigit(m_leadingZeros?0:10);
    	pushDigit(m_leadingZeros?0:10);
    }
    else
    {
    	pushDigit(m_leadingZeros?11:10);
    	pushDigit(m_leadingZeros?0:11);
    }
    pushDigit(number/10);
    pushDigit(number%10);
  }
  else
  {
    if(positive)
    {
    	pushDigit(m_leadingZeros?0:10);
    	pushDigit(m_leadingZeros?0:10);
    	pushDigit(m_leadingZeros?0:10);
  	}
  	else
  	{
  		pushDigit(m_leadingZeros?11:10);
  		pushDigit(m_leadingZeros?0:10);
  		pushDigit(m_leadingZeros?0:11);
  	}
    pushDigit(number);
  }  
  // then send 3 other bits (2 external leds + 1 final latch clock)
  pushBit(0);
  pushBit(0);
  pushBit(0);
}