Пример #1
0
void SDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src, Color color)
{
	Rect sr(Point(x, y) + cloff.Top().offset, (src & img.GetSize()).GetSize());
	const Vector<Rect>& clip = cloff.Top().clip;
	for(int i = 0; i < clip.GetCount(); i++) {
		Rect cr = clip[i] & sr;
		if(!cr.IsEmpty()) {
			Point p = cr.TopLeft();
			Rect r(cr.TopLeft() - sr.TopLeft() + src.TopLeft(), cr.GetSize());
			if(IsNull(color))
				PutImage(p, img, r);
			else
				PutImage(p, img, r, color);
		}
	}
}
Пример #2
0
NAMESPACE_UPP

void SDraw::PutImage(Point p, const Image& img, const Rect& src, Color color)
{
	PutImage(p, (paintonly ? CachedSetColorKeepAlphaPaintOnly : CachedSetColorKeepAlpha)
	               (img, color), src);
}
Пример #3
0
void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size )
{
 wItem    * item;
 txSample * image = NULL;
 int        i;

 image_buffer=db;
 image_width=window->Width;

 for( i=0;i < nrItems + 1;i++ )
  {
   item=&Items[i];
   switch( item->type )
    {
     case itButton:
          PutImage( &item->Bitmap,item->x,item->y,3,item->pressed );
          break;
     case itPotmeter:
          if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
          else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
          break;
     case itHPotmeter:
          if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
          else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
          PutImage( &item->Mask,item->x + (int)( ( item->width - item->psx ) * item->value / 100.0f ),item->y,3,item->pressed );
          break;
     case itVPotmeter:
          PutImage( &item->Bitmap,
	    item->x,item->y,
	    item->phases,
	    item->phases * ( 1. - item->value / 100.0f ) );
          PutImage( &item->Mask,
	    item->x,item->y + (int)( ( item->height - item->psy ) * ( 1. - item->value / 100.0f ) ),
	    3,item->pressed );
          break;
     case itSLabel:
          image=fntRender( item,0,"%s",item->label );
          if ( image ) PutImage( image,item->x,item->y,1,0 );
     case itDLabel:
          {
           char * t = Translate( item->label );
           int    l = fntTextWidth( item->fontid,t );
           l=(l?l:item->width);
           image=fntRender( item,l-(GetTimerMS() / 20)%l,"%s",t );
	  }
          if ( image ) PutImage( image,item->x,item->y,1,0 );
          break;
    }
  }
 wsConvert( window,db,size );
}
Пример #4
0
int __stdcall text_out(char *string, char *buffer, int height, int color, int x, int y) {
	unsigned char *from_zone;
	unsigned char *to_zone;
	int px, py;
	unsigned char app_data[1024];
	
	int width=0;
	//kol_board_puts("width...\n");
	//kol_board_puts("\n and now height is ...");
	//kol_board_puti(height);
	
	width=get_width(string,buffer,height);
	//kol_board_puts("\n Width is ...");
	//kol_board_puti(width);
	//kol_board_puts(" and height is ...");
	//kol_board_puti(height);
	
	//kol_board_puts("\n malloc...\n");
	from_zone=(char*)zmalloc(3*height*width);
	to_zone=(char*)zmalloc(height*width);
	//kol_board_puts("malloc done...\n");
	
kol_process_info(-1, app_data);
//px=app_data[35]*256+app_data[34];
px=app_data[35]*256+app_data[34]+app_data[55]*256+app_data[54];//lev
//py=app_data[39]*256+app_data[38];
py=app_data[39]*256+app_data[38]+app_data[59]*256+app_data[58];//lev

//kol_board_puts("\nzone...\n");
getzone(px+x, py+y, width, height, from_zone);
//kol_board_puts("render...\n");
picture(string, buffer, to_zone, width, height);
//kol_board_puts("blit...\n");	
font_blit(from_zone,to_zone, color, width*height);
//kol_board_puts("out...\n");
 //f65(x,y,width,height,from_zone);
 PutImage(x,y,width,height,from_zone);//lev
	zfree(from_zone);
	zfree(to_zone);
	return 0;
}
Пример #5
0
WORD GridDraw( GRID *pGrid )
{
    SHORT   i;
    SHORT   j;

    if ((pGrid->hdr.state & GRID_DRAW_ITEMS) || (pGrid->hdr.state & GRID_DRAW_ALL) || (pGrid->hdr.state & GRID_SHOW_FOCUS))
    {
        if (pGrid->hdr.state & GRID_DRAW_ALL)
        {
            // Clear the entire region.
            SetColor( pGrid->hdr.pGolScheme->CommonBkColor );
            Bar( pGrid->hdr.left, pGrid->hdr.top, pGrid->hdr.right, pGrid->hdr.bottom );

            // Draw the grid lines
            if (pGrid->hdr.state & (GRID_SHOW_LINES | GRID_SHOW_BORDER_ONLY | GRID_SHOW_SEPARATORS_ONLY))
            {
                SetLineType( SOLID_LINE );
                SetColor( pGrid->hdr.pGolScheme->EmbossLtColor  );

                // Draw the outside of the box
                // TODO This should have some 3D effects added with GOL_EMBOSS_SIZE
                if (pGrid->hdr.state & (GRID_SHOW_LINES | GRID_SHOW_BORDER_ONLY))
                {
                    Line( pGrid->hdr.left, pGrid->hdr.top,  pGrid->hdr.right, pGrid->hdr.top );
                    LineTo( _cursorX, pGrid->hdr.bottom );
                    LineTo( pGrid->hdr.left, _cursorY );
                    LineTo( pGrid->hdr.left, pGrid->hdr.top );
                }    

                // Draw the lines between each cell
                if (pGrid->hdr.state & (GRID_SHOW_LINES | GRID_SHOW_SEPARATORS_ONLY))
                {
                    for (i=1; i< pGrid->numColumns; i++)
                    {
                        Line( pGrid->hdr.left + i * (pGrid->cellWidth+1), pGrid->hdr.top, 
                              pGrid->hdr.left + i * (pGrid->cellWidth+1), pGrid->hdr.top + pGrid->numRows * (pGrid->cellHeight+1) );
                    }
                    for (i=1; i<pGrid->numRows; i++)
                    {
                        Line( pGrid->hdr.left,  pGrid->hdr.top + i * (pGrid->cellHeight+1),  
                              pGrid->hdr.right, pGrid->hdr.top + i * (pGrid->cellHeight+1) );
                    }
                }    
            }
        }

        for (i = 0; i < pGrid->numColumns; i++)
        {
            for (j = 0; j < pGrid->numRows; j++)
            {
                if ((pGrid->hdr.state & GRID_DRAW_ALL) ||
                    ((pGrid->hdr.state & GRID_DRAW_ITEMS) && (pGrid->gridObjects[CELL_AT(i,j)].status & GRIDITEM_DRAW)) || 
                    ((pGrid->hdr.state & GRID_SHOW_FOCUS) && (i == pGrid->focusX) && (j == pGrid->focusY)))
                {
                    // Clear the cell
                    SetColor( pGrid->hdr.pGolScheme->CommonBkColor );
                    Bar( CELL_LEFT, CELL_TOP, CELL_RIGHT, CELL_BOTTOM );

                    // Draw the cell
                    if ((pGrid->gridObjects[CELL_AT(i,j)].status & GRID_TYPE_MASK) == GRIDITEM_IS_BITMAP)
                    {
                        // Draw the bitmap
                        if (pGrid->gridObjects[CELL_AT(i,j)].data)
                        {
                            PutImage( CELL_LEFT, CELL_TOP, pGrid->gridObjects[CELL_AT(i,j)].data, BITMAP_SCALE );
                        }
                    }
                    else
                    { 
                        // Draw the text
                    }
    
        	        // Draw the focus if applicable.
        	        if ((pGrid->hdr.state & GRID_SHOW_FOCUS) && (i == pGrid->focusX) && (j == pGrid->focusY))
        	        {
                        SetColor( pGrid->hdr.pGolScheme->EmbossLtColor );
                        SetLineType( DOTTED_LINE );
                        SetLineThickness( NORMAL_LINE );   	        
                        Rectangle( CELL_LEFT, CELL_TOP, CELL_RIGHT, CELL_BOTTOM );
                    }  
                    
                    // If the cell is selected, indicate it.
                    if (pGrid->gridObjects[CELL_AT(pGrid->focusX,pGrid->focusY)].status & GRIDITEM_SELECTED)
                    {
                        SetColor( pGrid->hdr.pGolScheme->EmbossLtColor );
                        SetLineType( SOLID_LINE ); 
                        if (pGrid->hdr.state & GRID_SHOW_LINES)
                        {
                            SetLineThickness( THICK_LINE );   	        
                        }
                        else
                        {
                            SetLineThickness( NORMAL_LINE );   	        
                        }    
                        Rectangle( CELL_LEFT-1, CELL_TOP-1, CELL_RIGHT+1, CELL_BOTTOM+1 );
                    }
                    
                    GridClearCellState( pGrid, i, j, GRIDITEM_DRAW );  
                }
            }
        }
        
        //pGrid->state &= ~(GRID_DRAW_ITEMS || GRID_DRAW_ALL || GRID_SHOW_FOCUS); 
        pGrid->hdr.state &= ~(GRID_DRAW_ITEMS || GRID_DRAW_ALL ); 
        
        // Set line state
        SetLineType( SOLID_LINE );
    }

    return 1;
}
Пример #6
0
/*********************************************************************
* Function: WORD PictDraw(PICTURE *pPict)
*
* Output: returns the status of the drawing
*		  0 - not completed
*         1 - done
*
* Overview: draws picture
*
********************************************************************/
WORD PictDraw(PICTURE *pPict)
{
    typedef enum
    {
        REMOVE,
        DRAW_IMAGE,
        DRAW_BACKGROUND1,
        DRAW_BACKGROUND2,
        DRAW_BACKGROUND3,
        DRAW_BACKGROUND4,
        DRAW_FRAME
    } PICT_DRAW_STATES;

    static PICT_DRAW_STATES state = REMOVE;
    static SHORT posleft;
    static SHORT postop;
    static SHORT posright;
    static SHORT posbottom;

    if(IsDeviceBusy())
        return (0);

    switch(state)
    {
        case REMOVE:
            if(GetState(pPict, PICT_HIDE))
            {
                SetColor(pPict->hdr.pGolScheme->CommonBkColor);
                if(!Bar(pPict->hdr.left, pPict->hdr.top, pPict->hdr.right, pPict->hdr.bottom))
                    return (0);
                return (1);
            }

            posleft = (pPict->hdr.left + pPict->hdr.right - pPict->scale * GetImageWidth(pPict->pBitmap)) >> 1;
            postop = (pPict->hdr.top + pPict->hdr.bottom - pPict->scale * GetImageHeight(pPict->pBitmap)) >> 1;
            posright = (pPict->hdr.right + pPict->hdr.left + pPict->scale * GetImageWidth(pPict->pBitmap)) >> 1;
            posbottom = (pPict->hdr.bottom + pPict->hdr.top + pPict->scale * GetImageHeight(pPict->pBitmap)) >> 1;
            state = DRAW_IMAGE;

        case DRAW_IMAGE:
            if(pPict->pBitmap != NULL)
            {
                if(IsDeviceBusy())
                    return (0);
                if(!PutImage(posleft, postop, pPict->pBitmap, pPict->scale))
                    return (0);
            }

            SetColor(pPict->hdr.pGolScheme->CommonBkColor);
            state = DRAW_BACKGROUND1;

        case DRAW_BACKGROUND1:
            if(!Bar(pPict->hdr.left + 1, pPict->hdr.top + 1, pPict->hdr.right - 1, postop - 1))
                return (0);
            state = DRAW_BACKGROUND2;

        case DRAW_BACKGROUND2:
            if(!Bar(pPict->hdr.left + 1, posbottom, pPict->hdr.right - 1, pPict->hdr.bottom - 1))
                return (0);
            state = DRAW_BACKGROUND3;

        case DRAW_BACKGROUND3:
            if(!Bar(pPict->hdr.left + 1, postop, posleft - 1, posbottom))
                return (0);
            state = DRAW_BACKGROUND4;

        case DRAW_BACKGROUND4:
            if(!Bar(posright, postop, pPict->hdr.right - 1, posbottom))
                return (0);
            state = DRAW_FRAME;

        case DRAW_FRAME:
            if(GetState(pPict, PICT_FRAME))
            {
                SetLineType(SOLID_LINE);
                SetColor(pPict->hdr.pGolScheme->TextColor0);
                if(!Rectangle(pPict->hdr.left, pPict->hdr.top, pPict->hdr.right, pPict->hdr.bottom))
                    return (0);
            }

            state = REMOVE;
            return (1);
    }

    return (1);
}
Пример #7
0
/**
 * @brief Render all GUI items in a window, i.e. copy the respective images
 *        into the draw buffer.
 *
 * @param window pointer to a ws window structure of the window to be rendered
 * @param items pointer to the array of items
 * @param till maximum index in use for the @a items, i.e. number of last item in array
 * @param drawbuf memory location of the @a window's draw buffer
 */
