Drawing bitmaps into arrays for displaying multiple bitmaps CORRECTLY

Status
Not open for further replies.
Wel the teensy harware ili9341_t3 uses reset at 3.3v but gives it a 255 as the out put. I will look at both versions and see. I really do not want to open the case back up.

Wait let me check that again.......
 
Last edited:
ok I put kurts and franks Begin() side by side using two widows in sublime text. I love this program!!!! But I'm still learning what it can do. Any way... so there doesn't seem to be a difference between frank or kurts t3 library on the begin or anthing , yet franks gives the pwm at 255 but comments after the define that if not used pin to 3.3v.

Edit:::

Looked at all my libraries begin() functions and all the rst parts are the same. And the others use 3.3v. So I should be fine unless Kurt put something in that I'm not seeing.

Edit::::

It's says that RST is optional but when ever I try to compile it compiles but the teensy never boots so no displaying on screen.

Edit::::: turned the rst off but it only prints out a small portion
 
Last edited:
I've been playing with the t3n library. I tried reversing the 320x240 but that did the same thing my master library by making a spot where nothing appears at all. I also played with the rotation. No better results so far. I can only get a quarter of the tilemap to show. I wrote a fillScreen(Black); in the appropriate place in my begin but it stops at the dead spots well but as before the player shows up everywhere.

oops... I must have dropped in the version of tilemap, just looked at it to make sure I was correct and it seems I need to do some more tweaking......... Ok just re compiled the updated function and now I get as much map as I did before. But the fill screen has a dead spot as well. ill post a pic.....

I know this is off topic, but the snake trails are starting to annoy me. Ok look at this function in my dune demo...

Code:
  if (ButtonUp.fallingEdge()){

    /////  display character from rear
      tft.drawBitmap1(player_x, player_y,paul_rearblack,16,16,BLACK);
        tft.drawBitmap1(player_x, player_y,paul_rearblue,16,16,BLUE);
         tft.drawBitmap1(player_x, player_y,paul_rearbrown,16,16,BROWN);
          tft.drawBitmap1(player_x, player_y,paul_reargrey,16,16,GREY);
           tft.drawBitmap1(player_x, player_y,paul_rearpink,16,16,PINK);
            tft.drawBitmap1(player_x, player_y,paul_rearred,16,16,RED);


         ////// extra set to animate the players walk
        tft.drawBitmap1(player_x, player_y,paul_rearw1black,16,16,BLACK);
         tft.drawBitmap1(player_x, player_y,paul_rearw1blue,16,16,BLUE);
          tft.drawBitmap1(player_x, player_y,paul_rearw1brown,16,16,BROWN);
           tft.drawBitmap1(player_x, player_y,paul_rearw1grey,16,16,GREY);
            tft.drawBitmap1(player_x, player_y,paul_rearw1pink,16,16,PINK);
             tft.drawBitmap1(player_x, player_y,paul_rearw1red,16,16,RED);

                player_direction = 1;        /////stops and displays current player direction
             player_y = player_y - 5;}    /////moves player
 //            if(checkcolision())player_y--;} /////// checks collision with bitmap images in tilemap
//           if(player_y <= 0){  /////stops player from going off screen 
//              player_y = 0;}    stops player from going off screen

I need to place something in between the first set of bitmaps and the second , then another after the second set of bitmaps and before the player direction so 1 I can get the animation of switching between bitmaps and stop the snake trails. Ive tried updateScreen() and clearscreen(). Fill screen kind of works but blurs the character and kills any bitmaps in an array because its constantly writing fill screen over the tilemap.
 
Swapping 320 and 240 could easily go deeper than simple edit - if doing what was apparent doesn't do it - then there are other hardcoded expectations elsewhere. When I did the TOUCH button windows the code was dynamic to clip or arrange in any of 4 rotations.

Not sure what the snake trail erase code looks like? It just needs a blanking (background color) rectangle on the bitmap area before placing the series of new bitmaps since they are transparent. If the first command were to BLACK the whole 'new' area where the colors are added - then only the small abandoned 'old' portion would need an extra blanking 'behind' ( may be under/over/left/right ) based on the direction of movement and the distance of the move - is it always '5'?
 
In post #21, at the top, kurt asked about the internal settings were to height(); and width() since I as changing everything that read ili9341_tftwidth or height in the code to height() and width(). Honestly I don't know. in the t3n library I have all these

Code:
#define GrafxT3_TFTWIDTH  240
#define GrafxT3_TFTHEIGHT 320

