I am posting to the AVR Freaks because I believe my issue relates to general programming rather then the platform I am running my project on (SAMD21).

I've been porting my TFT library over from Arduino and the library now supports SSD1963, ILI9325 & the SSD1289. All is working well expect for displaying images on the SSD1289. For some reason, the images don't fully load.

With most of these TFTs the only thing that changes is the commands. So displaying an image should be the same. Here is my code:

sam_load_raw_image_mem(1,1,72,72, mushroom, sizeof mushroom); void sam_load_raw_image_mem(int x1, int y1, int imgX, int imgY, const uint16_t *img, int size) { sam_clearCs(); sam_setXY(x1, y1,(imgX + x1) -1, (imgY + y1)-1); for (long y = 0; y < size; y++) { sam_writeData((img[y] >> 8), img[y]); } sam_setCs(); sam_clrXY(); } void sam_setXY(int x1, int y1, int x2, int y2) { if (tft_conf.orient == LANDSCAPE) { swap(int, x1, y1); swap(int, x2, y2) y1 = tft_conf.height - y1; y2 = tft_conf.height - y2; swap(int, y1, y2) } if(tft_conf.tft_model == ILI9325D_8 || tft_conf.tft_model == ILI9325D_16 ){ sam_writeComData(0x20, x1); sam_writeComData(0x21, y1); sam_writeComData(0x50, x1); sam_writeComData(0x52, y1); sam_writeComData(0x51, x2); sam_writeComData(0x53, y2); sam_writeCom(0x22); } else if(tft_conf.tft_model == SSD1963_480){ swap(int, x1, y1); swap(int, x2, y2); sam_writeCom(0x2a); sam_writeByteData(x1>>8); sam_writeByteData(x1); sam_writeByteData(x2>>8); sam_writeByteData(x2); sam_writeCom(0x2b); sam_writeByteData(y1>>8); sam_writeByteData(y1); sam_writeByteData(y2>>8); sam_writeByteData(y2); sam_writeCom(0x2c); } else if( tft_conf.tft_model == SSD1289){ sam_writeComData(0x44,(x2<<8)+x1); sam_writeComData(0x45,y1); sam_writeComData(0x46,y2); sam_writeComData(0x4e,x1); sam_writeComData(0x4f,y1); sam_writeCom(0x22); } } void sam_writeData(uint8_t vh, uint8_t vl) { sam_setRs(); switch(tft_conf.tft_model){ case ILI9325D_8: sam_writeBus(vh, vl); break; case ILI9325D_16: case SSD1963_480: case SSD1289: sam_write16ToTFT(vh,vl); sam_pulseBitLow(); break; default: printf("Device not recognized\n\r"); break; } } void sam_write16ToTFT(uint8_t vh, uint8_t vl){ REG_PORT_OUTCLR1 = PORTBMASK_16; REG_PORT_OUTSET1 = ( ((vl | (vh) << 8)) & 0xFFFF); }

The function

sam_load_raw_image_mem

works for the SSD1963 and ILI9325, but cuts off the image on the SSD1289. Any help is much appreciated.