//sound detection and display
task SoundDB()
{
	//Declare Variables
	int i;
	int soundLVL;
	SensorType[S1] = sensorSoundDBA;
	soundLVL = 0;

	displayInverseStringAt(5, 120, "Sound Level");//Display 'Sound Level' at top left of screen

	while(true){
		soundLVL = SensorValue[S1];

		if(soundLVL > 80) soundLVL = 80;//set max for Db reading
		//Draw Sound Bar
		for(i = 0; i < soundLVL; i++){
			fillRect(0,0,30,NOISE + i);
			sleep(1);
		}
		//Erase Sound Bar
		for(i = soundLVL; i > 0; i--){
			eraseRect(0,(NOISE + i)-1,30,NOISE + i);
			sleep(1);
		}

	}//end while true
}//end soundDB
Exemplo n.º 2
0
void drawExampleName()
{
	int			left, top;
	Rect		rect;
	Str255		label = "\pCurrent Example:  ";
	Str255		name[9] = {	"\p TRANSFER MODES", "\pARITHMETIC MODES", "\p   DITHERING",
							"\p  COLORIZATION", "\p  COLOR MAPPING", "\p  PAINT BUCKET",
							"\p   LASSO TOOL", "\pPIXEL AVERAGING", "\p    CUSTOM"	};
	Rect		tempRect1;
	
	left = 15;
	top = GetPortBounds(GetWindowPort(gWindow), &tempRect1)->bottom - 13;
	
	drawName( left, top, label );
	left += StringWidth( label );
	
	SetRect( &rect, left - 2, top - 12, left + 130, top + 4 );
	eraseRect( &rect );
	
	drawName( left, top, name[(gCurrentExample / 10) - 1] );
}

