RA8875: Layers and Touch Panel Controller

Status
Not open for further replies.

christoph

Well-known member
I currently have two problems with my RA8875 display (480*272 pixels).

1) Layers (FIXED, nevermind). If I'm not mistaken I can make use of two layers on this display. It should be able to draw on one layer, while displaying the other. When all drawing is done, I can switch between them to get flicker-free updates.

The layer that is drawn on is selected in MWCR1, bit 0. Selecting the visible layer is done in LPTR0, bit 0. Is there any other trick to using the two layers? Because when I select a layer this way, my display simply shows nothing at all.

Turns out I forgot to activate two-layer operation in DPCR, bit 7. The updates are somewhat flicker-free, better than before.

2) Touch Screen Controller. I enable the controller with these commands (register names and bit definitions snatched from sumotoy):
Code:
write_reg8(g, RA8875_TPCR0, 0x80 | RA8875_TPCR0_WAIT_16384CLK | RA8875_TPCR0_ADCCLK_DIV16); gfxSleepMilliseconds(1);
write_reg8(g, RA8875_TPCR1, RA8875_TPCR1_AUTO | RA8875_TPCR1_DEBOUNCE); gfxSleepMilliseconds(1);
This should enable the touch screen controller with a sufficiently slow ADC clock (less than 10 MHz, my F_SYS is 60 MHz). Regardless of auto mode and debouncing, the status register should show me when the screen is being pressed. I am confident that my write_reg8 function works, I use it for the whole initialization of my display. Again: Am I missing something?
 
Last edited:
I think I partially understand what's happening. The status register doesn't show any touch events, although it has a "Touch Panel Event Detected" flag. That stays zero no matter what. The Touch Panel X/Y Low Byte Register has the ADET flag, which should also show if the panel is being touched. That one stays at 1 (not touched).

The interrupt register (INTC2) shows valid data: The touch panel interrupt flag is set when I touch the panel. X/Y data is then debounced and latched in the corresponding registers TPXH, TPYH, TPXYL. I can read it and clear the interrupt flag by writing to INTC2. If I do do that while still touching the panel, new coordinates are latched immediately. That allows me to drag over the display (that's good).
 
When I swap layers (draw on layer 1, show layer 2 -> draw on layer 2, show layer 1) I get a short period of black screen. Is there a way to get around this? This flickering is really annoying...the code I use for swapping:
Code:
void ra8875_swap()
{
  static bool draw_1 = true;
  ra8875_acquire_bus();
  if (draw_1) // switch to drawing on layer two
  {
    ra8875_write_index(RA8875_MWCR1);
    ra8875_write_data(1); // active drawing layer: 2
    ra8875_write_index(RA8875_LTPR0);
    ra8875_write_data(0); // active display layer: 1
    draw_1 = false;
  }
  else
  {
    ra8875_write_index(RA8875_MWCR1);
    ra8875_write_data(0); // active drawing layer: 1
    ra8875_write_index(RA8875_LTPR0);
    ra8875_write_data(1); // active display layer: 2
    draw_1 = true;
  }
  // set active window to full screen
  ra8875_write_index(RA8875_HSAW0);
  ra8875_write_data(0);
  ra8875_write_index(RA8875_HSAW1);
  ra8875_write_data(0);
  ra8875_write_index(RA8875_VSAW0);
  ra8875_write_data(0);
  ra8875_write_index(RA8875_VSAW1);
  ra8875_write_data(0);
  ra8875_write_index(RA8875_HEAW0);
  ra8875_write_data((width-1) & 0xFF);
  ra8875_write_index(RA8875_HEAW1);
  ra8875_write_data((width-1) >> 8);
  ra8875_write_index(RA8875_VEAW0);
  ra8875_write_data((height-1) & 0xFF);
  ra8875_write_index(RA8875_VEAW1);
  ra8875_write_data((height-1) >> 8);
  ra8875_write_index(RA8875_MCLR);
  // start clearing active window of active drawing layer
  ra8875_write_data((1<<7) | (1<<6));
  ra8875_release_bus();
}

Regards

Christoph
 
christoph, I don't have any black screen or artifact when I switch layers! I've tried with mine library at 8Mhz SPI and 60Mhz SysClock.
Did you enjoy this journey inside the dense-register-populated world of RA8875??? ;)
 
