NOTICE: This website will be shut down in the near future. Product content has moved to nxp.com. Forum content and FAQs have been moved to community.nxp.com. We encourage you to create a user account on nxp.com to use the new community forums and access NXP microcontroller content. We greatly appreciate your contributions and look forward to seeing you at our new web location.

 

Another simple SWIM example

Attached is another simple SWIM demo that setups a 240x320 window and draws an animated diamond in the window as fast as possible. Although the code is meant to be used with the LPC32x0 CDL, it can be easily ported to other devices. The code for setting up the window and doing the animations is below:

/* Create a SWIM window */
swim_window_open(&win1, LCD_DISPLAY.pixels_per_line,
    LCD_DISPLAY.lines_per_panel, fblog1, 0, 0,
    (LCD_DISPLAY.pixels_per_line - 1),
    (LCD_DISPLAY.lines_per_panel - 1), 3, WHITE, BLACK, MAGENTA);

    xf = 20;
    yf = 30;
    xinc = 1;
    yinc = 1;
    clr = RED | GREEN;

    /* Draw as fast as possible, no throttling */
    while (1)
    {
       swim_set_fill_color(&win1, clr);
       swim_put_diamond(&win1, LCD_DISPLAY.pixels_per_line / 2,
       LCD_DISPLAY.lines_per_panel / 2, xf, yf);
       lcd_ioctl(lcddev, LCD_SET_UP_FB, PHY_LCD_FRAME_BUF1);

       xf += xinc;
       if ((xf < 10) || (xf > 150))
           xinc = -xinc;
       yf += yinc;
       if ((yf < 10) || (yf > 230))
           yinc = -yinc;

       clr++;
       if (clr > 0xFFFF)
           clr = RED | GREEN;
    }

The file also includes a pre-built image of the program for use with the Phytec LPC3250 board using S1L. To use the image, just boot the board to the S1L prompt, type "load term srec', send the SREC file to the board via the serial port (no transfer protocol), and then type 'exec' to start it.

5
Your rating: None Average: 5 (1 vote)
feedback