Esempio n. 1
0
void Show_TMenuTheme(void) {
    SPILCD_Clear_Lim(0,100,0,120,WHITE);

    DRAW_LINE(0,120,100,120,RED);
    DRAW_LINE(100,0,100,120,RED);
    DRAW_LINE(0,0,0,120,RED);
}
Esempio n. 2
0
// 0 for false, 1 for true
int confirm(const char *label) {
	int ret = -1;
	char str[64];

	DECL_LINE(yesbtn);
	DECL_LINE(nobtn);

	strcpy(sbstr, "confirm action");

	if (label == NULL)
		strcpy(str, "are you sure?");
	else
		sprintf(str, "are you sure you want to %s?", label);

	clear_screen();

	START_LIST(16, 96, 416, 0xFF00FF00, 0xFF0000FF, 0xFFC0C0C0);

	text(str, 16,16, 2,2, 0xFFC0C0C0, 0x00000000);

	DRAW_LINE(yesbtn, "yes", "perform the action");
	DRAW_LINE(nobtn, "no", "cancel the action and return to the previous screen");

	while (ret == -1) {
		update_screen();
		input_read();

		if (BTN_CLICKED(yesbtn)) ret = 1;
		else if (BTN_CLICKED(nobtn)) ret = 0;
	}
	return ret;
}
Esempio n. 3
0
char * select_lv_set(void) {
	int *by, pagenum = 1, npages;
	int n, ret = 0;
	char *selected_set = NULL;

	DECL_LINE(backbtn);
	DECL_LINE(prevpage);
	DECL_LINE(nextpage);

	strcpy(sbstr, "select volume set");

	update_lv_lists();
	n = lv_set_count();
	by = malloc(n * sizeof(int));
	npages = 1 + n / PERPAGE;
	
	do {
		clear_screen();
		START_LIST(8, 32, 352, 0xFF404040, 0xFF808080, 0xFFC0C0C0)

		DRAW_LINE(backbtn, "back", "return to previous menu without making a selection"); 
		if (pagenum > 1) {
			DRAW_LINE(prevpage, "previous page", "not all volume sets are shown"); 
		}
		for (int i = PERPAGE * (pagenum - 1); i < n; ++i) {
			if (i > pagenum * PERPAGE) break;
		
			USECOLR = !USECOLR; 
			CURCOLR = USECOLR ? BG1COLR : BG2COLR; 
			current_y += 48; 
			by[i] =  current_y; 
			fill_rect(0, by[i], 1024, 44, CURCOLR);
			text(lv_set_name(i), col1_x, by[i] + 8, 2, 2, 0xFFFFFFFF, CURCOLR);
		}
		if (pagenum < npages) {
			DRAW_LINE(nextpage, "next page", "not all volume sets are shown");
		}

		update_screen();
		input_read();
		if (BTN_CLICKED(backbtn)) ret = 2;

		for (int i = PERPAGE * (pagenum - 1); i < n; ++i)
			if (was_clicked(0, by[i], 1024, 44)) {
				if (i > pagenum * PERPAGE) break;
				selected_set = strdup(lv_set_name(i));
				ret = 1;				
			}
		if (BTN_CLICKED(prevpage)) --pagenum;
		else if (BTN_CLICKED(nextpage)) ++pagenum;
	} while (!ret);

	free(by);

	return selected_set;
}
Esempio n. 4
0
void Show_MenuTheme(void) {
    for(a=0; a<14; a++) {
        DRAW_han(464-32*a,300,Theme[a]);
    }
    for(b=0; b<3; b++) {
        DRAW_NUM1(384-16*b,269,MSP[b]);
    }
    DRAW_NUM1(384-16*3,269,num[4]);
    DRAW_NUM1(384-16*4,269,num[3]);
    DRAW_NUM1(384-16*5,269,num[0]);

    DRAW_LINE(480,260,0,260,RED);

    DRAW_LINE(480,45,0,45,RED);
}
Esempio n. 5
0
static PyObject *
curve_draw_unselected(SKCurveObject * self, PyObject * args)
{
    PyObject * draw_bezier;
    PyObject * draw_line;
    PyObject * result;
    CurveSegment * segment = self->segments + 1;
    int i;

    if (!PyArg_ParseTuple(args, "OO", &draw_bezier, &draw_line))
	return NULL;

    for (i = 1; i < self->len; i++, segment++)
    {
	if (segment->type == CurveLine)
	{
	    DRAW_LINE(segment[-1].x, segment[-1].y, segment->x, segment->y);
	}
	else if (!segment[-1].selected && !segment->selected)
	{
	    DRAW_BEZIER(segment[-1].x, segment[-1].y, segment->x1, segment->y1,
			segment->x2, segment->y2, segment->x, segment->y);
	}
    }

    Py_INCREF(Py_None);
    return Py_None;
}
Esempio n. 6
0
static PyObject *
creator_draw_not_last(SKCurveObject * curve, PyObject * args)
{
    PyObject * result;
    CurveSegment * segments = curve->segments;
    int i;
    PyObject * draw_bezier;
    PyObject * draw_line;

    if (!PyArg_ParseTuple(args, "OO", &draw_bezier, &draw_line))
	return NULL;

    for (i = 1; i < SKCurve_LENGTH(curve) - 1; i++)
    {
	if (segments[i].type == CurveBezier)
	{
	    DRAW_BEZIER(segments[i - 1].x, segments[i - 1].y,
			segments[i].x1, segments[i].y1,
			segments[i].x2, segments[i].y2,
			segments[i].x, segments[i].y);
	}
	else if (segments[i].type == CurveLine)
	{
	    DRAW_LINE(segments[i - 1].x, segments[i - 1].y,
		      segments[i].x, segments[i].y);
	}
    }

    Py_INCREF(Py_None);
    return Py_None;
}
Esempio n. 7
0
void Show_ALLTHEME(void) {
    DRAW_Heart(432,15,0);
    DRAW_Heart(432,280,1);
    DRAW_han(420,310,HRhan[0]);
    DRAW_han(380,310,HRhan[1]);
    DRAW_han(340,310,HRhan[2]);
    DRAW_han(300,310,HRhan[3]);
    DRAW_Other(320,16,2);
    DRAW_Other(250,274,2);
    DRAW_LINE(15,60,465,60,RED);
}
void clTabRendererCurved::DrawBottomRect(
    clTabInfo::Ptr_t activeTab, const wxRect& clientRect, wxDC& dc, const clTabColours& colours, size_t style)
{
#ifdef __WXOSX__
    if(!IS_VERTICAL_TABS(style)) {
        wxPoint pt1, pt2;
        dc.SetPen(colours.activeTabBgColour);
        if(style & kNotebook_BottomTabs) {
            // bottom tabs
            pt1 = clientRect.GetTopLeft();
            pt2 = clientRect.GetTopRight();
            DRAW_LINE(pt1, pt2);

        } else {
            // Top tabs
            pt1 = clientRect.GetBottomLeft();
            pt2 = clientRect.GetBottomRight();
            pt1.y -= 1;
            pt2.y -= 1;
            DRAW_LINE(pt1, pt2);
        }
    }
#else
    if(!IS_VERTICAL_TABS(style)) {
        wxPoint pt1, pt2;
        dc.SetPen(colours.activeTabPenColour);
        if(style & kNotebook_BottomTabs) {
            // bottom tabs
            pt1 = clientRect.GetTopLeft();
            pt2 = clientRect.GetTopRight();
            DRAW_LINE(pt1, pt2);

        } else {
            // Top tabs
            pt1 = clientRect.GetBottomLeft();
            pt2 = clientRect.GetBottomRight();
            DRAW_LINE(pt1, pt2);
        }
    }
#endif
}
Esempio n. 9
0
static PyObject *
curve_draw_dragged_nodes(SKCurveObject * self, PyObject * args)
{
    PyObject * draw_bezier;
    PyObject * draw_line;
    PyObject * result;
    SKPointObject * offset;
    CurveSegment * segment = self->segments + 1;
    int partially;
    int i;

    if (!PyArg_ParseTuple(args, "O!iOO", &SKPointType, &offset, &partially,
			  &draw_bezier, &draw_line))
	return NULL;

    for (i = 1; i < self->len; i++, segment++)
    {
	if (segment[-1].selected || segment->selected || !partially)
	{
	    double nx = segment[-1].x;
	    double ny = segment[-1].y;
	    CurveSegment seg = *segment;

	    if (segment[-1].selected)
	    {
		nx += offset->x;
		ny += offset->y;
		seg.x1 += offset->x;
		seg.y1 += offset->y;
	    }
	    if (segment->selected)
	    {
		seg.x += offset->x;
		seg.y += offset->y;
		seg.x2 += offset->x;
		seg.y2 += offset->y;
	    }

	    if (segment->type == CurveBezier)
	    {
		DRAW_BEZIER(nx, ny, seg.x1, seg.y1, seg.x2, seg.y2,
			    seg.x, seg.y);
	    }
	    else
	    {
		DRAW_LINE(nx, ny, seg.x, seg.y);
	    }
	}
    }

    Py_INCREF(Py_None);
    return Py_None;
}
Esempio n. 10
0
static __inline void TAG(draw_line)( GLcontext *ctx,
				     TNL_VERTEX *v0,
				     TNL_VERTEX *v1 )
{
   LOCAL_VARS;
   GLubyte ormask = (v0->mask | v1->mask);

   if ( !ormask ) {
      DRAW_LINE( v0, v1 );
   } else if ( !(v0->mask & v1->mask) ) {
      TAG(clip_draw_line)( ctx, v0, v1, ormask );
   }
}
Esempio n. 11
0
void drawbpletter(){
      //Show_ALLTHEME();
      DRAW_Other(450,280,11); //B
      DRAW_Other(430,280,12); //P
      DRAW_han(420,310,BPhan[0]);
      DRAW_han(380,310,BPhan[1]);
      DRAW_han(340,310,BPhan[2]);
      DRAW_han(300,310,BPhan[3]);
      DRAW_Other(250,274,2);
      DRAW_LINE(15,60,465,60,RED);

      //收缩压
      DRAW_han(460,48,BPhan[4]);
      DRAW_han(428,48,BPhan[5]);
      DRAW_han(396,48,BPhan[6]);
      DRAW_Other(348,20,2); //:
      //舒张压
      DRAW_han(228,48,BPhan[7]);
      DRAW_han(196,48,BPhan[8]);
      DRAW_han(164,48,BPhan[9]);
      DRAW_Other(116,20,2); //:

  }
