ili9340.c
int ili9340_thread(void* data) {
	
	int cnt = 0;
	threadActive = 1;
	debug("thread starting");
	   
	displayInit();
	displayStartStream();
	
	while(!threadTerminate) {
     
		int i;
		
		// use a second buffer
		memcpy(mem2, mem, ILI9340_BUFFER_SIZE_TOTAL);
		
		// convert from RGB32 to RGB16 and enque for sending
		for (i = 0; i < ILI9340_BUFFER_SIZE_TOTAL; i += 4) {
			//const int b = mem2[i+0] >> 3;
			//const int g = mem2[i+1] >> 2;
			//const int r = mem2[i+2] >> 3;
			//const int c = (b << 0) | (g << 5) | (r << 11);
			const int c = ((mem2[i+0] & 0b11111000) >> 3) | ((mem2[i+1] & 0b11111100) << 3) | ((mem2[i+2] & 0b11111000) << 8);
			displayStreamPixel(c);
		}
		
		// restart drawing in the upper-left every 16 frames (sync if something goes wrong)
		if (++cnt % 16 == 0) {
			displayStopStream();
			displayStartStream();
		}
			
		// wait for next
		msleep(10);
			
	}
 
	// cleanup
	displayUninit();
		
	// return
	debug("thread done");
	threadActive = 0;
	do_exit(0);

}
/**
 * background thread
 * refreshes the content of the LCD
 * using the internal memory buffer
 */
background thread
refreshes the content of the LCD
using the internal memory buffer
background thread refreshes the content of the LCD using the internal memory buffer
int ili9340_thread(void* data) {
	int cnt = 0;
	threadActive = 1;
	debug("thread starting");
	displayInit();
	displayStartStream();
	while(!threadTerminate) {
		int i;
		memcpy(mem2, mem, ILI9340_BUFFER_SIZE_TOTAL);
		for (i = 0; i < ILI9340_BUFFER_SIZE_TOTAL; i += 4) {
			const int c = ((mem2[i+0] & 0b11111000) >> 3) | ((mem2[i+1] & 0b11111100) << 3) | ((mem2[i+2] & 0b11111000) << 8);
			displayStreamPixel(c);
		}
		if (++cnt % 16 == 0) {
			displayStopStream();
			displayStartStream();
		}
		msleep(10);
	}
	displayUninit();
	debug("thread done");
	threadActive = 0;
	do_exit(0);
}
int ili9340_thread ( void * data ) { int cnt = 0 ; threadActive = 1 ; debug ( " " ) ; displayInit ( ) ; displayStartStream ( ) ; while ( ! threadTerminate ) { int i ; memcpy ( mem2 , mem , ILI9340_BUFFER_SIZE_TOTAL ) ; for ( i = 0 ; i < ILI9340_BUFFER_SIZE_TOTAL ; i += 4 ) { const int c = ( ( mem2 [ i + 0 ] & 0b11111000 ) >> 3 ) | ( ( mem2 [ i + 1 ] & 0b11111100 ) << 3 ) | ( ( mem2 [ i + 2 ] & 0b11111000 ) << 8 ) ; displayStreamPixel ( c ) ; } if ( ++ cnt % 16 == 0 ) { displayStopStream ( ) ; displayStartStream ( ) ; } msleep ( 10 ) ; } displayUninit ( ) ; debug ( " " ) ; threadActive = 0 ; do_exit ( 0 ) ; }
background thread
 refreshes the content of the LCD
 using the internal memory buffer
background thread refreshes the content of the LCD using the internal memory buffer
// use a second buffer // convert from RGB32 to RGB16 and enque for sending //const int b = mem2[i+0] >> 3; //const int g = mem2[i+1] >> 2; //const int r = mem2[i+2] >> 3; //const int c = (b << 0) | (g << 5) | (r << 11); // restart drawing in the upper-left every 16 frames (sync if something goes wrong) // wait for next // cleanup // return