/** * \brief Read a single color from the graphical memory * * Use this function to read a color from the graphical memory of the * controller. * * Limits have to be set prior to calling this function, e.g.: * \code * ili9341_set_top_left_limit(0, 0); * ili9341_set_bottom_right_limit(320, 240); * ... * \endcode * * \retval ili9341_color_t The read color pixel */ ili9341_color_t ili9341_read_gram(void) { uint8_t red, green, blue; ili9341_send_command(ILI9341_CMD_MEMORY_READ); /* No interesting data in the first byte, hence read and discard */ red = ili9341_read_byte(); red = ili9341_read_byte(); green = ili9341_read_byte(); blue = ili9341_read_byte(); ili9341_deselect_chip(); return ILI9341_COLOR(red, green, blue); }
/** * \brief Copy pixels from the screen to a pixel buffer * * Use this function to copy pixels from the display to an internal SRAM buffer. * * Limits have to be set prior to calling this function, e.g.: * \code * ili9341_set_top_left_limit(0, 0); * ili9341_set_bottom_right_limit(320, 240); * ... * \endcode * * \param pixels Pointer to the pixel buffer to read to * \param count Number of pixels to read */ void ili9341_copy_pixels_from_screen(ili9341_color_t *pixels, uint32_t count) { uint8_t red, green, blue; /* Sanity check to make sure that the pixel count is not zero */ Assert(count > 0); ili9341_send_command(ILI9341_CMD_MEMORY_READ); /* No interesting data in the first byte, hence read and discard */ red = ili9341_read_byte(); while (count--) { red = ili9341_read_byte(); green = ili9341_read_byte(); blue = ili9341_read_byte(); *pixels = ILI9341_COLOR(red, green, blue); pixels++; } ili9341_deselect_chip(); }
* \section compinfo Compilation Info * This software was written for the GNU GCC and IAR for AVR. * Other compilers may or may not work. * * \section contactinfo Contact Information * For further information, visit * <A href="http://www.atmel.com/">Atmel</A>.\n */ /* * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> */ #include <asf.h> /** Table of primary and secondary display pixel colors */ const ili9341_color_t color_table[] = { ILI9341_COLOR(0, 0, 255), ILI9341_COLOR(0, 255, 0), ILI9341_COLOR(255, 0, 0), ILI9341_COLOR(255, 255, 0), ILI9341_COLOR(255, 0, 255), ILI9341_COLOR(0, 255, 255) }; /** Number of colors stored in the \ref color_table array */ #define COLOR_TABLE_SIZE (sizeof(color_table) / sizeof(color_table[0])) /** Display background color when clearing the display */ #define BG_COLOR ILI9341_COLOR(0, 0, 0) /** Number of pixels for full screen */ #define TOTAL_PIXELS ((uint32_t)ILI9341_DEFAULT_WIDTH * ILI9341_DEFAULT_HEIGHT) /** Create an array to hold a 40 x 40 bitmap */ ili9341_color_t bitmap[1600];