Maybe I should try drawing a full-screen black rectangle on the invisible layer instead of clearing it...
 
Yes, I even went down to 1 MHz SPI speed while maintaining 60 MHz f_sys. When you switch between layers, do you clear the drawing layer before drawing on it? Anyway, my goal is to have moving widgets with the ugfx widget system. If their moving code properly clears and redraws the affected areas of the screen I'll be fine.
 
I really appreciate you guys are fiddling around with the RA8875.
Has anyone gotten good results with any fonts (going slightly off topic) and/or setting the display to portrait mode?
I loaded some libraries last fall and I got some results, although very slow and thus unable to update data reasonably.
 
I'm using ugfx which allows me to convert and use any ttf font that has a compatible license. It also allows me to draw in portrait mode (in software, but hardware might be possible). The only thing that would make portrait mode a bit harder is the touch screen, because the touch screen coordinate system must be rotated with the screen and some care must be taken to ensure that this actually happens correctly.

Speed seems to be ok if you don't try to redraw the entire screen every 10 ms, and as you can see above we have managed to crank up the allowed SPI speed significantly.
 
It also allows me to draw in portrait mode (in software, but hardware might be possible)
It's possible via hardware, I already managed this in the next version. About the touch you right, I have to use a matrix scheme instead the simple one I'm using actually, it's quite complicated but allow to detect max 3 concurrent touch, funny because many users buy the capacitive I2C version so everithing should be done again for that too... Sigh!
I'm not sure to understand well the issue you have with layers:
1) Perform the command to drive on layer 1
2) draw something on layer 1
3) Perform the command to drive on layer 2
4) Draw something else on layer 2

I do this, the switch on layer 1, draw something else... I cannot see any flickering.
 
Last edited:
I believe that this chip was created by a corean mad scientist that had a trip...
Before using layers I have to instruct _DPCRReg, in that case I need to clear the RA8875 buffer (see my useLayers function).
I clear the RA8875 internal buffer only when I switch layers on, I think the chip reorganize internally the buffer so I got some garbage if I don't do that.
Since layers depends of _MWCR1 register I have grouped everithing in a single function

writeTo(L1); (can be L1, L2, CGRAM, PATTERN, CURSOR)
then I draw something...
now call again writeTo(L2);//this time on layer 2
draw somehing...

The result is the 2 layer showed both on then screen

I have some other function that I can use now:
layerEffect (LAYER1, LAYER2, TRANSPARENT, LIGHTEN, OR, AND, FLOATING) for apply some effect between layers
layerTransparency() where I can change the transparency of each layer
The clear function can clear the current layer or both layers.

I have some examples that use layers, the last one it's vBarsGauge that has 248 colored VU's updated really fast. This uses 2 layers and AND effect so the layer 2 it's updated very fast and mask the layer 1, but there's no flickering.

With this chip it's a real challenge build a library, it's even tricky create some function to get life easier because a register affects some other and so on, you sure notice that.
Actually I have related problems with the sysClock PLL, changing speed it affects a lot of other stuff so changing speed (the 2 registers 88 & 89) means tune up again other registers too or I got something not working as it should.
For example, I was driving chip at 22Mhz and everithing was looking good but I've discovered that text positioning was 80% correct, filled and outline circles looks weird and keypad internal scan stopped but (strangely) the Font ROM was working. Dropping down SPI to 20Mhz fixed the text positioning only but the FontRom was offline...
At the end of the story, have created a mega-sketch that test everithing because sometimes it looks working but some other stuff not, a nightmare (and do not mention BTE, I will fix when I became a buddist priest).
I got the datasheet 2.0 from dec 2014 if you need it!

PS
During digging inside RA8875 registers I had some visions too...
 
Last edited:
Status
Not open for further replies.
Back
Top