Esempio n. 1
0
void cmd_gettext(uint8_t argc, char **argv)
{
  // Print results from an alpha-numeric dialogue
  char* results = alphaShowDialogue();
  drawFill(COLOR_BLACK);
  printf("%s%s", results, CFG_PRINTF_NEWLINE);
}
Esempio n. 2
0
void ofxUICanvas::draw()
{
    ofPushStyle(); 
    glDisable(GL_DEPTH_TEST);       
    glDisable(GL_LIGHTING);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA); 
    ofSetRectMode(OF_RECTMODE_CORNER);         
    ofSetLineWidth(1.0);         
    
    drawPadded();
    
    drawPaddedOutline(); 
    
    drawBack(); 
    
    drawFill(); 
    
    drawFillHighlight(); 
    
    drawOutline(); 
    
    drawOutlineHighlight();

    for(int i = widgets.size()-1; i >= 0; i--)
    {
        if(widgets[i]->isVisible())
        {
            widgets[i]->draw(); 	
        }
    }
    
    glDisable(GL_DEPTH_TEST); 
    ofPopStyle();         
}
Esempio n. 3
0
tsTouchData_t tsRenderCalibrationScreen(uint16_t x, uint16_t y, uint16_t radius)
{
  drawFill(COLOR_WHITE);
  tsCalibCenterText(TS_LINE1, 50, COLOR_GRAY_50);
  tsCalibCenterText(TS_LINE2, 65, COLOR_GRAY_50);
  tsCalibCenterText(TS_LINE3, 80, COLOR_GRAY_50);
  drawCircle(x, y, radius, COLOR_RED);
  drawCircle(x, y, radius + 2, COLOR_GRAY_128);

  // Wait for a valid touch events
  tsTouchData_t data;
  tsTouchError_t error;
  bool valid = false;
  while (!valid)
  {    
    // Set calibration flag for ts read
    error = tsRead(&data, true);
    if (!error && data.valid)
    {
      valid = true;
    }
  }

  return data;
}
char* alphaShowDialogue(void)
{
  char result;

  /* These need to be instantiated here since the width and height of 
     the lcd is retrieved dynamically depending on screen orientation */
  alphaBtnX[0] = ALPHA_COL1_LEFT;
  alphaBtnX[1] = ALPHA_COL2_LEFT;
  alphaBtnX[2] = ALPHA_COL3_LEFT;
  alphaBtnX[3] = ALPHA_COL4_LEFT;
  alphaBtnX[4] = ALPHA_COL5_LEFT;
  alphaBtnY[0] = ALPHA_ROW1_TOP;
  alphaBtnY[1] = ALPHA_ROW2_TOP;
  alphaBtnY[2] = ALPHA_ROW3_TOP;
  alphaBtnY[3] = ALPHA_ROW4_TOP;
  alphaBtnY[4] = ALPHA_ROW5_TOP;
  alphaBtnY[5] = ALPHA_ROW6_TOP;

  /* Initialise the string buffer */
  memset(&alphaString[0], 0, sizeof(alphaString));
  alphaString_ptr = alphaString;
  alphaPage = 0;

  /* Draw the background and render the buttons */
  drawFill(ALPHA_COLOR_BACKGROUND);
  alphaRefreshScreen();

  /* Capture results until the 'OK' button is pressed */
  while(1)
  {
    result = alphaHandleTouchEvent();
    if (result == '>') return (char *)&alphaString;
  }
}
Esempio n. 5
0
// Main display loop
void display () 
{
	PERF_PUSH ( "frame" );		// instrument code (does CPU and GPU perf)
	
	glClearColor( 0.5, 0.5, 0.5, 1.0 );
	glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

	// Draw 2D funcs similar to immediate mode, but uses VBO buffers internally
	// Draw order maintained. Transparency allowed.
	// start2D() does dynamic redraw every frame. 
	// static2D() will redraw automatically, can be infrequently updated.
	// Commands:
	//    start2D, static2D, end2D, setview2D
	//    drawLine, drawRect, drawFill, drawText, setText
	//    drawCircle, drawCircleFill, drawCircleDash
	// Future goals (partially implemented):
	//    - Ability to change model/view matrix per start2D/end2D sets
	//    - Add/remove static2D sets

	start2D();			
	int x1, y1, x2, y2;
	float r, g, b;
	for (int n=0; n < numRects; n++ ) {
		x1 = n % 40; y1 = n / 40;
		drawFill ( x1*30+30-14, y1*30+200-14, x1*30+30+14, y1*30+200+14, 0, float(y1)/40.0, float(x1)/40.0, 1 );		
	}
	for (int n=0; n < numCircles; n++ ) {
		x1 = n % 40; y1 = n / 40;
		drawCircleFill ( x1*30+30, y1*30+200, 14, float(x1)/40.0, float(y1)/40.0, 1, 1 );
		drawCircleDash ( x1*30+30, y1*30+200, 14, 1, 1, 1, 1 );
	}
	srand ( 3142 );
	for (int n=0; n < numLines; n++ ) {
		x1 = (rand()*window_width)/RAND_MAX;	y1 = (rand()*window_height)/RAND_MAX;
		x2 = (rand()*window_width)/RAND_MAX;	y2 = (rand()*window_height)/RAND_MAX;
		r = float(rand())/RAND_MAX; g = float(rand())/RAND_MAX; b = float(rand())/RAND_MAX; 
		drawLine ( x1, y1+200, x2, y2+200, r, g, b, 1 );
	}
	end2D ();

	// multiple start/end blocks allowed per frame	
	start2D ();	
	char msg[128];
	for (int n=0; n < numText; n++ ) {		
		x1 = n % 40; y1 = n / 40;
		sprintf ( msg, "%d,%d", x1, y1 );
		drawText ( x1*30+30-12, y1*30+200, msg, 1, 1, 1, 1);
	}
	end2D();

	// DrawGui - required to draw GUI
	drawGui ();	

	// Draw2D - required to draw nv2D
	draw2D ();

	frameTime = PERF_POP ();  // frame

	SwapBuffers( g_hDC );  		
}
Esempio n. 6
0
void renderLCDFrame(void)
{
  // Clear the screen
  drawFill(COLOR_DARKGRAY);

  // Render V references
  fontsDrawString(245,  27, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "3.5V");
  fontsDrawString(244,  26, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "3.5V");
  fontsDrawString(245, 195, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "0.0V");
  fontsDrawString(244, 194, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "0.0V");

  // Div settings
  fontsDrawString( 10, 10, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "~100ms/Div");
  fontsDrawString(  9,  9, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "~100ms/Div");
  fontsDrawString( 95, 10, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "500mV/Div");
  fontsDrawString( 94,  9, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "500mV/Div");

  // Clear the ADC output level just in case
  drawRectangleFilled(175, 5, 250, 18, COLOR_DARKGRAY);

  // Render the channel text
  fontsDrawString( 25, 220, COLOR_BLACK,  &dejaVuSansBold9ptFontInfo, "P1.4 (Analog)");
  fontsDrawString( 24, 219, adcEnabled ? COLOR_YELLOW : COLOR_MEDIUMGRAY, &dejaVuSansBold9ptFontInfo, "P1.4 (Analog)");
  fontsDrawString(135, 220, COLOR_BLACK,  &dejaVuSansBold9ptFontInfo, "P2.0 (Digital)");
  fontsDrawString(134, 219, digEnabled ? COLOR_GREEN : COLOR_MEDIUMGRAY, &dejaVuSansBold9ptFontInfo, "P2.0 (Digital)");

  // ADC Warning
  fontsDrawString(245,  80, COLOR_BLACK, &dejaVuSansBold9ptFontInfo, "Warning:");
  fontsDrawString(244,  79, COLOR_WHITE, &dejaVuSansBold9ptFontInfo, "Warning:");
  fontsDrawString(244,  95, COLOR_WHITE, &dejaVuSans9ptFontInfo, "ADC input");
  fontsDrawString(244, 110, COLOR_WHITE, &dejaVuSans9ptFontInfo, "is not 5.0V");
  fontsDrawString(244, 125, COLOR_WHITE, &dejaVuSans9ptFontInfo, "tolerant!");
}
Esempio n. 7
0
void ofxUIScrollableCanvas::draw()
{
    ofxUIPushStyle();
    
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofxUISetRectMode(OFX_UI_RECTMODE_CORNER);
    ofSetLineWidth(1.0);
    
    drawPadded();
    
    drawPaddedOutline();
    
    drawBack();
    
    drawFill();
    
    drawFillHighlight();
    
    drawOutline();
    
    drawOutlineHighlight();
    
    for(vector<ofxUIWidget *>::reverse_iterator it = widgets.rbegin(); it != widgets.rend(); ++it)
    {
        if((*it)->isVisible() && (*it)->getRect()->rInside(*sRect))
        {
            (*it)->draw();
        }
    }
    
    ofxUIPopStyle();
}
Esempio n. 8
0
static void updateData(int sig) {
    sig=sig;
    
    strncpy(capname, syspath, PATH_MAX);
    strcat(capname, "energy_now");
    FILE* fp = fopen(capname, "r");
    if (fp == NULL) {
        strncpy(capname, syspath, PATH_MAX);
        strcat(capname, "charge_now");
        fp = fopen(capname, "r");
    }

    fscanf(fp, "%d", &currentcap);
    fclose(fp);

    strncpy(capname, syspath, PATH_MAX);
    strcat(capname, "status");
    fp = fopen(capname, "r");
    fscanf(fp, "%s", powerstate);
    fclose(fp);

    snprintf(capname, PATH_MAX, "%.1f %%",
             (float)currentcap/(float)lastfullcap*100.0);
    gtk_status_icon_set_tooltip(ico, capname);

    fillRect(CLEAR, 0, 0, 23, 23);
    drawFrame();
    drawFill((float)currentcap/(float)lastfullcap);
    if (strcmp(powerstate, "Charging")==0) drawFlash();
    
    gtk_status_icon_set_from_pixbuf(ico, pixbuf);
    alarm(2);
}
Esempio n. 9
0
void Dialog::on_label_mouse_Release()
{
    ui->label_3->setText("Release");
    prss = false;
    if (sel_M){
        int xx = sel_x + (x - mv_x),yy = sel_y + (y - mv_y);
        tstRec(xx,yy,sel_w+xx,sel_h+yy);
    }

    if (bt_pres == "mB_sel" && sel_B == false ){
        sel_B = true;
        if (sel_M == false){
            tmp = pix.copy(sel_x,sel_y,sel_w,sel_h);
            QPainter painter(&pix);
            painter.setCompositionMode (QPainter::CompositionMode_Source);
            painter.fillRect(sel_x,sel_y,sel_w,sel_h,colr);
            painter.setCompositionMode (QPainter::CompositionMode_SourceOver);
        }
    }
    sel_M = false;

    if (bt_pres == "mB_fill"){
        drawFill();
    }

    on_pushButton_5_clicked();
}
Esempio n. 10
0
void ofxUIWidget::draw() {
	ofxUIPushStyle();
	
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	drawPadded();
	drawPaddedOutline();
	drawBack();
	drawOutline();
	drawOutlineHighlight();
	drawFill();
	drawFillHighlight();
	
	ofxUIPopStyle();
}
void main_page_draw(struct main_page_ctx * ctx)
{
    drawFill(COLOR_BLUE);
    draw_switch_sensor(ctx);
    draw_switch_ss(ctx);
    draw_switch_rec(ctx);
    drawString(13, 120, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "Resistance");
    drawString(13, 140, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "Voltage");
    drawString(13, 160, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "Current");
    drawString(13, 180, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "Temperature");
    drawString(120, 120, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "[Meg]:");
    drawString(120, 140, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "[V]:");
    drawString(120, 160, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "[A]:");
    drawString(120, 180, COLOR_CYAN, &dejaVuSansBold9ptFontInfo, "[C]:");
    gui_set_update(main_page_events);
}
Esempio n. 12
0
void tsRenderCalibrationScreen(uint16_t x, uint16_t y, uint16_t radius)
{

  drawFill(COLOR_WHITE);
  tsCalibCenterText(TS_LINE1, 50, COLOR_DARKGRAY);
  tsCalibCenterText(TS_LINE2, 65, COLOR_DARKGRAY);
  tsCalibCenterText(TS_LINE3, 80, COLOR_DARKGRAY);
  drawCircle(x, y, radius, COLOR_RED);
  drawCircle(x, y, radius + 2, COLOR_MEDIUMGRAY);

  // Wait for touch
  uint32_t z1, z2;
  z1 = z2 = 0;
  while (z2 < CFG_TFTLCD_TS_THRESHOLD) 
    tsReadZ(&z1, &z2);
}
Esempio n. 13
0
void DrawGame::CircleSprite::draw()
{
  // 显示圆形	
  ofPushMatrix();	 
  ofTranslate(ofPoint(X,Y)); 
  ofRotate(Rot,0,0,1); 
  ofScale(Size,Size,1.0f);   
  drawFill();  
  drawEdge();  
  ofPopMatrix();

  // 显示表情
  ofPushMatrix();
  ofTranslate(ofPoint(X,Y));
  ofRotate(Rot,0,0,1);	 
  ofScale(Size,Size,1.0f);  
  drawFace();
  ofPopMatrix();
}
void ofxUIDropDownList::draw()
{
    ofxUIPushStyle();
    
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    
    drawPadded();
    drawPaddedOutline();
    
    drawBack();
    
    drawOutline();
    drawOutlineHighlight();
    
    drawFill();
    drawFillHighlight();
    
    ofxUIPopStyle();
}
void cmd_clear(uint8_t argc, char **argv)
{
  int32_t col = 0;
  if (argc > 0)
  {
    // Try to convert supplied value to an integer
    getNumber (argv[0], &col);
    
    // Check for invalid values (getNumber may complain about this as well)
    if (col < 0 || col > 0xFFFF)
    {
      printf("Invalid Color%s", CFG_PRINTF_NEWLINE);
      return;
    }
  }

  // Fill the screen
  drawFill((uint16_t)col);
}
Esempio n. 16
0
void welcomeScreen(){
  drawFill(drawRGB24toRGB565(nwazetYellowRed, nwazetYellowGreen, nwazetYellowBlue));
  lcdSetWindow(
    49, 49 + (142 - 1),
    82, 82 + (156 - 1));
  unsigned short imageSize = 44304;
  unsigned short* imagePixel = (unsigned short*) &nwazetLogo[0];
  while(imageSize){
    lcdWriteData(*imagePixel);
    imagePixel++;
    imageSize -= 2;
  }
  unsigned short y = 10;
  unsigned short spaceBetweenLines = 2;
  printString("Touch Display", y);
  y+=verdanabold14ptFontInfo.height+spaceBetweenLines;
  printString("By [nwazet", y);
  y = 295;
  printString("Raspberry Pi v0.1", y);
}
Esempio n. 17
0
char* alphaShowDialogue(void)
{
  char result;

  /* These need to be instantiated here since the width and height of 
     the lcd is retrieved dynamically depending on screen orientation */
  alphaBtnX[0] = ALPHA_COL1_LEFT;
  alphaBtnX[1] = ALPHA_COL2_LEFT;
  alphaBtnX[2] = ALPHA_COL3_LEFT;
  alphaBtnX[3] = ALPHA_COL4_LEFT;
  alphaBtnX[4] = ALPHA_COL5_LEFT;
  alphaBtnY[0] = ALPHA_ROW1_TOP;
  alphaBtnY[1] = ALPHA_ROW2_TOP;
  alphaBtnY[2] = ALPHA_ROW3_TOP;
  alphaBtnY[3] = ALPHA_ROW4_TOP;
  alphaBtnY[4] = ALPHA_ROW5_TOP;
  alphaBtnY[5] = ALPHA_ROW6_TOP;

  /* Initialise the string buffer */
  memset(&alphaString[0], 0, sizeof(alphaString));
  alphaString_ptr = alphaString;
  alphaPage = 0;

  /* Draw the background and render the buttons */
  drawFill(COLOR_WHITE);
  drawRectangleFilled(0, ALPHA_KEYPAD_TOP - ALPHA_BTN_SPACING, lcdGetWidth() - 1, lcdGetHeight() - 1, COLOR_DARKGRAY);
  drawLine(0, (ALPHA_KEYPAD_TOP - ALPHA_BTN_SPACING) + 1, lcdGetWidth() - 1, (ALPHA_KEYPAD_TOP - ALPHA_BTN_SPACING) + 1, COLOR_LIGHTGRAY);
  alphaRefreshScreen();

  /* Capture results until the 'OK' button is pressed */
  while(1)
  {
    result = alphaHandleTouchEvent();
    if (result == '>') return (char *)&alphaString;
  }
}
Esempio n. 18
0
void ControlBase::draw(){
	drawFill();
	drawOutline();
	drawText();
}
Esempio n. 19
0
void drawOverlay ()
{
	Vector4DF clr;

	Matrix4F proj, view, model;
	proj.Scale ( 2.0/window_width, -2.0/window_height, 1 );		
	model.Translate ( cam.getToPos().x, cam.getToPos().y, 1 );
	view.Scale ( cam.getToPos().z, 1, 1 );
	view *= model;
	model.Identity ();

	//----- 2D Drawing (visualizer space)	
	setview2D ( model.GetDataF(), view.GetDataF(), proj.GetDataF() );
	setorder2D ( false, 1 );
	updatestatic2D ( 0 );		// update model/view/proj matrices of each static draw layer
	updatestatic2D ( 1 );
	updatestatic2D ( 2 );
	updatestatic2D ( 3 );
		
	// Selector Bar
	start2D ();					
	  drawRect ( mSelectID*10, 0, mSelectID*10+10, NUM_BIN*25, 1,1,1,1 );

	// Same-State Highlights (yellow)
	int minE = (((0-window_width/2.0)/cam.getToPos().z) - cam.getToPos().x) / 10;
	int maxE = (((window_width - window_width/2.0)/cam.getToPos().z) - cam.getToPos().x) / 10;
	minE = ( minE < 0 ) ? 0 : minE;
	maxE = ( maxE >= mEvents.size() ) ? mEvents.size() : maxE;
	for (int n=0; n < mEvents.size(); n++ ) {
		if ( mEvents[n].bin_id[mSelectBin] == mEvents[mSelectID].bin_id[mSelectBin] && n > minE && n < maxE ) {
			drawRect ( n*10, mSelectBin*25, n*10+10, mSelectBin*25+24, 1,1,0,1 );
			drawRect ( n*10+1, mSelectBin*25+1, n*10+9, mSelectBin*25+23, 1,1,0,1 );
		}
	}
	end2D ();
	
	//----- 2D Drawing (screen space)	
	setview2D ( window_width, window_height );	// change to screen space
	setorder2D ( true, -0.00001 );
	
	start2D ();					// dynamic draw
	int panel_width = 200;
	float xoff = window_width - panel_width;
	float yoff = cam.getToPos().y + (window_height/2);

	// Left panel - Bin Text 
	char name[128];
	char msg[1024];

	int frame = mEvents[mSelectID].frame; 
	frame = (frame < 0 || frame >= mFrames.size() ) ? 0 : frame;
	Frame& f = mFrames[ frame ];

	drawFill ( 0, yoff, +panel_width, yoff + NUM_BIN*25+250, 0.15,0.15,0.2,0.75 );
	
	drawText ( 10, yoff-85, "Frame #:", 1,1,1,1 );
	drawText ( 10, yoff-70, "Frame Draws:", 1,1,1,1 );
	drawText ( 10, yoff-55, "Frame Prims:", 1,1,1,1 );
	drawText ( 10, yoff-40, "Frame Transfer:", 1,1,1,1 );	
	drawText ( 10, yoff-20, "Frame States:", 1,1,1,1 );	
	sprintf ( msg, "%d", frame );					drawText ( 100, yoff - 85, msg, 1,1,1,1 );	
	sprintf ( msg, "%d", f.totalDraw );				drawText ( 100, yoff - 70, msg, 1,1,1,1 );
	sprintf ( msg, "%d", f.totalPrim );				drawText ( 100, yoff - 55, msg, 1,1,1,1 );
	sprintf ( msg, "%d bytes", f.totalTransfer );	drawText ( 100, yoff - 40, msg, 1,1,1,1 );

	setText ( 0.8, 0 );
	drawText ( 100, yoff - 20, "Modify", 1,0,0,1 );
	drawText ( 125, yoff - 10, "Switch", 1,0.5,0,1 );
	drawText ( 150, yoff - 20, "Reuse", 0,1,0,1 );
	drawText ( 175, yoff - 10, "Unique", 1,1,1,1 );
	drawTri ( 100, yoff-10, 100+10, yoff-10, 100, yoff, 1, 0,0, 1);
	drawTri ( 125, yoff-10, 125+10, yoff-10, 125, yoff, 1,.5,0, 1);
	drawTri ( 150, yoff-10, 150+10, yoff-10, 150, yoff, 0, 1,0, 1);
	setText ( 1.0, -0.5 );

	for (int b=0; b < NUM_BIN; b++ ) {
		strncpy ( name, binNames[b].c_str(), 128 );
		drawText ( 8, yoff + b*25+12, name, 1,1,1,1 );

		clr.x = float(f.binChange[b]) / f.totalDraw;	if ( clr.x > 1 ) clr.x = 1;
		sprintf ( msg, "%d", f.binChange[b] );	drawText ( 100, yoff + b*25+12-2, msg, clr.x*0.7+0.3, 0,0,1 );	
		
		clr.x = float(f.binSwitch[b]) / f.totalDraw;	if ( clr.x > 1 ) clr.x= 1;
		sprintf ( msg, "%d", f.binSwitch[b] );	drawText ( 125, yoff + b*25+12+2, msg, clr.x*0.7+0.3,clr.x*.4+0.2,0,1 );
		
		clr.x = float(f.binReuse[b]) / f.totalDraw; 	if ( clr.x > 1 ) clr.x= 1;
		sprintf ( msg, "%d", f.binReuse[b] );	drawText ( 150, yoff + b*25+12-2, msg, 0, clr.x*0.7+0.3, 0,1 );

		sprintf ( msg, "%d", f.binUnique[b] );	drawText ( 175, yoff + b*25+12+2, msg, .7, .7, .7,1 );
	}

	int ys = NUM_BIN*25;
	float ypos; 
	sprintf ( msg, "%d", mMaxPrim/4 ); 
	drawLine ( 0, yoff + ys+25, 200, yoff+ys+25, .6, .6, .6, 1);	
	drawText ( 10, yoff+ys+25+15, msg, .8,.8,.8,1 );
	drawText ( 10, yoff + ys+80, "# Prims", 1, 1, 1, 1 );
	drawText ( 10, yoff+ys+125, "0", .8,.8,.8,1 );
	drawLine ( 0, yoff + ys+125, 200, yoff+ys+125, .6, .6, .6, 1);
	ypos = mEvents[ mSelectID ].bin_id[ BIN_DRAW ] * 400 / mMaxPrim;		// prim count	
	clr = getClr ( mEvents[ mSelectID ].bin_id[9] + 9*16384 );
	if ( ypos > 100 ) ypos = 100;			
	sprintf ( msg, "%d", mEvents[ mSelectID ].bin_id[BIN_DRAW] );
	drawLine ( 150, yoff+ys+(125-ypos), 200, yoff+ys+(125-ypos), clr.x,clr.y,clr.z,1 );
	drawText ( 150, yoff+ys+(125-ypos), msg, clr.x,clr.y,clr.z,1 );

	sprintf ( msg, "%d", mMaxSize ); 
	drawLine ( 0, yoff + ys+150, 200, yoff+ys+150, .6, .6, .6, 1);
	drawText ( 10, yoff+ys+150+15, msg, .8,.8,.8,1 );
	drawText ( 10, yoff + ys+200, "Transfer (bytes)" , 1, 1, 1, 1);
	drawText ( 10, yoff+ys+250, "0", .8,.8,.8,1 );
	drawLine ( 0, yoff + ys+250, 200, yoff+ys+250, .6, .6, .6, 1);
	ypos = mEvents[ mSelectID ].bin_size [ BIN_SIZE ] * 100 / mMaxSize;		// prim count
	if ( ypos > 100 ) ypos = 100;	
	sprintf ( msg, "%d", mEvents[ mSelectID ].bin_size [BIN_SIZE] );
	drawLine ( 150, yoff+ys+(250-ypos), 200, yoff+ys+(250-ypos), 1,1,1,1 );
	drawText ( 150, yoff+ys+(250-ypos), msg, 1,1,1,1 );
		
	// Right panel - Call Text		
	drawFill ( xoff, yoff, xoff + panel_width, yoff + NUM_BIN*25+250, 0.15,0.15,0.2,0.75 );	
	int cid;
	glColor3f ( 1, 1, 1);
	
	for (int c = 0; c < mEvents[ mSelectID ].call_num; c++ ) {	
		cid = mEvents[ mSelectID ].call_start + c;		
		clr = getClr ( mCalls[cid].val_id + mCalls[cid].bin_id*16384 );
		clr.w = 1;
		drawFill ( xoff+100, yoff + c*15, xoff+125, yoff+c*15+13, clr.x, clr.y, clr.z, clr.w );

		sprintf ( msg, "%s", mCalls[cid].name.c_str() );  
		drawText ( xoff+5, yoff + c*15+15, msg, 1,1,1,1 );

		sprintf ( msg, "%02d  %d %d", mCalls[cid].bin_id, mCalls[cid].size, mCalls[cid].val_id );
		drawText ( xoff+130, yoff + c*15+15, msg, 1,1,1,1 );
	}
	end2D ();
	
	

	#ifdef USE_DX
		g_pContext->OMSetDepthStencilState( g_pDepthStencilState, 1 );
	#endif
}
Esempio n. 20
0
void drawMatrix ()
{
	Vector3DF id_clr;
	float ypos, yposl;
	int b, num = (int) mEvents.size();	

	Matrix4F proj, view, model;
	proj.Scale ( 2.0/window_width, -2.0/window_height, 1 );		
	model.Translate ( cam.getToPos().x, cam.getToPos().y, 1 );
	view.Scale ( cam.getToPos().z, 1, 1 );
	view *= model;
	model.Identity ();

	//----- 2D Drawing (visualizer space)		
	setview2D ( model.GetDataF(), view.GetDataF(), proj.GetDataF() );
	setorder2D ( false, 1 );

	// Event ID	bars	
	static2D ();	
	int fl = -1;
	char msg[100];
	for (int n=0; n < num; n++ ) {
		if ( mEvents[n].frame != fl ) {
			sprintf ( msg, "frame %d", mEvents[n].frame ); drawText ( n*10, -2, msg, 1,1,1,1 );
		}
		for (b=0; b < NUM_BIN; b++) {
			if ( mEvents[n].bin_id[b] == -1  ) {
				id_clr.Set ( 1, 1, 1 );
			} else if ( mEvents[n].bin_change[b] == 0 ) {
				id_clr.Set ( .2, .2, .2 );
			} else {
				id_clr = getClr ( mEvents[n].bin_id[b] + b*16384 );
			}
			drawFill ( n*10.0, b*25, n*10+10.0, b*25+24, id_clr.x, id_clr.y, id_clr.z, 1 );						
		}
		fl = mEvents[n].frame;
	}
	end2D ();

	// Change State bars
	static2D ();
	for (int n=0; n < num; n++ ) {
		for (b=0; b < NUM_BIN; b++) {
			if ( mEvents[n].bin_id[b] != -1 ) {
				switch ( mEvents[n].bin_change[b] ) {
				case BIN_NOTUSED:		id_clr.Set ( .2, .2, .2 );	break;		
				case BIN_CREATE:		id_clr.Set ( 1, 0, 0 );		break;
				case BIN_CHANGE:		id_clr.Set ( 1, 0, 0 );		break;
				case BIN_SWITCH:		id_clr.Set ( 1, .5, 0 );	break;
				case BIN_REUSE:		id_clr.Set ( 0, 1, 0 );		break;
				};				
				drawTri ( n*10, b*25, n*10+10, b*25, n*10, b*25+10, id_clr.x, id_clr.y, id_clr.z, 1 );
			}
		}
	}
	end2D ();

	int ys = NUM_BIN*25;
		
	// Prim count bars
	static2D();
	b = BIN_DRAW;
	for (int n=0; n < num; n++ ) {
		id_clr = getClr ( mEvents[n].bin_id[9] + 9*16384 );	
		ypos = mEvents[n].bin_id[ b ] * 400 / mMaxPrim;		// prim count
		if ( ypos > 100 ) ypos = 100;		
		drawFill ( n*10, ys+(125-ypos), n*10+10, ys+125, id_clr.x, id_clr.y, id_clr.z, 1 );
	}
	end2D ();
	
	// Mem transfer line
	static2D();
	yposl = 0;
	b = BIN_SIZE;
	for (int n=0; n < num; n++ ) {
		id_clr.Set(1,1,1);		
		ypos = mEvents[n].bin_size[ b ] * 100 / mMaxSize;		// size (bytes)
		if ( ypos > 100 ) ypos = 100;		
		drawLine ( n*10+5, ys+(250-ypos), n*10-5, ys+(250-yposl), 1, 1, 1, 1 );
		yposl = ypos;
	}
	drawLine ( 5, ys+250, num*10-5, ys+250, .5, .5, .5, 1 );
	end2D ();
}
Esempio n. 21
0
void tsCalibrate(void)
{
  lcdOrientation_t orientation;
  uint16_t right2, top2, left2, bottom2;
  bool passed = false;

  // Determine screen orientation before starting calibration
  orientation = lcdGetOrientation();

  /* -------------- Welcome Screen --------------- */
  tsRenderCalibrationScreen(lcdGetWidth() / 2, lcdGetHeight() / 2, 5);

  // Delay to avoid multiple touch events
  systickDelay(250);

  /* -------------- CALIBRATE TOP-LEFT --------------- */
  passed = false;
  while (!passed)
  {
    // Read X/Y depending on screen orientation
    tsRenderCalibrationScreen(3, 3, 5);
    _calibration.offsetLeft = orientation == LCD_ORIENTATION_LANDSCAPE ? tsReadY() : tsReadX();
    _calibration.offsetTop = orientation == LCD_ORIENTATION_LANDSCAPE ? tsReadX() : tsReadY();
  
    // Make sure values are in range
    if (_calibration.offsetLeft < TS_CALIBRATION_OUTOFRANGE && _calibration.offsetTop < TS_CALIBRATION_OUTOFRANGE)
      passed = true;
  }

  // Delay to avoid multiple touch events
  systickDelay(250);

  /* -------------- CALIBRATE BOTTOM-RIGHT  --------------- */
  passed = false;
  while (!passed)
  {
    tsRenderCalibrationScreen(lcdGetWidth() - 4, lcdGetHeight() - 4, 5);
  
    // Read X/Y depending on screen orientation
    _calibration.offsetRight = orientation == LCD_ORIENTATION_LANDSCAPE ? TS_ADC_LIMIT - tsReadY() : TS_ADC_LIMIT - tsReadX();
    _calibration.offsetBottom = orientation == LCD_ORIENTATION_LANDSCAPE ? TS_ADC_LIMIT - tsReadX() : TS_ADC_LIMIT - tsReadY();
  
    // Redo test if value is out of range
    if (_calibration.offsetRight < TS_CALIBRATION_OUTOFRANGE && _calibration.offsetBottom < TS_CALIBRATION_OUTOFRANGE)
      passed = true;
  }

  // Delay to avoid multiple touch events
  systickDelay(250);

  /* -------------- CALIBRATE TOP-RIGHT  --------------- */
  passed = false;
  while (!passed)
  {
    tsRenderCalibrationScreen(lcdGetWidth() - 4, 3, 5);
  
    if (orientation == LCD_ORIENTATION_LANDSCAPE)
    {
      right2 = TS_ADC_LIMIT - tsReadY();
      top2 = tsReadX();
    }
    else
    {
      right2 = tsReadX();
      top2 = TS_ADC_LIMIT - tsReadY();
    }
  
    // Redo test if value is out of range
    if (right2 < TS_CALIBRATION_OUTOFRANGE && top2 < TS_CALIBRATION_OUTOFRANGE)
      passed = true;  
  }

  // Average readings
  _calibration.offsetRight = (_calibration.offsetRight + right2) / 2;
  _calibration.offsetTop = (_calibration.offsetTop + top2) / 2;

  // Delay to avoid multiple touch events
  systickDelay(250);

  /* -------------- CALIBRATE BOTTOM-LEFT --------------- */
  passed = false;
  while (!passed)
  {
    tsRenderCalibrationScreen(3, lcdGetHeight() - 4, 5);
  
    if (orientation == LCD_ORIENTATION_LANDSCAPE)
    {
      left2 = tsReadY();
      bottom2 = TS_ADC_LIMIT - tsReadX();
    }
    else
    {
      left2 = TS_ADC_LIMIT - tsReadX();
      bottom2 = tsReadY();
    }
  
    // Redo test if value is out of range
    if (left2 < TS_CALIBRATION_OUTOFRANGE && bottom2 < TS_CALIBRATION_OUTOFRANGE)
      passed = true;
  }

  // Average readings
  _calibration.offsetLeft = (_calibration.offsetLeft + left2) / 2;
  _calibration.offsetBottom = (_calibration.offsetBottom + bottom2) / 2;

  // Delay to avoid multiple touch events
  systickDelay(250);

  _calibration.divisorX = ((TS_ADC_LIMIT - (_calibration.offsetLeft + _calibration.offsetRight)) * 100) / lcdGetWidth();
  _calibration.divisorY = ((TS_ADC_LIMIT - (_calibration.offsetTop + _calibration.offsetBottom)) * 100) / lcdGetHeight();

  /* -------------- Persist Data --------------- */
  // Persist data to EEPROM
  eepromWriteU16(CFG_EEPROM_TOUCHSCREEN_OFFSET_LEFT, _calibration.offsetLeft);
  eepromWriteU16(CFG_EEPROM_TOUCHSCREEN_OFFSET_RIGHT, _calibration.offsetRight);
  eepromWriteU16(CFG_EEPROM_TOUCHSCREEN_OFFSET_TOP, _calibration.offsetTop);
  eepromWriteU16(CFG_EEPROM_TOUCHSCREEN_OFFSET_BOT, _calibration.offsetBottom);
  eepromWriteU16(CFG_EEPROM_TOUCHSCREEN_OFFSET_DIVX, _calibration.divisorX);
  eepromWriteU16(CFG_EEPROM_TOUCHSCREEN_OFFSET_DIVY, _calibration.divisorY);
  eepromWriteU8(CFG_EEPROM_TOUCHSCREEN_CALIBRATED, 1);

  // Clear the screen
  drawFill(COLOR_BLACK);
}