In ST7735_t3 : tft.Print and tft.Println do not print spaces

Good afternoon - The Adafruit display should work with previously defined tab color: tft.initR(INITR_MINI160x80);
I don't believe theirs is an S... Could be wrong. But fingers crossed should be the same as before... I thought I had one around here, earlier, but don't see it right now, new one should arrive with my Mouser order.
 
Good Evening,

Maybe it also is an S display, but they definitely configured it differently. So will keep fingers crossed that most of them follow one or the other...

EDIT: Tomorrow or so the new Adafruit display 160x80 will arrive. So of course the one I thought I already had... I just found :eek: And looks like it works, the same as yours.

So looks like I should organize some of my junk! It was buried in my sensors box and not in the displays box. Probably should organize this a lot more!
 
Last edited:
To update the issues that I originally posted about....in case someone is coming across this thread...

Regarding a .96 80X160 screen like this one https://www.banggood.com/Geekcreit-...-p-1370911.html?rmmds=search&cur_warehouse=CN (I mention this because different screens are used in the thread).

Using ST7735_t3 that can be installed using Teensyduino 1.53 and choosing: tft.initR(INITR_MINI160x80_ST7735S); the issues that I mentioned in my OP are fixed. That option was not available before and results in a modified command set in ST7735_t3. I did not test everything outside of the issues mentioned.

Even the colors do not need to be #defined as inversion is correctly set. I note that CASET and RASET are set to slightly different values that I had kludged, but they seem to work fine suggesting that I don't completely understand CASET and RASET :)

Good Deal!
 
Print space problem with ILI9341_t3n.h

tft.print("Init Program"). "Init_Program" is an file name from SD Card. Thanks for a little help my friend ;)

20241127_011943.jpg


C++:
// Draw a character
void ILI9341_t3n::drawChar(int16_t x, int16_t y, unsigned char c,
  uint16_t fgcolor, uint16_t bgcolor, uint8_t size_x,
  uint8_t size_y)
{
  if ((x >= _width) ||              // Clip right
    (y >= _height) ||               // Clip bottom
    ((x + 6 * size_x - 1) < 0) ||   // Clip left  TODO: is this correct?
    ((y + 8 * size_y - 1) < 0))     // Clip top   TODO: is this correct?
    return;
  if (c == 32)
  {
    if (fgcolor == bgcolor)
    {
      if (size_x == 2)
        fillRect(x, y, CHAR_width, CHAR_height - 1, COLOR_BACKGROUND);
      else
        fillRect(x, y, CHAR_width_small, CHAR_height_small, COLOR_BACKGROUND);
    }
    else if (size_x == 2)
      fillRect(x, y, CHAR_width, CHAR_height - 1, bgcolor);
    else
      fillRect(x, y, CHAR_width_small, CHAR_height_small, bgcolor);
  }
  else if (fgcolor == bgcolor)
  {
    // This transparent approach is only about 20% faster
    if ((size_x == 1) && (size_y == 1))
    {
      uint8_t mask = 0x01;
      int16_t xoff, yoff;
      for (yoff = 0; yoff < 8; yoff++)
      {
        uint8_t line = 0;
        for (xoff = 0; xoff < 5; xoff++)
        {
          if (font[c * 5 + xoff] & mask)
            line |= 1;
          line <<= 1;
        }
        line >>= 1;
        xoff = 0;
        while (line)
        {
          if (line == 0x1F)
          {
            drawFastHLine(x + xoff, y + yoff, 5, fgcolor);
            break;
          }
          else if (line == 0x1E)
          {
            drawFastHLine(x + xoff, y + yoff, 4, fgcolor);
            break;
          }
          else if ((line & 0x1C) == 0x1C)
          {
            drawFastHLine(x + xoff, y + yoff, 3, fgcolor);
            line <<= 4;
            xoff += 4;
          }
          else if ((line & 0x18) == 0x18)
          {
            drawFastHLine(x + xoff, y + yoff, 2, fgcolor);
            line <<= 3;
            xoff += 3;
          }
          else if ((line & 0x10) == 0x10)
          {
            drawPixel(x + xoff, y + yoff, fgcolor);
            line <<= 2;
            xoff += 2;
          }
          else
          {
            line <<= 1;
            xoff += 1;
          }
        }
        mask = mask << 1;
      }
    }
    else
    {
      uint8_t mask = 0x01;
      int16_t xoff, yoff;
      for (yoff = 0; yoff < 8; yoff++)
      {
        uint8_t line = 0;
        for (xoff = 0; xoff < 5; xoff++)
        {
          if (font[c * 5 + xoff] & mask)
            line |= 1;
          line <<= 1;
        }
        line >>= 1;
        xoff = 0;
        while (line)
        {
          if (line == 0x1F)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, 5 * size_x, size_y,
              fgcolor);
            break;
          }
          else if (line == 0x1E)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, 4 * size_x, size_y,
              fgcolor);
            break;
          }
          else if ((line & 0x1C) == 0x1C)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, 3 * size_x, size_y,
              fgcolor);
            line <<= 4;
            xoff += 4;
          }
          else if ((line & 0x18) == 0x18)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, 2 * size_x, size_y,
              fgcolor);
            line <<= 3;
            xoff += 3;
          }
          else if ((line & 0x10) == 0x10)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, size_x, size_y,
              fgcolor);
            line <<= 2;
            xoff += 2;
          }
          else
          {
            line <<= 1;
            xoff += 1;
          }
        }
        mask = mask << 1;
      }
    }
  }
  else
  {
    // This solid background approach is about 5 time faster
    uint8_t xc, yc;
    uint8_t xr, yr;
    uint8_t mask = 0x01;
    uint16_t color;
    // We need to offset by the origin.
    x += _originx;
    y += _originy;
    int16_t x_char_start = x; // remember our X where we start outputting...
    if ((x >= _displayclipx2) ||                   // Clip right
      (y >= _displayclipy2) ||                   // Clip bottom
      ((x + 6 * size_x - 1) < _displayclipx1) || // Clip left  TODO: this is not correct
      ((y + 8 * size_y - 1) < _displayclipy1))   // Clip top   TODO: this is not correct
      return;
    // need to build actual pixel rectangle we will output into.
    int16_t y_char_top = y; // remember the y
    int16_t w = 6 * size_x;
    int16_t h = 8 * size_y;
    if (x < _displayclipx1)
    {
      w -= (_displayclipx1 - x);
      x = _displayclipx1;
    }
    if ((x + w - 1) >= _displayclipx2)
      w = _displayclipx2 - x;
    if (y < _displayclipy1)
    {
      h -= (_displayclipy1 - y);
      y = _displayclipy1;
    }
    if ((y + h - 1) >= _displayclipy2)
      h = _displayclipy2 - y;

    beginSPITransaction(_SPI_CLOCK);
    setAddr(x, y, x + w - 1, y + h - 1);
    y = y_char_top; // restore the actual y.
    writecommand_cont(ILI9341_RAMWR);
    for (yc = 0; (yc < 8) && (y < _displayclipy2); yc++)
    {
      for (yr = 0; (yr < size_y) && (y < _displayclipy2); yr++)
      {
        x = x_char_start; // get our first x position...
        if (y >= _displayclipy1)
        {
          for (xc = 0; xc < 5; xc++)
          {
            if (font[c * 5 + xc] & mask)
            {
              color = fgcolor;
            }
            else
            {
              color = bgcolor;
            }
            for (xr = 0; xr < size_x; xr++)
            {
              if ((x >= _displayclipx1) && (x < _displayclipx2))
              {
                writedata16_cont(color);
              }
              x++;
            }
          }
          for (xr = 0; xr < size_x; xr++)
          {
            if ((x >= _displayclipx1) && (x < _displayclipx2))
            {
              writedata16_cont(bgcolor);
            }
            x++;
          }
        }
        y++;
      }
      mask = mask << 1;
    }
    writecommand_last(ILI9341_NOP);
    endSPITransaction();
  }
}
 