void RenderAll(wsWindow *window, guiItem *items, int till, char *drawbuf)
{
    uint32_t *db;
    guiItem *item;
    guiImage *image = NULL;
    int dw, i, index, x;
    char *trans;
    unsigned int d;

    db = (uint32_t *)drawbuf;
    dw = window->Width;

    for (i = 0; i <= till; i++) {
        item = &items[i];

        switch (item->pressed) {
        case btnPressed:
            index = 0;
            break;

        case btnReleased:
            index = 1;
            break;

        default:
            index = 2;
            break;
        }

        switch (item->type) {
        case itButton:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, 3, index, True);
            break;

        case itPimage:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True);
            break;

        case itHPotmeter:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True);
            PutImage(item->x + (item->width - item->pbwidth) * item->value / 100.0, item->y, db, dw, &item->Mask, 3, index, True);
            break;

        case itVPotmeter:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, False);
            PutImage(item->x, item->y + (item->height - item->pbheight) * (1.0 - item->value / 100.0), db, dw, &item->Mask, 3, index, True);
            break;

        case itRPotmeter:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True);

            if (item->Mask.Image) {
                double radius, radian;
                int y;

                // keep the button inside the potmeter outline
                radius = (FFMIN(item->width, item->height) - FFMAX(item->pbwidth, item->pbheight)) / 2.0;

                radian = item->value / 100.0 * item->arclength + item->zeropoint;

                // coordinates plus a correction for a non-square item
                // (remember: both axes are mirrored, we have a clockwise radian)
                x = radius * (1 + cos(radian)) + FFMAX(0, (item->width - item->height) / 2.0) + 0.5;
                y = radius * (1 + sin(radian)) + FFMAX(0, (item->height - item->width) / 2.0) + 0.5;

                PutImage(item->x + x, item->y + y, db, dw, &item->Mask, 3, index, True);
            }

            break;

        case itSLabel:

            if (item->width == -1)
                item->width = fntTextWidth(item->fontid, item->label);

            image = fntTextRender(item, 0, item->label);

            if (image)
                PutImage(item->x, item->y, db, dw, image, 1, 0, True);

            break;

        case itDLabel:

            trans = TranslateVariables(item->label);

            if (!item->text || (strcmp(item->text, trans) != 0)) {
                free(item->text);
                item->text      = strdup(trans);
                item->textwidth = fntTextWidth(item->fontid, trans);
                item->starttime = GetTimerMS();
                item->last_x    = 0;
            }

            d = GetTimerMS() - item->starttime;

            if (d < DLABEL_DELAY)
                x = item->last_x;                   // don't scroll yet
            else {
                int l;
                char c[2];

                l    = (item->textwidth ? item->textwidth : item->width);
                x    = (l ? l - ((d - DLABEL_DELAY) / 20) % l - 1 : 0);
                c[0] = *item->text;
                c[1] = 0;

                if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) {
                    item->starttime = GetTimerMS(); // stop again
                    item->last_x    = x;            // at current x pos
                }
            }

            image = fntTextRender(item, x, trans);

            if (image)
                PutImage(item->x, item->y, db, dw, image, 1, 0, True);

            break;
        }
    }

    wsImageRender(window, drawbuf);
}
Пример #8
0
/*****************************************
 *int main (void)
 *****************************************/