int16_t width(void)  { return _width; }
	int16_t height(void) { return _height; }


	int16_t _width, _height; // Display w/h as modified by current rotation

////from cpp
#define WIDTH  GrafxT3_TFTWIDTH
#define HEIGHT GrafxT3_TFTHEIGHT

Is all that correct?

 
In post #21, at the top, kurt asked about the internal settings were to height(); and width() since I as changing everything that read ili9341_tftwidth or height in the code to height() and width(). Honestly I don't know. in the t3n library I have all these

Is all that correct?

That post#30 code looks like the same code that is in the _t3 code - so it should work to return the rotationally corrected values as used internal to the LIB to reject out of bounds x,y settings. But then everything in the code using those values must calculate from those run time values - not compile time #define's or other hard coded math.

I would draw out general pictures of the screen space as used in any rotation { for whatever screen layout is in the current game }. What is the active game area within _width/_height and what area is reserved for stats/scores etc. (if any). In the active game area any 'right or bottom' drawing must be held back by (exactly) the width or height of the element on a zero based offset to that limit whether it is 1 pixel or 16 pixel bitmap - within that area. From what I've scanned in the thread that is where this is falling down. This is what Kurt's idea to show the expected x,y coordinates for running y rows to the end and jumping x pixels down at screen's edge would show.

My earlier note on 'color printing' for instance could be used to put a colored rectangle over each row (of bitmap height?) as it is drawn. Any area not filled (or over filled) is miscalculated - any rectangle in the wrong place will show itself. Then on each increment of the row rectangle change the color as it progresses down the screen. This is debug only - so make an easy way to enable/disable it. It can slow things down - perhaps purposefully add a delay(100) - so you can watch it work and see what it is really doing as it does it. I've done this and other things as I played with stuff as swapping x/y is easy - or forgetting to include buffer spaces or just having the wrong math.
 
Quick notes:

I asked if TFT.width() and TFT.height() were returning the correct values, as it sounded like you were messing around with the libraries #defines for width and height and the code uses these:
Code:
void ILI9341_t3n::setRotation(uint8_t m)
{
	rotation = m % 4; // can't be higher than 3
	beginSPITransaction();
	writecommand_cont(ILI9341_MADCTL);
	switch (rotation) {
	case 0:
		writedata8_last(MADCTL_MX | MADCTL_BGR);
		_width  = ILI9341_TFTWIDTH;
		_height = ILI9341_TFTHEIGHT;
		break;
	case 1:
		writedata8_last(MADCTL_MV | MADCTL_BGR);
		_width  = ILI9341_TFTHEIGHT;
		_height = ILI9341_TFTWIDTH;
		break;
	case 2:
		writedata8_last(MADCTL_MY | MADCTL_BGR);
		_width  = ILI9341_TFTWIDTH;
		_height = ILI9341_TFTHEIGHT;
		break;
	case 3:
		writedata8_last(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR);
		_width  = ILI9341_TFTHEIGHT;
		_height = ILI9341_TFTWIDTH;
		break;
	}
	endSPITransaction();
	setClipRect();
	setOrigin();
	
	cursor_x = 0;
	cursor_y = 0;
}

So if you simply change the #define values like ILI9341_TFTWIDTH to something else, the code won't work right with the hardware.

Note: I am not currently planning to run/debug your code in your current state (I have my own code/hardware to debug ;) ) however will try to help you help yourself fix the issues.

Right now I have no clue if you followed through on any of the previous suggestions/issues as each posting feels like you are jumping all over everywhere and I am not sensing that you have followed through on any of the main things.

Like:
a) Like in the code where it is initing the positions of the objects... Print them out. Do they make sense?

b) Have you made a pass through the code, fixing any place that still uses byte for coordinates? What about width and height? Can any of your objects have a dimension > 255, in which case they also need to be extended... Like:
Code:
typedef struct
{
  byte x;
  byte y;
  byte w;
  byte h;
  boolean exist;
}  BrickStruct;
b1) Actually I would do a global search for the word byte and see if you have any places that might do something like:
for (byte x = 0; x < ???; x += ????)
As again these will not work either...

c) If you have fixed arrays like: BrickStruct Brick[BrickRows][BrickColsMax];
Which depend on some constant... Will it work in all dirctions? That is if BrickRows = 10 but you use up to 15, you are playing with fire... If you are set on using 2 dimensional arrays, you can always waste memory and define it like Brick[16][16]...

