Menu

ILI9341 sprite

Help
2020-02-14
2020-02-15
  • stan cartwright

    stan cartwright - 2020-02-14

    I got a sprite that has a one pixel background boundary so if it moves 1 pixel in any direction it should erase itself.
    It works for up and down and moving left but not moving right...leaves a trail but only bottom right corner.
    please see video and the minimal code ie left right movement.
    Anobium... Is the sprite write correct please?
    https://www.youtube.com/watch?v=yI_dNADLh4U&feature=youtu.be

    do
    for sprite_x = 80 to 160
    sprite (sprite_x,sprite_y) ;draw sprite
    next
    for sprite_x = 160 to 80
    sprite (sprite_x,sprite_y) ;draw sprite
    next
    loop
    ;
    sub sprite (sprite_x,sprite_y) ;fills box with sprite data
    ;  SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x + sprite_width-1,sprite_y + sprite_height - 1 )
      SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x + 23,sprite_y + 23)
      for ptr=0 to 575 ;sprite_width * sprite_height starting table from 0
        ReadTable lander,ptr,pixel
        SendWord_ILI9341 pixel
      next ptr
    end sub
    
    ;
    table lander
    ;1 2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 21 23 24
    bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk ;1
    bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,wh,wh,wh,wh,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk ;2
    bk,bk,bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk,bk,bk ;3
    bk,bk,bk,bk,bk,bk,wh,bk,bk,bk,wh,wh,wh,wh,bk,bk,bk,wh,bk,bk,bk,bk,bk,bk ;4
    bk,bk,bk,bk,wh,wh,bk,bk,wh,wh,bk,bk,bk,bk,wh,wh,bk,bk,wh,wh,bk,bk,bk,bk ;5
    bk,bk,bk,wh,bk,bk,bk,wh,bk,bk,bk,bk,bk,bk,bk,bk,wh,bk,bk,bk,wh,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,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,bk,bk,bk ;20
    bk,bk,bk,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,bk,bk,bk ;21
    bk,bk,wh,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,wh,bk,bk ;22
    bk,wh,wh,wh,wh,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,wh,wh,wh,wh,bk ;23
    bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk ;24
    end table
    ;
    
     
  • Anobium

    Anobium - 2020-02-15

    Not sure.

    You need to examine the first two draw sequences.

    I would expect that you have move the sprite XY position before resolving the old sprite.

     
  • stan cartwright

    stan cartwright - 2020-02-15

    I tested by just sending the sprite but changed the table so that the right edge is all white pixels not black and got the image.
    This fault has not shown until now due to not erasing sprite but over printing with background pixels surrounding the sprite.
    In the picture the vertical line is on the left of the sprite but in the table it's on the right side.

    sprite (sprite_x,sprite_y) ;draw sprite
    do
    loop
    ;
    sub sprite (sprite_x,sprite_y) ;fills box with sprite data
    ;  SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x + sprite_width-1,sprite_y + sprite_height - 1 )
      SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x + 23,sprite_y + 23 )
      for ptr=0 to 576 ;(sprite_width * sprite_height)
      :THIS MUST BE for ptr=1 to 576 to work 
        ReadTable lander,ptr,pixel
        SendWord_ILI9341 pixel
      next ptr
    end sub
    ;
    table lander
    bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh
    bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,wh,wh,wh,wh,wh,bk,bk,bk,bk,bk,bk,bk,bk,wh
    bk,bk,bk,bk,bk,bk,b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bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,wh
    bk,bk,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,bk,wh
    bk,bk,bk,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,bk,bk,wh
    bk,bk,bk,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,bk,bk,wh
    bk,bk,bk,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,bk,bk,wh
    bk,bk,wh,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,wh,bk,wh
    bk,wh,wh,wh,wh,wh,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh,wh,wh,wh,wh,wh
    bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,wh
    end table
    
     

    Last edit: stan cartwright 2020-02-15
  • Anobium

    Anobium - 2020-02-15

    So, all sorted? You know how to proceed?

     
    • stan cartwright

      stan cartwright - 2020-02-15

      sorted..Not really.
      I used for ptr=0 to 576 ;(sprite_width * sprite_height).....0 to 575 tried.
      When I look at the ili9341 include file
      '''Set the row or column address range for the ILI9341 GLCD
      '''@param ILI9341AddressType Address Type (ILI9341_ROW or ILI9341_COLUMN)
      '''@param ILI9341Start Starting address
      '''@param ILI9341End Ending address
      '''@hide
      Sub SetAddressWindow_ILI9341( , in _x2 as word, in _y2 as word)

      SendCommand_ILI9341(ILI9341_CASET); // Column addr set
      SendData_ILI9341 _x1_H
      SendData_ILI9341 _x1
      SendData_ILI9341 _x2_H
      SendData_ILI9341 _x2

      SendCommand_ILI9341(ILI9341_PASET); // Row addr set
      SendData_ILI9341 _y1_H
      SendData_ILI9341 _y1
      SendData_ILI9341 _y2_H
      SendData_ILI9341 _y2

      SendCommand_ILI9341(ILI9341_RAMWR); // write to RAM

      End Sub

      seems I got rid of In _x1 as word, in _y1 as word
      but there's something fundamental I don't understand and as anobium wrote the glcd stuff,
      he is best to answer.
      Your glcd stuff is brill...I just want to steal your code to get what I want to do but not very good at it. This writing data shapes to ili devices might be universal ....or not
      but it's faster than pset ing the data.

       
      • stan cartwright

        stan cartwright - 2020-02-15

        Do I have to set all prameters to use this ili9341 method of writing data ie each line?

        I liked when video was in ram...and you can play with ram.
        The ssd1306 was a good if small example.
        my other hobbies are...less thinking

         
  • stan cartwright

    stan cartwright - 2020-02-15

    Sorted. This is the line---- for ptr=0 to 575 ;(sprite_width * sprite_height)

    the table must start at 1 it seems for ptr=1 to 576 ;(sprite_width * sprite_height)
    Anobium. you posted start at zero. https://sourceforge.net/p/gcbasic/discussion/579126/thread/8ffff73946/ You were wrong mate.
    The sprite is now 100% ok
    just that line did my head in....now on to arrays,ha,ha....not
    http://www.youtube.com/watch?v=tYbtej5KEAghttps
    the Sub SetAddressWindow_ILI9341( , in _x2 as word, in _y2 as word) and other stuff is useful and no one else has done it...which is a downer as more people are needed. Gcb can't run off a few people.

     

    Last edit: stan cartwright 2020-02-15
  • stan cartwright

    stan cartwright - 2020-02-15
     

    Last edit: stan cartwright 2020-02-16

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.