Last edited:
I solved my problem. I commented out the code lines in ILI9341_tn3.cpp Draw a character

20241127_211838.jpg


C++:
// Draw a character
void ILI9341_t3n::drawChar(int16_t x, int16_t y, unsigned char c,
  uint16_t fgcolor, uint16_t bgcolor, uint8_t size_x,
  uint8_t size_y)
{
  if ((x >= _width) ||              // Clip right
    (y >= _height) ||               // Clip bottom
    ((x + 6 * size_x - 1) < 0) ||   // Clip left  TODO: is this correct?
    ((y + 8 * size_y - 1) < 0))     // Clip top   TODO: is this correct?
    return;
/*              // change RD
  if (c == 32)
  {
    if (fgcolor == bgcolor)
    {
      if (size_x == 2)
        fillRect(x, y, CHAR_width, CHAR_height - 1, COLOR_BACKGROUND);
      else
        fillRect(x, y, CHAR_width_small, CHAR_height_small, COLOR_BACKGROUND);
    }
    else if (size_x == 2)
      fillRect(x, y, CHAR_width, CHAR_height - 1, bgcolor);
    else
      fillRect(x, y, CHAR_width_small, CHAR_height_small, bgcolor);
  }
  else if (fgcolor == bgcolor)
  */
  if (fgcolor == bgcolor) // change RD
  {
    // This transparent approach is only about 20% faster
    if ((size_x == 1) && (size_y == 1))
    {
      uint8_t mask = 0x01;
      int16_t xoff, yoff;
      for (yoff = 0; yoff < 8; yoff++)
      {
        uint8_t line = 0;
        for (xoff = 0; xoff < 5; xoff++)
        {
          if (font[c * 5 + xoff] & mask)
            line |= 1;
          line <<= 1;
        }
        line >>= 1;
        xoff = 0;
        while (line)
        {
          if (line == 0x1F)
          {
            drawFastHLine(x + xoff, y + yoff, 5, fgcolor);
            break;
          }
          else if (line == 0x1E)
          {
            drawFastHLine(x + xoff, y + yoff, 4, fgcolor);
            break;
          }
          else if ((line & 0x1C) == 0x1C)
          {
            drawFastHLine(x + xoff, y + yoff, 3, fgcolor);
            line <<= 4;
            xoff += 4;
          }
          else if ((line & 0x18) == 0x18)
          {
            drawFastHLine(x + xoff, y + yoff, 2, fgcolor);
            line <<= 3;
            xoff += 3;
          }
          else if ((line & 0x10) == 0x10)
          {
            drawPixel(x + xoff, y + yoff, fgcolor);
            line <<= 2;
            xoff += 2;
          }
          else
          {
            line <<= 1;
            xoff += 1;
          }
        }
        mask = mask << 1;
      }
    }
    else
    {
      uint8_t mask = 0x01;
      int16_t xoff, yoff;
      for (yoff = 0; yoff < 8; yoff++)
      {
        uint8_t line = 0;
        for (xoff = 0; xoff < 5; xoff++)
        {
          if (font[c * 5 + xoff] & mask)
            line |= 1;
          line <<= 1;
        }
        line >>= 1;
        xoff = 0;
        while (line)
        {
          if (line == 0x1F)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, 5 * size_x, size_y,
              fgcolor);
            break;
          }
          else if (line == 0x1E)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, 4 * size_x, size_y,
              fgcolor);
            break;
          }
          else if ((line & 0x1C) == 0x1C)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, 3 * size_x, size_y,
              fgcolor);
            line <<= 4;
            xoff += 4;
          }
          else if ((line & 0x18) == 0x18)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, 2 * size_x, size_y,
              fgcolor);
            line <<= 3;
            xoff += 3;
          }
          else if ((line & 0x10) == 0x10)
          {
            fillRect(x + xoff * size_x, y + yoff * size_y, size_x, size_y,
              fgcolor);
            line <<= 2;
            xoff += 2;
          }
          else
          {
            line <<= 1;
            xoff += 1;
          }
        }
        mask = mask << 1;
      }
    }
  }
  else
  {

    // This solid background approach is about 5 time faster
    uint8_t xc, yc;
    uint8_t xr, yr;
    uint8_t mask = 0x01;
    uint16_t color;

    // We need to offset by the origin.
    x += _originx;
    y += _originy;
    int16_t x_char_start = x; // remember our X where we start outputting...

    if ((x >= _displayclipx2) ||                   // Clip right
      (y >= _displayclipy2) ||                   // Clip bottom
      ((x + 6 * size_x - 1) < _displayclipx1) || // Clip left  TODO: this is not correct
      ((y + 8 * size_y - 1) < _displayclipy1))   // Clip top   TODO: this is not correct
      return;

    // need to build actual pixel rectangle we will output into.
    int16_t y_char_top = y; // remember the y
    int16_t w = 6 * size_x;
    int16_t h = 8 * size_y;

    if (x < _displayclipx1)
    {
      w -= (_displayclipx1 - x);
      x = _displayclipx1;
    }
    if ((x + w - 1) >= _displayclipx2)
      w = _displayclipx2 - x;
    if (y < _displayclipy1)
    {
      h -= (_displayclipy1 - y);
      y = _displayclipy1;
    }
    if ((y + h - 1) >= _displayclipy2)
      h = _displayclipy2 - y;


    beginSPITransaction(_SPI_CLOCK);
    setAddr(x, y, x + w - 1, y + h - 1);
    y = y_char_top; // restore the actual y.
    writecommand_cont(ILI9341_RAMWR);

    for (yc = 0; (yc < 8) && (y < _displayclipy2); yc++)
    {
      for (yr = 0; (yr < size_y) && (y < _displayclipy2); yr++)
      {
        x = x_char_start; // get our first x position...
        if (y >= _displayclipy1)
        {
          for (xc = 0; xc < 5; xc++)
          {
            if (font[c * 5 + xc] & mask)
            {
              color = fgcolor;
            }
            else
            {
              color = bgcolor;
            }
            for (xr = 0; xr < size_x; xr++)
            {
              if ((x >= _displayclipx1) && (x < _displayclipx2))
              {
                writedata16_cont(color);
              }
              x++;
            }
          }
          for (xr = 0; xr < size_x; xr++)
          {
            if ((x >= _displayclipx1) && (x < _displayclipx2))
            {
              writedata16_cont(bgcolor);
            }
            x++;
          }
        }
        y++;
      }
      mask = mask << 1;
    }
    writecommand_last(ILI9341_NOP);
    endSPITransaction();
  }
}
 
Last edited:
I'll be powering up a T_4.1 with ILI9341.

Can you post a simple example program that shows the issue to repro test?

When looking here in _T3N that code is not present and already fixed? : https://github.com/KurtE/ILI9341_t3n/blob/master/src/ILI9341_t3n.cpp#L3261

Also not seeing it on the PJRC source _T3:
 
Back
Top