Menu

ILI9341 pixel colour demo

2017-11-30
2017-11-30
  • stan cartwright

    stan cartwright - 2017-11-30

    This demos testing a pixels colour. If the next pixel is not black the falling pixels reset to top of the screen. The text and graphics are not erased.
    https://youtu.be/830z7IZIEK8

    #chip mega328p, 16
    #option explicit
    #include <glcd.h>
    #include <UNO_mega328p.h >
    ;
    #define GLCD_TYPE GLCD_TYPE_ILI9341
    #define ILI9341_HardwareSPI
    ;
    #define GLCD_DC       DIGITAL_8         ' Data command line
    #define GLCD_CS       DIGITAL_10          ' Chip select line
    #define GLCD_RESET    DIGITAL_9         ' Reset line
    #define GLCD_DI       DIGITAL_12          ' Data in | MISO
    #define GLCD_DO       DIGITAL_11          ' Data out | MOSI
    #define GLCD_SCK      DIGITAL_13          ' Clock Line
    ;
    #define black 2147483648
    #define red 2163998720
    #define green 2147548160
    #define blue 2147483900
    #define white 2164063484
    #define purple 2163482876
    #define yellow 2164063232
    #define cyan 2147548412
    #define d_gray 2152747088
    #define l_gray 2155360444
    #define silver 2160378052
    #define maroon 2156134400
    #define olive 2156167168
    #define lime 2147548160
    #define aqua 2147548412
    #define teal 2147516548
    #define navy 2147483780
    #define fuchia 2163998972
    ;
    #define GLCD_EXTENDEDFONTSET1
    GLCDfntDefaultsize = 2
    GLCDBackground=ILI9341_BLACK
    GLCDRotate ( Portrait_Rev )
    GLCDCLS ILI9341_BLACK
    ;
    dim pixcol as long
    dim px,py as word
    dim sx (20),sy (20),tmp as word
    ;
    line 0,319,239,319,ILI9341_green
    FilledBox 91,280,151,318,ILI9341_blue
    FilledTriangle 80,279,120,250,160,279,ILI9341_RED
    FilledBox 128,302,140,318,ILI9341_RED
    FilledBox 100,300,120,312,ILI9341_YELLOW
    GLCDPrint 0,120,"P I X E L  T E S T",ILI9341_blue
    ;
    for tmp=1 to 20 ;snow
      sx(tmp)=random
      if sx(tmp)>239 then sx(tmp)=237
      sy(tmp)=random
      pset sx(tmp),sy(tmp),ILI9341_WHITE
    next tmp
    ;main loop
    do
    for tmp=1 to 20 ;falling snow
      pset (sx(tmp),sy(tmp),GLCDBackground)
      sy(tmp)=sy(tmp)+1
      pixcol = ReadPixel_ILI9341( sx(tmp),sy(tmp) )
      if pixcol<>black then
        sy(tmp)=0:sx(tmp)=random
        if sx(tmp)>239 then sx(tmp)=237
      end if
      pset (sx(tmp),sy(tmp),ILI9341_WHITE)
    next tmp
    loop
    
     
  • Anobium

    Anobium - 2017-11-30

    @Stan You telling us? Sharing succss?

     
  • stan cartwright

    stan cartwright - 2017-11-30

    GCB changes daily. Is there a demo for this already? You only changed the include recently.
    Is the way I defined colours wrong? I couldn't change the long pixel colour to gcb word colour. Spent too long trying.
    I'm glad you added the function.
    Add a snowman :)
    or santa moving round and the house shoots missiles....not
    Just gave an idea for a game. snow looks like "star field effect" , just need pixels moving at different speeds. Bored if I posted results? I could do a 4 way move. ie press l,r,u,d and the pixels move opposite direction. with pixels moving at differrent speed it looks very 3D like star trek flying through space.
    What's this got to do with pics you ask.

     

    Last edit: stan cartwright 2017-11-30
  • Anobium

    Anobium - 2017-11-30

    Minimise the code. I am not wanting to figure out from the posting the minimum code to repoduce the issue.

    Change shows that this glcd has not changed, so, minimise the code and post that.

    If this stuff was easy. There would be no challenges. This is probably an error somewhere. The trick is to find the root cause.

     
  • stan cartwright

    stan cartwright - 2017-11-30

    No issue, just a demo. Why read a pixel. dunno, but you can now. dim prob

     

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.