Exemplo n.º 1
0
int CalibrateSetting(int w, char st[])
{
  printf("%s: %d\n", st, w);
  StartPress();
  w = WSetting(st, MultDiv(w, 80, 100), MultDiv(w, 120, 100));
  return w;
}
Exemplo n.º 2
0
int WProportion(int wIn, int wInMin, int wInMax, int wOutMin, int wOutMax)
{
  int w;

  if (wIn <= wInMin) return wOutMin;
  if (wIn >= wInMax) return wOutMax;
  w = MultDiv(wIn - wInMin, wOutMax-wOutMin, wInMax-wInMin) + wOutMin;
  return w;
}
void Parser::SubAdd_1() {
	
  switch(lookahead) {
  int tempVal;
  int tempVal_2;
        case T_PLUS:
        	match(T_PLUS);
        	if( evaluate == true) {
        		tempVal = value;
        	    }
        	MultDiv();
        	if( evaluate == true) {
        		value = tempVal + value;
        		}
        	SubAdd_1();
        	break;
   		
   		case T_MINUS:
   			match(T_MINUS);
   			if( evaluate == true) {
   				tempVal_2 = value;
   				}
    		MultDiv();
    		if( evaluate == true) {
    			value = tempVal_2 - value;
    			}
        	SubAdd_1();
        	break;
    	
    	case T_SEMICOLON:
    	case T_EOF:
    	case T_CLOSEPAREN:
    	case T_CLOSEBRACKET:
    	  //epsilon
    		break; 
    		
    	default:
    		parseError(scanner.lineNumber(), lookahead);
    		break;
    }
}
Exemplo n.º 4
0
BOOL TooltipAnimate(PTOOLTIPWND pttwnd)
{
    int y, yMem, yReal, ny, iy, cx, cy;
    DWORD dwElapsed;
    HDC hdc;
    BOOL fRet = FALSE;

    if (pttwnd->pstr == NULL)
        return TRUE;

    hdc = GetTooltipDC(pttwnd);
    cx = pttwnd->rcWindow.right - pttwnd->rcWindow.left;
    cy = pttwnd->rcWindow.bottom - pttwnd->rcWindow.top;
    dwElapsed = NtGetTickCount() - pttwnd->dwAnimStart;
    iy = MultDiv(cy, dwElapsed, CMS_TOOLTIP);

    if (dwElapsed > CMS_TOOLTIP || iy == cy) {
        GreBitBlt(hdc, 0, 0, cx, cy, pttwnd->hdcMem, 0, 0, SRCCOPY | NOMIRRORBITMAP, 0);
        fRet = TRUE;
        goto Cleanup;
    } else if (pttwnd->iyAnim == iy) {
        goto Cleanup;
    }

    if (pttwnd->dwFlags & TTF_POSITIVE) {
        y = 0;
        ny = 0;
    } else {
        y = cy;
        ny = -1;
    }

    yReal = y + ny * iy;
    yMem = (pttwnd->dwFlags & TTF_POSITIVE) ? cy - iy : 0;
    pttwnd->iyAnim = iy;

    GreBitBlt(hdc, 0, yReal, cx, iy, pttwnd->hdcMem, 0, yMem, SRCCOPY | NOMIRRORBITMAP, 0);

Cleanup:
    _ReleaseDC(hdc);
    return fRet;
}
Exemplo n.º 5
0
/* Measure ticks per second */
void CalibrateSpeed()
{
  long msStart;
  long msEnd;
  int cForward;
  int cBack;
  int cTicks = 500;
  int i;
  int fServo;

  for (fServo = 0; fServo < 2; fServo++)
    {
    if (fServo)
      {
      enable_servos();
      Gate(0);
      printf("Servo: ");
      }
    else
      printf("No Servo: ");

    for (i = 0; i < 2; i++)
      {
      msStart = mseconds();
      Move(cTicks,cTicks);
      msEnd = mseconds();
      rgSpeed[i] = MultDiv(100, 1000, (int) (msEnd - msStart));
      printf("%d ", rgSpeed[i]);
      cTicks = -cTicks;
      sleep(1.0);
      }

    if (fServo)
      disable_servos();

    printf("\n");
    StartPress();
    }
}
void Parser:: SubAdd() {
  MultDiv();
  SubAdd_1();
}
Exemplo n.º 7
0
int ScaleKnob(int wMin, int wMax)
{
  return MultDiv(knob(), wMax-wMin, 255) + wMin;
}