/* Sets the orientation of the display data. 
Configures the display for a given orientation, including mirroring and/or screen rotation. */
void ili9341_set_orientation(uint8_t flags)
/* Sets the orientation of the display data. 
Configures the display for a given orientation, including mirroring and/or screen rotation. */
void ili9341_set_orientation(uint8_t flags)
{
	uint8_t madctl = 0x48;
	flags ^= ILI9341_SWITCH_XY | ILI9341_FLIP_X;
	if (flags & ILI9341_FLIP_X) {
		madctl &= ~(1 << 6);
	}
	if (flags & ILI9341_FLIP_Y) {
		madctl |= 1 << 7;
	}
	if (flags & ILI9341_SWITCH_XY) {
		madctl |= 1 << 5;
	}
	ili9341_send_command(ILI9341_CMD_MEMORY_ACCESS_CONTROL);
	ili9341_send_byte(madctl);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();
}