int main (void)
{
    InitializeHardware();
    HardwareButtonInit();
    InitAllLEDs();
    
#ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH     
	GFX_DRIVER_AutoUpdPart();		// Turn on widget auto update, partial update for less flashing
#endif
    
    InitTick();
	GOLInit();

    SetColor(WHITE);
    ClearDevice();

	// Set proper display rotation
#if(DISP_ORIENTATION == 90)
    GFX_DRIVER_InitRotmode(ROTATE_90);
#else
#error "This PICTail display orientation must be 90."
#endif
       
	// make sure that the correct hex file is loaded
    CheckExternalFlashHex();

	// Create cursor in GFX_CURSOR_LAYER with Alpha Color = 0xA
	GFX_DRIVER_CreateLayer( GFX_CURSOR_LAYER, GFX_LAYER_TRANS_EN | 0xA, GetX(), GetY(), GetX() + 31, GetY() + 31 );
	GFX_DRIVER_ActivateLayer( GFX_CURSOR_LAYER );
	PutImage(0, 0, (void *)&mouse_cursor_icon_270, IMAGE_NORMAL); 
	GFX_DRIVER_ActivateLayer( GFX_MAIN_LAYER );
	
	// Start demo screen 
	demoScreens = DEMO_INTRO_SCREEN_CREATE;
	
    while(1)
	{
        GOLDraw();
#ifndef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH
	#if defined( ONE_CYCLE_DRAWING	) 
		// The screen drawing starts and completes during one while(1) cycle loop in main().
		// This Demo is one cycle drawing application.
        if ( GFX_DRIVER_IsUpdateRequested() || (g_UPDATE_FLAGS == GFX_UPDATE_AS_IT_DRAWS) )
        {
	    	GFX_DRIVER_UpdateEpd( g_UPDATE_FLAGS, 0, 0, GetMaxX(), GetMaxY() ); 
	    	g_UPDATE_FLAGS = GFX_UPDATE_NO_FLASH | GFX_WAIT_IMAGE_DISPLAYED;   
	    }
	#else
		// This way can be used when drawing may take few or more cycles of while(1) loop in main().
		// See "tick.c" file for details.
        if ( g_UpdateNow || (g_UPDATE_FLAGS == GFX_UPDATE_AS_IT_DRAWS) )
        {
	        g_UpdateNow = 0;
	    	GFX_DRIVER_UpdateEpd( g_UPDATE_FLAGS, 0, 0, GetMaxX(), GetMaxY() ); 
	    	g_UPDATE_FLAGS = GFX_UPDATE_NO_FLASH | GFX_WAIT_IMAGE_DISPLAYED;   
	    }	
	#endif
#endif		 
	}	

    return (-1);
}
Пример #9
0
/* display pixmap */
void DrawImage(ObjData *my, GrpData *grp)
{
    PutImage(grp->image[my->image],my->X - grp->HarfW, my->Y - grp->HarfH);

    return;
}
Пример #10
0
void RenderAll(wsTWindow *window, wItem *Items, int nrItems, char *db)
{
    wItem *item;
    guiImage *image = NULL;
    int i, ofs;

    image_buffer = db;
    image_width  = window->Width;

    for (i = 0; i < nrItems + 1; i++) {
        item = &Items[i];

        switch (item->pressed) {
        case btnPressed:
            ofs = 0;
            break;

        case btnReleased:
            ofs = 1;
            break;

        default:
            ofs = 2;
            break;
        }

        switch (item->type) {
        case itButton:
            PutImage(&item->Bitmap, item->x, item->y, 3, ofs);
            break;

        case itPotmeter:
            if (item->numphases == 1)
                SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0);
            else
                PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0));
            break;

        case itHPotmeter:
            if (item->numphases == 1)
                SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0);
            else
                PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0));
            PutImage(&item->Mask, item->x + (item->width - item->pwidth) * (item->value / 100.0), item->y, 3, ofs);
            break;

        case itVPotmeter:
            PutImage(&item->Bitmap, item->x, item->y, item->numphases, item->numphases * (1.0 - item->value / 100.0));
            PutImage(&item->Mask, item->x, item->y + (item->height - item->pheight) * (1.0 - item->value / 100.0), 3, ofs);
            break;

        case itSLabel:
            if (item->width == -1)
                item->width = fntTextWidth(item->fontid, item->label);
            image = fntRender(item, 0, item->label);
            if (image)
                PutImage(image, item->x, item->y, 1, 0);
            break;

        case itDLabel:
        {
            int x;
            unsigned int d;
            char *t = Translate(item->label);

            if (!item->text || (strcmp(item->text, t) != 0)) {
                free(item->text);
                item->text      = strdup(t);
                item->textwidth = fntTextWidth(item->fontid, t);
                item->starttime = GetTimerMS();
                item->last_x    = 0;
            }

            d = GetTimerMS() - item->starttime;

            if (d < DLABEL_DELAY)
                x = item->last_x;                     // don't scroll yet
            else {
                int l;
                char c[2];

                l    = (item->textwidth ? item->textwidth : item->width);
                x    = l - ((d - DLABEL_DELAY) / 20) % l - 1;
                c[0] = *item->text;
                c[1] = '\0';

                if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) {
                    item->starttime = GetTimerMS();   // stop again
                    item->last_x    = x;              // at current x pos
                }
            }

            image = fntRender(item, x, t);
        }

            if (image)
                PutImage(image, item->x, item->y, 1, 0);

            break;
        }
    }

    wsConvert(window, db);
}
Пример #11
0
    int main(void)
{
    SHORT       width, height;	// variables to store the height and width of the 16-bit bitmap image
    SHORT       counter;		// loop control variable for each shape that controls how many shapes are printed and their scale
    SHORT  		triangle[] = {160,120,160,120,160,120,160,120};		// triangle polygon points (start triangle in center of LCD)
    
    #if defined(__dsPIC33F__) || defined(__PIC24H__)

    // Configure Oscillator to operate the device at 40Mhz
    // Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
    // Fosc= 8M*40(2*2)=80Mhz for 8M input clock
    PLLFBD = 38;                    // M=40
    CLKDIVbits.PLLPOST = 0;         // N1=2
    CLKDIVbits.PLLPRE = 0;          // N2=2
    OSCTUN = 0;                     // Tune FRC oscillator, if FRC is used

    // Disable Watch Dog Timer
    RCONbits.SWDTEN = 0;

    // Clock switching to incorporate PLL
    __builtin_write_OSCCONH(0x03);  // Initiate Clock Switch to Primary

    // Oscillator with PLL (NOSC=0b011)
    __builtin_write_OSCCONL(0x01);  // Start clock switching
    while(OSCCONbits.COSC != 0b011);

    // Wait for Clock switch to occur	
    // Wait for PLL to lock
    while(OSCCONbits.LOCK != 1)
    { };
    #elif defined(__PIC32MX__)
    INTEnableSystemMultiVectoredInt();
    SYSTEMConfigPerformance(GetSystemClock());
    #ifdef MULTI_MEDIA_BOARD_DM00123
    CPLDInitialize();
    CPLDSetGraphicsConfiguration(GRAPHICS_HW_CONFIG);
    CPLDSetSPIFlashConfiguration(SPI_FLASH_CHANNEL);
    #endif
    #endif

    #if defined (PIC24FJ256DA210_DEV_BOARD)
    
    // _ANSG8 = 0; /* S1 */
    // _ANSE9 = 0; /* S2 */
    // _ANSB5 = 0; /* S3 */
        
    #else

    /////////////////////////////////////////////////////////////////////////////
    // ADC Explorer 16 Development Board Errata (work around 2)
    // RB15 should be output
    /////////////////////////////////////////////////////////////////////////////
    LATBbits.LATB15 = 0;
    TRISBbits.TRISB15 = 0;

    #endif

    /////////////////////////////////////////////////////////////////////////////
    #if defined(__dsPIC33FJ128GP804__) || defined(__PIC24HJ128GP504__)
    AD1PCFGL = 0xffff;
    #endif
    InitGraph();

    while(1)
    {
	    /* Display the Kettering Logo bit image with the Welcome to the ECE in the center 
	    /* The image was taken from a JPEG and converted to a 16-bit bitmap in order to meet 
	    /* the display requirement of 16-bits per pixel. This can be done by resaving the
	    /* JPEG as 16-bit bitmap in a image editing program and then converting it using
	    /* the graphics library resource converter. The LCD only supports 4-bit, 8-bit, and
	    /* 16-bits per pixel images 
	    */
	    width = GetImageWidth((void *) &kulogo);
		SetFont((void *) &Font25);
	    WAIT_UNTIL_FINISH(PutImage(45, 20 , (void *) &kulogo,  1)); // image location is relative to the top left corner of the image
        SetColor(WHITE);
        Bar(45, 110, width + 45, 135);	// Draw a bar over the image to place the text over.
        SetColor(BLUE);
        OutTextXY(65, 110, "WELCOME TO THE ECE");
        
        DelayMs(DEMODELAY);	// delay for 1 sec and clear the screen
        SetColor(BLACK);
        ClearDevice();

		/* Display multiple circles, starting at the center and increasing in size at 
        /* each draw until the LCD borders are met. Increasing the counter value will 
        /* expand the shape size more quickly. */
        for(counter = 0; counter < MIN(GetMaxX(), GetMaxY()) >> 1; counter += 14)
        {
	        SetColor(BLACK);	// refresh the screen
	        ClearDevice();	
	        SetColor(BRIGHTRED);
	        SetFont((void *) &Font25);		// draw the name of the shape in the center
	        OutTextXY(135, 110, "Circle");
            WAIT_UNTIL_FINISH(Circle(GetMaxX() >> 1, GetMaxY() >> 1, counter + 5));	// draw the shape
            DelayMs(50);	// display for 50 ms
        }

        DelayMs(DEMODELAY);	// delay for 1 sec and clear the screen
        SetColor(BLACK);
        ClearDevice();

		/* Display multiple rectangles, starting at the center and increasing in size at 
        /* each draw until the LCD borders are met. Increasing the counter value will 
        /* expand the shape size more quickly. */
        for(counter = 0; counter < MIN(GetMaxX() / 2, GetMaxY() / 2) >> 1; counter += 5)
        {	
	        SetColor(BLACK);	// refresh the screen
	        ClearDevice();	
	        SetColor(BRIGHTBLUE);
	        OutTextXY(120, 110, "Rectangle");	// draw the name of the shape in the center
            WAIT_UNTIL_FINISH
            (
                Rectangle
                    (
                        GetMaxX() / 2 - counter * 3 + 6,	// x value of top left corner of rectangle
                        GetMaxY() / 2 - counter * 2 - 8,	// y value of top left corner of rectangle
                        GetMaxX() / 2 + counter * 3 - 6,	// x value of bottom right corner of rectangle
                        GetMaxY() / 2 + counter * 2 + 8     // y value of bottom right corner of rectangle        
                    )
            );
            DelayMs(20); // Display for 20 ms
            
        }

        DelayMs(DEMODELAY); // delay for 1 sec and clear the screen
        SetColor(BLACK);
        ClearDevice();
        
        /* Display multiple triangles, starting at the center and increasing in size at 
        /* each draw until the LCD borders are met. Increasing the counter value will 
        /* expand the shape size more quickly. */
        int i;
		for(counter = 0; counter < MIN(GetMaxX() / 2, GetMaxY() / 2) >> 1; counter += 10)
		{
			SetColor(BLACK);	// refresh the screen
			ClearDevice();
			SetColor(GREEN);	// draw the name of the shape at the center
			OutTextXY(125, 110, "Triangle");
			
			//{160,120,160,120,160,120,160,120} start in center of screen
			triangle[1] = triangle[1] - counter * 2 - 20; 	 // top point y
			triangle[7] = triangle[1];				 		 // top point y (close triangle)
			triangle[2] = triangle[2] - counter * 2 - 58; 	 // left corner point x
			triangle[3] = triangle[3] + counter * 2 + 16;	 // left corner point y
			triangle[4] = triangle[4] + counter * 2 + 58; 	 // right corner point x
			triangle[5] = triangle[5] + counter * 2 + 16;	 // right corner point y
			
			DrawPoly(4, triangle);	// draw the triangle (4 points to enclose it)
			
			// reset each of the triangle points to the center to prevent over expansion
			for (i = 0; i < 8; i++)
				if (i % 2 == 0)
					triangle[i] = 160;
				else
					triangle[i] = 120;
				
			DelayMs(50);	// display for 50 ms
		}
		
       
		DelayMs(DEMODELAY); // delay for 1 sec and clear the screen
    	SetColor(BLACK);
    	ClearDevice();
        
    }
}
Пример #12
0
/*********************************************************************
* Function: WORD GOLPanelDrawTsk(void) 
*
* PreCondition: parameters must be set with
*               GOLRndPanelDraw(x,y,radius,width,height,faceClr,embossLtClr,
*								embossDkClr,pBitmap,embossSize)
*
* Input: None
*
* Output: Output: non-zero if drawing is completed
*
* Overview: draws a rounded panel on screen. Must be called repeatedly. Drawing is done
*           when it returns non-zero. 
*
* Note: none
*
********************************************************************/
WORD GOLPanelDrawTsk(void) {

//#define SIN45 46341

#ifndef USE_NONBLOCKING_CONFIG

	WORD counter;

	if (_rpnlR) {
		// draw upper left portion of the embossed area
		SetColor(_rpnlEmbossLtColor);
		Arc(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR-_rpnlEmbossSize, _rpnlR, 0xE1);	
		// draw lower right portion of the embossed area
		SetColor(_rpnlEmbossDkColor);
		Arc(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR-_rpnlEmbossSize, _rpnlR, 0x1E);	
	}
	else {
		// object is rectangular panel draw the embossed areas
		counter = 1;
	    SetColor(_rpnlEmbossLtColor);
    	while(counter < _rpnlEmbossSize){
   			Bar( _rpnlX1+counter, _rpnlY1+counter, _rpnlX2-counter, _rpnlY1+counter); 	// draw top
        	Bar( _rpnlX1+counter, _rpnlY1+counter, _rpnlX1+counter, _rpnlY2-counter);	// draw left
           	counter++;
       	}
       	counter = 1;
	    SetColor(_rpnlEmbossDkColor);
    	while(counter < _rpnlEmbossSize){
        	Bar( _rpnlX1+counter, _rpnlY2-counter, _rpnlX2-counter, _rpnlY2-counter);	// draw bottom
        	Bar( _rpnlX2-counter, _rpnlY1+counter, _rpnlX2-counter, _rpnlY2-counter);	// draw right	
           	counter++;
       	}
	}

	// draw bitmap
	if(_pRpnlBitmap != NULL) {
        if (!(_rpnlX2-_rpnlX1) && (_rpnlY2-_rpnlY1)) {			// vertical capsule
        	PutImage(_rpnlX1-(_rpnlR-_rpnlEmbossSize), _rpnlY1, _pRpnlBitmap,IMAGE_NORMAL);
        } else if ((_rpnlX2-_rpnlX1) && !(_rpnlY2-_rpnlY1)) {	// horizontal capsule
        	PutImage(_rpnlX1, _rpnlY1-(_rpnlR-_rpnlEmbossSize), _pRpnlBitmap,IMAGE_NORMAL);
        }	
        else if ((_rpnlX2-_rpnlX1) && (_rpnlY2-_rpnlY1)) {
	        if (_rpnlR) {  	// beveled 
	        	PutImage(_rpnlX1, _rpnlY1, _pRpnlBitmap,IMAGE_NORMAL);
			} else {			// square
	        	PutImage(_rpnlX1+_rpnlEmbossSize, _rpnlY1+_rpnlEmbossSize, _pRpnlBitmap,IMAGE_NORMAL);
	        }
	    } else if (!(_rpnlX2-_rpnlX1) && !(_rpnlY2-_rpnlY1)) { 	// circular 
        	PutImage(_rpnlX1-(_rpnlR-_rpnlEmbossSize), 
        			 _rpnlY1-(_rpnlR-_rpnlEmbossSize), _pRpnlBitmap,IMAGE_NORMAL);
      	} 
    } else {
	    // draw the face color
	    SetColor(_rpnlFaceColor);
		if (_rpnlR) 
		    FillBevel(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR-_rpnlEmbossSize);
		else    
		    Bar(_rpnlX1+_rpnlEmbossSize, _rpnlY1+_rpnlEmbossSize, _rpnlX2-_rpnlEmbossSize, _rpnlY2-_rpnlEmbossSize);	     
#ifdef USE_MONOCHROME
		if (_rpnlFaceColor == BLACK) {
			SetColor(WHITE);
			if (_rpnlR) 
	   			Bevel(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR-(_rpnlEmbossSize-1));	
	   		else	
    			Bevel(_rpnlX1+(_rpnlEmbossSize-1), _rpnlY1+(_rpnlEmbossSize-1), 
    				  _rpnlX2-(_rpnlEmbossSize-1), _rpnlY2-(_rpnlEmbossSize-1), 0);	
		}
#endif
	} 
    
	
	// draw the outline 
    SetColor(_rpnlEmbossDkColor);
    Bevel(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR);
    return 1;

#else

typedef enum {
BEGIN,
ARC1,
DRAW_EMBOSS1,
DRAW_EMBOSS2,
DRAW_EMBOSS3,
DRAW_EMBOSS4,
DRAW_FACECOLOR,
#ifdef USE_MONOCHROME
DRAW_INNERFRAME,
#endif
DRAW_FRAME,
} ROUND_PANEL_DRAW_STATES;

static ROUND_PANEL_DRAW_STATES state = BEGIN;
static WORD counter;

while(1){
    if(IsDeviceBusy())
        return 0;
    switch(state){
        case BEGIN:      
			if (_rpnlR) {
				// draw upper left portion of the embossed area
				SetColor(_rpnlEmbossLtColor);
				if (!Arc(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR-_rpnlEmbossSize, _rpnlR, 0xE1))	
					return 0;
				state = ARC1;
	        } 
	        else {
        		state = DRAW_EMBOSS1;
        		goto rnd_panel_draw_emboss;
        	}

        case ARC1:      
			// draw upper left portion of the embossed area
			SetColor(_rpnlEmbossDkColor);
			if (!Arc(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR-_rpnlEmbossSize, _rpnlR, 0x1E))
				return 0;	
        	state = DRAW_FACECOLOR;
        	goto rnd_panel_draw_facecolor;

		// now draw the upper portion of the embossed area
        case DRAW_EMBOSS1:
rnd_panel_draw_emboss:        
	    	SetColor(_rpnlEmbossLtColor);
            counter = 1;
            while(counter < _rpnlEmbossSize){
   	            if(IsDeviceBusy())
	       	            return 0;
	       	    // draw top        
				Bar( _rpnlX1+counter, _rpnlY1+counter,  \
				     _rpnlX2-counter, _rpnlY1+counter);
              	counter++;
           	}
            counter = 1;
           	state = DRAW_EMBOSS2;
           	break;

		case DRAW_EMBOSS2:
           	while(counter < _rpnlEmbossSize){
               	if(IsDeviceBusy())
                   	return 0;
                // draw left   	
	        	Bar( _rpnlX1+counter, _rpnlY1+counter,  \
	        	     _rpnlX1+counter, _rpnlY2-counter);	
               	counter++;
           	}
           	counter = 1;
           	state = DRAW_EMBOSS3;
           	break;

		// now draw the lower portion of the embossed area
		case DRAW_EMBOSS3:
		    SetColor(_rpnlEmbossDkColor);
	        while(counter < _rpnlEmbossSize){
                if(IsDeviceBusy())
       	            return 0;
       	        // draw bottom    
		       	Bar( _rpnlX1+counter, _rpnlY2-counter,   \
		       	     _rpnlX2-counter, _rpnlY2-counter);
             	counter++;
           	}
           	counter = 1;
           	state = DRAW_EMBOSS4;
           	break;

		case DRAW_EMBOSS4:
			while(counter < _rpnlEmbossSize){
               	if(IsDeviceBusy())
                   	return 0;
                // draw right	   	
	        	Bar( _rpnlX2-counter, _rpnlY1+counter,  \
	        		 _rpnlX2-counter, _rpnlY2-counter);	
    	       	counter++;
			}
            state = DRAW_FACECOLOR;
            break;

		// draw the face color 
		case DRAW_FACECOLOR:
rnd_panel_draw_facecolor:		

			if(_pRpnlBitmap != NULL) {
		        if (!(_rpnlX2-_rpnlX1) && (_rpnlY2-_rpnlY1)) 		// vertical capsule
		        	PutImage(_rpnlX1-(_rpnlR-_rpnlEmbossSize), _rpnlY1, _pRpnlBitmap,IMAGE_NORMAL);
		        else if ((_rpnlX2-_rpnlX1) && !(_rpnlY2-_rpnlY1))	// horizontal capsule
		        	PutImage(_rpnlX1, _rpnlY1-(_rpnlR-_rpnlEmbossSize), _pRpnlBitmap,IMAGE_NORMAL);
		        else if ((_rpnlX2-_rpnlX1) && (_rpnlY2-_rpnlY1)) {
			        if (_rpnlR)  	// beveled 
			        	PutImage(_rpnlX1, _rpnlY1, _pRpnlBitmap,IMAGE_NORMAL);
			        else			// square
			        	PutImage(_rpnlX1+_rpnlEmbossSize, _rpnlY1+_rpnlEmbossSize, _pRpnlBitmap,IMAGE_NORMAL);
			    }
		        else if (!(_rpnlX2-_rpnlX1) && !(_rpnlY2-_rpnlY1)) 	// circular 
		        	PutImage(_rpnlX1-(_rpnlR-_rpnlEmbossSize), 
		        			_rpnlY1-(_rpnlR-_rpnlEmbossSize), _pRpnlBitmap,IMAGE_NORMAL);
		    } else {
			    SetColor(_rpnlFaceColor);
				if (_rpnlR) {
				    if (!FillBevel(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR-_rpnlEmbossSize))
				    	return 0;
				}
				else  {  
				    Bar(_rpnlX1+_rpnlEmbossSize, _rpnlY1+_rpnlEmbossSize,    \
				    	_rpnlX2-_rpnlEmbossSize, _rpnlY2-_rpnlEmbossSize);
				}			    
	       	    #ifdef USE_MONOCHROME
	       	    	state = DRAW_INNERFRAME;
            		break;
	       	    #endif
				
			}
            state = DRAW_FRAME;
            break;

		#ifdef USE_MONOCHROME
		case DRAW_INNERFRAME:
   			if (_rpnlFaceColor == BLACK) {
   				SetColor(WHITE);
				if (_rpnlR) 
	    			Bevel(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR-(_rpnlEmbossSize-1));	
	    		else	
    				Bevel(_rpnlX1+(_rpnlEmbossSize-1), _rpnlY1+(_rpnlEmbossSize-1), 
    					  _rpnlX2-(_rpnlEmbossSize-1), _rpnlY2-(_rpnlEmbossSize-1), 0);	
	    			
    		}
            state = DRAW_FRAME;
            break;
		#endif	

		case DRAW_FRAME:
			// draw the outline frame
			#ifdef USE_MONOCHROME
		    	SetColor(WHITE);
		    #else	
		    	SetColor(_rpnlEmbossDkColor);
		    #endif	
		    Bevel(_rpnlX1, _rpnlY1, _rpnlX2, _rpnlY2, _rpnlR);
            state = BEGIN;
            return 1;
            
    }// end of switch
}// end of while
#endif //#ifndef USE_NONBLOCKING_CONFIG   
}
Пример #13
0
void SDL_Graphics::ShowText(const char* txt, int x, int y) {
    TTF_SetFontStyle(font, TTF_STYLE_BOLD);//|TTF_STYLE_ITALIC);
    textSurface=TTF_RenderText_Solid(font,txt,textColor);
    PutImage(textSurface, x, y);
    SDL_FreeSurface(textSurface);
}