But alternatively you could define it as single dimensional array and compute the index... Where the max number of bricks needed is something like:
max(Grafx_TFTWIDTH, Grafx_TFTHEIGHT)/(BrickSpaceX+BrickW) * 6...

Good luck
 
Sorry like I said the break out game was just an example of more code that won't print all the way across the screen. On the post above in the code locks. Yes I assure you that all the internal values match properly. That's something I change when setting up the library for my needs. If you don't do it correctly the compiler gives you error messages.

Everything seems to be printing when I use debug code. If I move the tilemap map in my dune demo or the positions of the bricks in break out the serial print prints out what I have told it to. It will also move and show the missing bricks/tiles when I play with the position.

Maybe I need to change the values to opposite in my functions? Like if it says TFTWIDTH change it to TFTHEIGHT?

I understand about changing byte into int in the break out code but the Tilemap code does use int for placement.
 
M-o-o-n! That spells progress. Lol.

Ok so I reversed the TFTWIDTH and height in my tilemap function but no change. So I went back up the cpp page till I got to fillScreen and changed those width and height then compiled and I now get full screen with the tilemap. I made it bigger last night to test out my camera controls that scroll the character.

One more thing down guys. You guys have so much patience with me and I really appreciate it.



So I just need to fix the snake trails which to be honest really can't be seen with tilemap in place if they are any color but black. But any black pixels and the snake trail can be seen.

Looks like I have it right but I call fill screen black in the begin() which goes in the set up. But it's still only filling up the screen partially with black and creating a dead zone that's white still on the right.
 
If fillscreen is not working, try putting a few print statements in a few places, like
In setRotation print value and new width and height. Then in fillscreen print out bounding rectangle and then maybe have clues. Like is the hardware sei in portrait mode but outputting like it was in landscape mode
 
Hmmmmm ok, I can check that. I get what your saying.

All right so my next problem is kind of funky. I had made a bigger tilemap last night just out of boredom and so I can test the camera controls. Basically it turns your character Sprite into a cursor you can scroll around a back ground or tilemap. The player Sprite has always been slow on top of the tilemap making me up the integer for how fast he moves but with the camera controls, I've tried setting them from 5 which was normal all the way to 20 with no change.

The other thing is kinda huge. The player Sprite flashes on the screen when he's on top of tiles. But no trail. So how can I make the character solid? Also the tilemap itself flashes as well.

here is the code for the camera
Code:
int camerax = 160 ;
 int cameray = 120 ;
 int xmax = 160;
////////////////////////////////////////////////
/////////////////camera controls////////////////
////////////////////////////////////////////////

        if(player_x > 160 && camerax < 0 && camerax > -160) {player_x = 160;camerax--;}
//value 59 equals player position on right when camera will start to follow 
//value 0 and -52 equals camers boundary positions
      else  if(player_x < 160 && camerax <  0 && camerax  > -160){player_x = 160;camerax++;}
//value 15 equals player position on left when camera will start to follow
//value 0 and -52 equals camera boundary positions 
      else  if(player_x > 160 && camerax <= 0 && camerax >= -160)camerax--;
      else  if(player_x < 160 && camerax <= 0 && camerax >= -160)camerax++;
      if(player_y > 160 && cameray < 0 && cameray >  -160){player_y = 160;cameray--;}
//value 28 equals player position on right when camera will start to folow
//value 0 and -40 equals camera boundary positions 
      else  if(player_y < 120 && cameray < 0 && cameray >  -120){player_y = 120;cameray++;}
//value 15 equals player position on left when camera will start to follow
//value 0 and -40 equals camera boundary positions
     else  if(player_y > 120 && cameray <= 0 && cameray >= -120)cameray--;
     else  if(player_y < 120 && cameray <= 0 && cameray >= -120)cameray++;

           if(camerax > 0)camerax= 0;
     else  if(camerax < -160) camerax = -160;
//value 0 and -52 equals camera boundary positions
           if(cameray > 0)cameray= 0;
     else  if(cameray < -120) cameray = -120;
//value 0 and -40 equals camera boundary positions

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

  tft.drawTilemap(camerax, cameray, tilemap1, spritesheet1, BLACK);
   tft.drawTilemap(camerax, cameray, tilemap2, spritesheet2, BROWN);
     tft.drawTilemap(camerax, cameray, tilemap3, spritesheet3, LIGHTBROWN);

I tried adding extra -- and ++ but that gives me lvalue error
 
Last edited:
Status
Not open for further replies.
Back
Top