void drawTime( long ticks )
{
	Rect	rect;
	int		left, top;
	float	seconds;
	char	cString[40];
	Rect	tempRect1;
	
	GetPortBounds(GetWindowPort(gWindow), &tempRect1);
	left = tempRect1.right - 130;
	top = tempRect1.bottom - 13;
	
	
	SetRect( &rect, left - 2, top - 12, left + 90, top + 4 );
	eraseRect( &rect );
	
	seconds = (float)ticks / 60.0;
	sprintf( &cString[0], "Draw Time: %03.03f secs", seconds );
	
	drawName( left, top, C2PStr( cString ) );
}
Exemplo n.º 3
0
void TipsPainter::repaintLine(const QPoint& pntbgn, const QPoint& pntend, const QPoint& prevpntbgn, const QPoint& prevpntend)
{
	int leftx = prevpntbgn.x();
	if (prevpntend.x() < prevpntbgn.x())
		leftx = prevpntend.x();
	int topy = prevpntbgn.y();
	if (prevpntend.y() > prevpntbgn.y())
		topy = prevpntend.y();
	eraseRect(QRect(leftx, topy, abs(prevpntend.x() - prevpntbgn.x()), abs(prevpntend.y() - prevpntbgn.y())));

	drawLine(pntbgn, pntend);
}
/*-----------------------------------------------------------------------------*/
void
iqDisplayLine( int row, bool select, char *str )
{
    if( row < 0 || row > 43 )
        return;

    if( select ) {
        fillRect( 0, row+1, 127, row-8);
        displayInverseStringAt( 1, row, str );
    }
    else {
        eraseRect( 0, row+1, 127, row-8);
        displayStringAt( 1, row, str);
    }
}
task main () {
  short red = 0;
  short green = 0;
  short blue = 0;
  short _color = 0;
  string _tmp;

  displayCenteredTextLine(0, "HiTechnic");
  displayCenteredBigTextLine(1, "COLOUR");
  displayCenteredTextLine(3, "Test 1");
  displayCenteredTextLine(5, "Connect sensor");
  displayCenteredTextLine(6, "to S1");
  sleep(2000);

  eraseDisplay();
  while (true) {
    // Read the currently detected colour from the sensor
    _color = HTCSreadColor(HTCS);

    // If colour == -1, it implies an error has occurred
    if (_color < 0) {
      displayTextLine(4, "ERROR!!");
      sleep(2000);
      stopAllTasks();
    }

    // Read the RGB values of the currently colour from the sensor
    // A return value of false implies an error has occurred
    if (!HTCSreadRGB(HTCS, red, green, blue)) {
      displayTextLine(4, "ERROR!!");
      sleep(2000);
      stopAllTasks();
    }

    displayCenteredTextLine(0, "Color: %d", _color);
    displayCenteredBigTextLine(1, "R  G  B");

    eraseRect(0,10, 99, 41);
    fillRect( 0, 10, 30, 10 + (red+1)/8);
    fillRect(35, 10, 65, 10 + (green+1)/8);
    fillRect(70, 10, 99, 10 + (blue+1)/8);
    StringFormat(_tmp, " %3d   %3d", red, green);
    displayTextLine(7, "%s   %3d", _tmp, blue);

    sleep(100);
  }
}
Exemplo n.º 6
0
void KisAbstractSliderSpinBox::paintEvent(QPaintEvent* e)
{
    Q_D(KisAbstractSliderSpinBox);
    Q_UNUSED(e)

    QPainter painter(this);

    //Create options to draw spin box parts
    QStyleOptionSpinBox spinOpts = spinBoxOptions();

    //Draw "SpinBox".Clip off the area of the lineEdit to avoid double
    //borders being drawn
    painter.save();
    painter.setClipping(true);
    QRect eraseRect(QPoint(rect().x(), rect().y()),
                    QPoint(progressRect(spinOpts).right(), rect().bottom()));
    painter.setClipRegion(QRegion(rect()).subtracted(eraseRect));
    style()->drawComplexControl(QStyle::CC_SpinBox, &spinOpts, &painter, d->dummySpinBox);
    painter.setClipping(false);
    painter.restore();


    //Create options to draw progress bar parts
    QStyleOptionProgressBar progressOpts = progressBarOptions();

    //Draw "ProgressBar" in SpinBox
    style()->drawControl(QStyle::CE_ProgressBar, &progressOpts, &painter, 0);

    //Draw focus if necessary
    if (hasFocus() &&
            d->edit->hasFocus()) {
        QStyleOptionFocusRect focusOpts;
        focusOpts.initFrom(this);
        focusOpts.rect = progressOpts.rect;
        focusOpts.backgroundColor = palette().color(QPalette::Window);
        style()->drawPrimitive(QStyle::PE_FrameFocusRect, &focusOpts, &painter, this);
    }

}
task main () {
  string _tmp;

  displayCenteredTextLine(0, "HiTechnic");
  displayCenteredBigTextLine(1, "Color V2");
  displayCenteredTextLine(3, "Test 1");
  displayCenteredTextLine(5, "Connect sensor");
  displayCenteredTextLine(6, "to S1");
  sleep(2000);

  // Create struct to hold sensor data
  tHTCS2 colorSensor;

  // Initialise and configure struct and port
  initSensor(&colorSensor, S1);

  eraseDisplay();
  while (true)
  {
    // Read the currently detected colour and RGB/HSV data from the sensor
    if (!readSensor(&colorSensor)) {
      displayTextLine(4, "ERROR!!");
      sleep(2000);
      stopAllTasks();
    }

    displayCenteredTextLine(0, "Color: %d", colorSensor.color);
    displayCenteredBigTextLine(1, "R  G  B");

    eraseRect(0,10, 99, 41);
    fillRect( 0, 10, 30, 10 + (colorSensor.red+1)/8);
    fillRect(35, 10, 65, 10 + (colorSensor.green+1)/8);
    fillRect(70, 10, 99, 10 + (colorSensor.blue+1)/8);
    StringFormat(_tmp, " %3d   %3d", colorSensor.red, colorSensor.green);
    displayTextLine(7, "%s   %3d", _tmp, colorSensor.blue);

    sleep(100);
  }
}
Exemplo n.º 8
0
void
drawBitmap( const unsigned char *bitmap )
{
    int row, stripe, pix;
    int p;

    eraseRect( 0, 10, 127, 24 );

    // 24 rows
    for(row=0;row<24;row++)
        {
        // 16 bytes each with 8 pixels
        for(stripe=0;stripe<16;stripe++)
            {
            p = bitmap[ (row*16) + stripe ];
            for(pix=0;pix<8;pix++)
                {
                if( ( p & 0x80 ) )
                    setPixel( (stripe*8) + pix, (34-row) );
                p <<= 1;
                }
            }
        }
}
task main () {
  bool selected_50hz = true;

  displayCenteredTextLine(0, "HiTechnic");
  displayCenteredBigTextLine(1, "Color V2");
  displayCenteredTextLine(4, "Config operating");
  displayCenteredTextLine(5, "frequency to");
  displayCenteredTextLine(6, "50 or 60 Hz");
  sleep(2000);

  eraseDisplay();
  displayCenteredTextLine(0, "Use arrow keys");
  displayCenteredTextLine(1, "to select a");
  displayCenteredTextLine(2, "frequency");
  displayCenteredBigTextLine(4, "50 60");
  displayCenteredTextLine(6, "[enter] to set");
  displayCenteredTextLine(7, "[exit] to cancel");

  drawRect(19, 34, 44, 16);

  while (true) {
    while (nNxtButtonPressed == kNoButton) {
      sleep(1);
    }

    switch (nNxtButtonPressed) {
      // if the left button is pressed, set the sensor for 50Hz
      case kLeftButton:
            if (selected_50hz) {
              playSound(soundBlip);
              while(bSoundActive) {sleep(1);}
            } else {
              selected_50hz = true;
              eraseRect(55, 34, 80, 16);
              displayCenteredBigTextLine(4, "50 60");
              drawRect(19, 34, 44, 16);
            }
            break;
       // if the right button is pressed, set the sensor for 60Hz
       case kRightButton:
            if (!selected_50hz) {
              playSound(soundBlip);
              while(bSoundActive) {sleep(1);}
            } else {
              selected_50hz = false;
              eraseRect(19, 34, 44, 16);
              displayCenteredBigTextLine(4, "50 60");
              drawRect(55, 34, 80, 16);
            }
            break;
        // Make the setting permanent by saving it to the sensor
        case kEnterButton:
            eraseDisplay();

            if (selected_50hz)
              setHz(HTCS2, 50);
            else
              setHz(HTCS2, 60);

            displayCenteredTextLine(2, "The Sensor is");
            displayCenteredTextLine(3, "configured for");
            if (selected_50hz)
              displayCenteredTextLine(4, "50 Hz operating");
            else
              displayCenteredTextLine(4, "60 Hz operating");
            displayCenteredTextLine(5, "frequency");
            for (short i = 5; i > 0; i--) {
              displayCenteredTextLine(7, "Exiting in %d sec", i);
              sleep(1000);
            }
            stopAllTasks();
            break;
    }

    // Debounce the button
    while (nNxtButtonPressed != kNoButton) {
      sleep(1);
    }

  }
}
Exemplo n.º 10
0
void GfxPaint16::kernelGraphFillBoxBackground(const Common::Rect &rect) {
	eraseRect(rect);
}