Esempio n. 12
0
/* Clip a line against the viewport and user clip planes.
 */
static void TAG(clip_draw_line)( GLcontext *ctx,
				 TNL_VERTEX *I,
				 TNL_VERTEX *J,
				 GLuint mask )
{
   LOCAL_VARS;
   GET_INTERP_FUNC;
   TNL_VERTEX tmp[MAX_CLIPPED_VERTICES];
   TNL_VERTEX *verts = tmp;
   TNL_VERTEX *pv = J;

   LINE_CLIP( CLIP_RIGHT_BIT,  -1,  0,  0, 1 );
   LINE_CLIP( CLIP_LEFT_BIT,    1,  0,  0, 1 );
   LINE_CLIP( CLIP_TOP_BIT,     0, -1,  0, 1 );
   LINE_CLIP( CLIP_BOTTOM_BIT,  0,  1,  0, 1 );
   LINE_CLIP( CLIP_FAR_BIT,     0,  0, -1, 1 );
   LINE_CLIP( CLIP_NEAR_BIT,    0,  0,  1, 1 );

   if ((ctx->_TriangleCaps & DD_FLATSHADE) && J != pv)
      COPY_PV( ctx, J, pv );

   DRAW_LINE( I, J );
}
Esempio n. 13
0
void ImageDialog::ShowNetClassified(char * netClassified,QImage* image)
{
	OBJECT_TO_DRAW_CLEAR();
	int h=0;
	int w=0;
	while (h<FULL_IMAGE_HEIGHT)
	{
		w=0;
		while (w<FULL_IMAGE_WIDTH)
		{
			int temp = netClassified[h*FULL_IMAGE_WIDTH+w];
			image->setPixel(w,h,LookupRgb(temp));
			w++;
		}
		h++;
	}

	//netVisionInterface netResult;

	memcpy(visionResult,netClassified+IMAGE_SIZE,sizeof(netVisionInterface));
	//std::cout<<"in ImageDialog, is the ball in the image ? "<<(int)netResult.ballSeen<<std::endl;
	//std::cout<<"in ImageDialog, the rightGoalB  is  "<<(float)netResult.rightGoalB<<std::endl;
    emit ReceiveResultOk((char*)visionResult);
	std::cout<<"in ImageDialog,  netVisionInterface is "<<sizeof(netVisionInterface)<<std::endl;//is 56

		CameraMatrix camMax;
		RotationMatrix rot(-double(visionResult->row)/1000000000,-double(visionResult->pitch)/1000000000,-double(visionResult->yaw)/1000000000);
		camMax.translation.x = double(visionResult->camX)/100000;
		camMax.translation.y = double(visionResult->camY)/100000;
		camMax.translation.z = double(visionResult->camZ)/100000;
		camMax.rotation = rot;
		DRAW_LINE(visionResult->horizonStartX,visionResult->horizonStartY,
			visionResult->horizonEndX,visionResult->horizonEndY,
			3,Drawings::ps_SolidLine, Drawings::darkBlue);
		const Vector3<double> fieldpoint1=Vector3<double>(4185.0,2000.0,0.0);//(4200.0,2000.0,0.0);//The 1th
		Vector2<int> fieldpoint1_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint1,camMax,fieldpoint1_pointInImage);
		DRAW_BIG_DOT(fieldpoint1_pointInImage.x,fieldpoint1_pointInImage.y,Drawings::black,Drawings::red);

		const Vector3<double> fieldpoint2=Vector3<double>(4185.0,1115.0,0.0);//(4200.0,1100.0,0.0);//The 2th
		Vector2<int> fieldpoint2_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint2,camMax,fieldpoint2_pointInImage);
		DRAW_BIG_DOT(fieldpoint2_pointInImage.x,fieldpoint2_pointInImage.y,Drawings::black,Drawings::red);

		const Vector3<double> fieldpoint3=Vector3<double>(4185.0,-1065.0,0.0);//(4200.0,-1100.0,0.0);//The 3th
		Vector2<int> fieldpoint3_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint3,camMax,fieldpoint3_pointInImage);
		DRAW_BIG_DOT(fieldpoint3_pointInImage.x,fieldpoint3_pointInImage.y,Drawings::black,Drawings::red);

		const Vector3<double> fieldpoint4=Vector3<double>(4185.0,-1975.0,0.0);//(4200.0,-2000.0,0.0);//The 4th
		Vector2<int> fieldpoint4_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint4,camMax,fieldpoint4_pointInImage);
		DRAW_BIG_DOT(fieldpoint4_pointInImage.x,fieldpoint4_pointInImage.y,Drawings::black,Drawings::red);

		const Vector3<double> fieldpoint5=Vector3<double>(3585.0,1115.0,0.0);//(3600.0,1100.0,0.0);//The 5th
		Vector2<int> fieldpoint5_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint5,camMax,fieldpoint5_pointInImage);
		DRAW_BIG_DOT(fieldpoint5_pointInImage.x,fieldpoint5_pointInImage.y,Drawings::black,Drawings::red);

		const Vector3<double> fieldpoint6=Vector3<double>(3585.0,-1065.0,0.0);//(3600.0,-1100.0,0.0);//The 6th
		Vector2<int> fieldpoint6_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint6,camMax,fieldpoint6_pointInImage);
		DRAW_BIG_DOT(fieldpoint6_pointInImage.x,fieldpoint6_pointInImage.y,Drawings::black,Drawings::red);

		const Vector3<double> fieldpoint7=Vector3<double>(2400.0,0.0,0.0);//The 7th
		Vector2<int> fieldpoint7_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint7,camMax,fieldpoint7_pointInImage);
		DRAW_BIG_DOT(fieldpoint7_pointInImage.x,fieldpoint7_pointInImage.y,Drawings::black,Drawings::red);

		const Vector3<double> fieldpoint8=Vector3<double>(1175.0,0.0,0.0);//(1200.0,0.0,0.0);//The 8th
		Vector2<int> fieldpoint8_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint8,camMax,fieldpoint8_pointInImage);
		DRAW_BIG_DOT(fieldpoint8_pointInImage.x,fieldpoint8_pointInImage.y,Drawings::black,Drawings::red);

		const Vector3<double> fieldpoint9=Vector3<double>(0.0,2000.0,0.0); //9th
		Vector2<int> fieldpoint9_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint9,camMax,fieldpoint9_pointInImage);
		DRAW_BIG_DOT(fieldpoint9_pointInImage.x,fieldpoint9_pointInImage.y,Drawings::black,Drawings::red);

		const Vector3<double> fieldpoint10=Vector3<double>(0.0,-1975.0,0.0); //10th
		Vector2<int> fieldpoint10_pointInImage(0,0);
		Geometry::calculatePointInImage(fieldpoint10,camMax,fieldpoint10_pointInImage);
		DRAW_BIG_DOT(fieldpoint10_pointInImage.x,fieldpoint10_pointInImage.y,Drawings::black,Drawings::red);


		DRAW_LINE(fieldpoint1_pointInImage.x,fieldpoint1_pointInImage.y,fieldpoint2_pointInImage.x,fieldpoint2_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black);
		DRAW_LINE(fieldpoint2_pointInImage.x,fieldpoint2_pointInImage.y,fieldpoint3_pointInImage.x,fieldpoint3_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black);
		DRAW_LINE(fieldpoint3_pointInImage.x,fieldpoint3_pointInImage.y,fieldpoint4_pointInImage.x,fieldpoint4_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black);
		DRAW_LINE(fieldpoint2_pointInImage.x,fieldpoint2_pointInImage.y,fieldpoint5_pointInImage.x,fieldpoint5_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black);
		DRAW_LINE(fieldpoint3_pointInImage.x,fieldpoint3_pointInImage.y,fieldpoint6_pointInImage.x,fieldpoint6_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black);
		DRAW_LINE(fieldpoint5_pointInImage.x,fieldpoint5_pointInImage.y,fieldpoint6_pointInImage.x,fieldpoint6_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black);
		DRAW_LINE(fieldpoint7_pointInImage.x,fieldpoint7_pointInImage.y,fieldpoint8_pointInImage.x,fieldpoint8_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black);
		DRAW_LINE(fieldpoint1_pointInImage.x,fieldpoint1_pointInImage.y,fieldpoint9_pointInImage.x,fieldpoint9_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black);
		DRAW_LINE(fieldpoint4_pointInImage.x,fieldpoint4_pointInImage.y,fieldpoint10_pointInImage.x,fieldpoint10_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black);
		DRAW_LINE(fieldpoint9_pointInImage.x,fieldpoint9_pointInImage.y,fieldpoint10_pointInImage.x,fieldpoint10_pointInImage.y,1,Drawings::ps_SolidLine,Drawings::black); 


	
	DrawVisualObjects(image);
	update();
	show();
	raise();
	activateWindow();
}
Esempio n. 14
0
__interrupt void ADC12ISR (void)
{


	switch(__even_in_range(ADC12IV,36))
	{
	case  0: break;                           	// Vector  0:  No interrupt
  	case  2: break;                           	// Vector  2:  ADC overflow
  	case  4: break;                           	// Vector  4:  ADC timing overflow
    case  6:                                   // Vector  6:  ADC12IFG0
        if(num1<=480||num2<=480)
            {
            results[num1] =ADC12MEM0;
            num1++;
           // if((ADC12IV && 8)==8){
                results1[num2] = ADC12MEM1;
                num2++;}
           // }

        break;

    case  8:
     /*  if(num1<=480||num2<=480&&ad_f==1)
        {
            results1[num2] = ADC12MEM1;
            num2++;
            if((ADC12IV && 6)==6){
              results[num1] = ADC12MEM0;
              num1++;}// Move results, IFG is cleared// Vector  8:  ADC12IFG1
        }*/
      //  if(ad_f!=1)
       // {
            if (section==0){
              x=ADC12MEM1;   //处于充气阶段
            }
            else{
                results1[n]=ADC12MEM0;
                results[n]=ADC12MEM1;
                      n++;

                  flag=flag%2;  //曲线的密集程度
                      if(flag==0){
                          xaxis=xaxis%480;
                          if(xaxis==0){
                              SPILCD_Clear_Lim(0,479,61,270,WHITE); //清除原来的波形
                              //drawbpletter();
                              //DRAW_LINE(0,60,480,60,RED);
                          }
                          DRAW_LINE(480-xaxis,mm,480-xaxis+1,ADC12MEM0/20+60,BLACK);
                          DRAW_LINE(480-xaxis,xx,480-xaxis+1,ADC12MEM1/18+40,GREEN);
                          xaxis++;
                          xx=ADC12MEM1/18+40;
                          mm=ADC12MEM0/20+60;
                      }
                      flag++;
            }
//            __bic_SR_register_on_exit(LPM0_bits);   // 退出低功耗
    //    }
        break;

	case  10:                                  // Vector  10:  ADC12IFG2
		interupt_flag=1;
 		ADC12IE &=~ ADC12IE2;
 	    ADC12CTL0 &= ~ADC12SC;//启动采样
 	    ADC12CTL0 &= ~ADC12ENC+ADC12ON;		// Move results, IFG is cleared

  	case 12: break;                           	// Vector 12:  ADC12IFG3
  	case 14: break;                           	// Vector 14:  ADC12IFG4
  	case 16: break;                           	// Vector 16:  ADC12IFG5
 	case 18: break;                           	// Vector 18:  ADC12IFG6
 	case 20: break;                           	// Vector 20:  ADC12IFG7
 	case 22: break;                           	// Vector 22:  ADC12IFG8
 	case 24: break;                           	// Vector 24:  ADC12IFG9
 	case 26:
 		interupt_flag=1;
 		ADC12IE &=~ ADC12IE10;
 	    ADC12CTL0 &= ~ADC12SC;//启动采样
 	    ADC12CTL0 &= ~ADC12ENC+ADC12ON;
 		break;                           	// Vector 26:  ADC12IFG10
 	case 28: break;                           	// Vector 28:  ADC12IFG11
 	case 30:
 	            results1[index11] = ADC12MEM12;          	// Move results
 		  		//转换采样数据在LCD上显示
 		  		if(index11>=9&&index11<=488)
 		  		{
 		  		    SPILCD_Clear_Lim(488-index11,488-index11,61,270,WHITE);
 		  			DRAW_LINE(489-index11,results1[index11-1]/20+50,488-index11,results1[index11]/20+50, BLACK);}
 		  		if(index11>=506)
 		  		{
 		  		 SPILCD_Clear_Lim(985-index11,985-index11,61,270,WHITE);  //958-980
 		  		 DRAW_LINE(986-index11,results1[index11-1]/20+50,985-index11,results1[index11]/20+50, BLACK); //959-981
 		  		}
 		  		index11++;
                //  __bic_SR_register_on_exit(LPM0_bits);   // 退出低功耗
 	  		if (index11 == 489)
 		  		{
 	  		     index_ECG = 0x33;
 	  		     SPILCD_Clear_Lim(479,479,61,270,WHITE);
 	  		    /* for(index11=7;index11<=486;index11++){
 	  		         results1[index11]=results1[index11]>>4;
 	  		     }*/
 	  		    // HRCaculate();
 	  		     index11=506;
 		  		 __bic_SR_register_on_exit(LPM0_bits);   // 退出低功耗
 		  		}
 	  		if(index11 == 986)  //959
 	  		{
 	             index_ECG = 0x22;
 	             SPILCD_Clear_Lim(479,479,61,270,WHITE);
 	            /*for(index11=502;index11<982;index11++){
 	               results1[index11]=results1[index11]>>4;
 	              }*/
 	             index11 = 9;
 	             __bic_SR_register_on_exit(LPM3_bits);   // 退出低功耗
 	  		}
 		break;                           	  	// Vector 30:  ADC12IFG12


 	case 32: break;                           	// Vector 32:  ADC12IFG13
 	case 34: break;                           	// Vector 34:  ADC12IFG14
 	case 36: break;							  		// Vector 36:  ADC12IFG15
 	default: break;
  	}
}
Esempio n. 15
0
// filtloc and filter operate on the filenames and determine whether they
// may be selected:
// ALL: don't filter, in this case, filter can be NULL
// BASE: filter with cmp_base(filename, filter) - only show when part up to
//       last extension matches
// EXT: filter with cmp_ext(filename, filter) - only show when (last) extension
//      matches
// NAME: filter with strcasecmp(filename, filter) - only show when whole name
//       matches
char * select_file(enum filter_spec filtloc, char *filter) {
	char *selected_file, str[256];
	int npages, pagenum = 1;
	const int perpage = PERPAGE - 1;

	DECL_LINE(backbtn);
	DECL_LINE(prevpage);
	DECL_LINE(nextpage);

	strcpy(sbstr, "file browser");

	selected_file = malloc(PATH_MAX * sizeof(char));

	selected_file[0] = '\0';

	while (selected_file[0] == '\0') {
		char *pwd = NULL;
		int n;
		int *by, *kept;
		int j, nkept;
		int match, keep;
		uint16_t mode;

		sel = -1;

		clear_screen();
		START_LIST(8, 48, 448, 0xFF404040, 0xFF808080, 0xFFC0C0C0)

		update_dir_list();
		n = file_count();
		by = malloc(n * sizeof(int));
		kept = malloc(n * sizeof(int));
		npages = 1 + n / perpage;

		pwd = getcwd(pwd, PATH_MAX);
		text(pwd, 16, 24, 1, 1, 0xFF606060, 0xFF000000);

		DRAW_LINE(backbtn, "back", "return to previous menu without making a selection"); 
		if (pagenum > 1) {
			DRAW_LINE(prevpage, "previous page", "not all files are shown"); 
		}

		j = 0;
		for (int i = 0; i < n; ++i) {
			switch (filtloc) {
			case ANY:
				match = 1;
				break;
			case BASE:
				match = !cmp_base(file_name(i), filter);
				break;
			case EXT:
				match = !cmp_ext(file_name(i), filter);
				break;
			case NAME:
				match = !strcasecmp(file_name(i), filter);
				break;
			default:
				match = 0;
			}

			if (file_is_dir(i) || match) {
				kept[j] = i; 
				++j;
			}
		}
		nkept = j;

		for (int i = perpage * (pagenum - 1); i < nkept; ++i) {
			if (i > pagenum * perpage) break;

			snprintf(str, sizeof(str), "permissions = %o", file_mode(kept[i]) & 07777);

			USECOLR = !USECOLR; 
			CURCOLR = USECOLR ? BG1COLR : BG2COLR; 
			current_y += 48; 
			by[i] =  current_y; 
			fill_rect(0, by[i], 1024, 44, CURCOLR);
			text(file_name(kept[i]), col1_x, by[i] + 8, 1, 1, 0xFFFFFFFF, CURCOLR);
			text(str, col2_x, by[i] + 8, 1, 1, 0xFFFFFFFF, CURCOLR);
		}
		if (pagenum < npages) {
			DRAW_LINE(nextpage, "next page", "not all files are shown");
		}

		while (sel == -1) {
			update_screen();
			input_read();

			if (BTN_CLICKED(backbtn)) {
				free(by);
				free(kept);
				return NULL;
			}
			for (int i = perpage * (pagenum - 1); i <= nkept; ++i)
				if (was_clicked(0, by[i], 1024, 44))
					sel = kept[i];
			if (BTN_CLICKED(prevpage)) {
				--pagenum;
				break;
			} else if (BTN_CLICKED(nextpage)) {
				++pagenum;
				break;
			}
		}

		if (sel != -1) {
			free(by);
			free(kept);
			pagenum = 1;
	
			if (file_is_dir(sel)) {
				if (chdir(file_name(sel)) == -1)
					perror("chdir");
			} else {
				strcpy(selected_file, pwd);
				strcat(selected_file, "/");
				strcat(selected_file, file_name(sel));
			}
		}
	}

	return selected_file;
}
Esempio n. 16
0
void boot_menu(void) {
	int npages, pagenum = 1;
	int *by, ret = -1;
	char helpstr[256];

	DECL_LINE(backbtn);
	DECL_LINE(prevpage);
	DECL_LINE(nextpage);

	if (!menu_size) scan_boot_lvs();
	by = malloc(menu_size * sizeof(int));
	npages = 1 + menu_size / PERPAGE;

	strcpy(sbstr, "boot menu");

	clear_screen();

	do {
		clear_screen();
		START_LIST(0, 32, 384, 0xFF404040, 0xFF808080, 0xFFC0C0C0)
		col1_x = 8;

		DRAW_LINE(backbtn, "back", "return to previous menu without making a selection"); 
		if (pagenum > 1) {
			DRAW_LINE(prevpage, "previous page", "not all available kernels are shown"); 
		}

		for (int i = PERPAGE * (pagenum - 1); i < menu_size; ++i) {
			boot_item *cur_item = menu + i; 

			if (i > pagenum * PERPAGE) break;

			snprintf(helpstr, sizeof(helpstr), "volume is %s,\nkernel is %s", 
					cur_item->cfgdev, cur_item->kernel);

			USECOLR = !USECOLR; 
			CURCOLR = USECOLR ? BG1COLR : BG2COLR; 
			current_y += 48; 
			by[i] =  current_y; 
			fill_rect(0, by[i], 1024, 44, CURCOLR);
			text(cur_item->label, col1_x, by[i] + 8, 1, 1, 0xFFFFFFFF, CURCOLR);
			text(helpstr, col2_x, by[i] + 8, 1, 1, 0xFFFFFFFF, CURCOLR);
		}

		while (ret == -1) {
			update_screen();
			input_read();

			if (BTN_CLICKED(backbtn)) ret = 1;

			for (int i = 0; i < menu_size; ++i) {
				if (i > pagenum * PERPAGE) break;
				if (was_clicked(0, by[i], 1024, 44))
					boot_kexec(i);
			}
			if (BTN_CLICKED(nextpage)) ++pagenum;
			else if (BTN_CLICKED(prevpage)) --pagenum;
		}
	} while (!ret);

	free(by);
}