Menu

Anobium b/w pal composite video

2022-01-20
2022-02-17
  • stan cartwright

    stan cartwright - 2022-01-20

    Anobium-
    I have been trying to get composite b/w to work and can put bars on the screen from searching info from others using pic.
    Lots of arduino examples that use "tvout" as include lib. No use to me as I can't convert the c to gcb.
    I need to make a buffer and read it then send to display.
    I thought of the ssd1306 and its buffer but looking at the gcb ssd1306.h include can not figure how to use the glcd graphics to just draw/print to the buffer then have access to it instead of it writing to the ssd1306.
    The pic search says don't use interrupts because of latency whereas arduino tvout lib uses interrupts??
    I'm using a 10"" lcd tv that's analogue rf so useless but it's got composite pal video in and apparently an lcd will tolerate poor sync signals so allowing for errors whereas using an old b/w crt tv would need better sync.

    Not a priority but any thoughts?

     
  • Domenic Cirone

    Domenic Cirone - 2022-01-21

    Take a look at this site:
    http://www.searle.wales/
    Is it useful? I might be able to help porting if you would like but I would need NTSC.

    Domenic

     
  • Anobium

    Anobium - 2022-01-21

    The SSD1306 does use a RAM buffer. It is called SSD1306_BufferAlias()

    You can access the buffer directly using SSD1306_BufferAlias(0..1023) or PixelStatus_SSD1306(GLCDX, GLCDY )

    Where a byte in the array is a pixel representation of the 128x64 display. Where byte are stored using this calculation GLCDX +( GLCDY / 8 )* GLCD_WIDTH + 1. So, think of the pixels being X orientated per byte in the SSD1306_BufferAlias array.

    Hope this helps.

     
  • stan cartwright

    stan cartwright - 2022-01-21

    Thanks. I'll play around and see what happens.

     
  • stan cartwright

    stan cartwright - 2022-01-21

    Anobium, am I right thinking the buffer holds what's been printed/drawn and that it's like a crt tv ie top row then next then next all following in the buffer array? Like zx and cpc464 and bbcmicro, just a block of screen memory.
    I tried this to test and flashes but nothing in the terminal. I probably missed something but is this how to get info from the buffer please?
    I will have to strip the ssd1306 to just do the buffer... not easy but it flashed without a ssd1306 connected.

    #chip mega328p, 16
    #option explicit
    #include <glcd.h>
    
    #define GLCD_TYPE GLCD_TYPE_SSD1306
    ;#define GLCD_I2C_Address 0x78
    GLCDfntDefaultsize=1
    dim pixelrow as Byte
    dim count1 as Byte
    
    GLCDCLS
    box 0,0,127,63
    
    do
    for count1=0 to 127
      serprint 1, SSD1306_BufferAlias(count1)
      wait 1 s
    next
    loop
    
    end
    
     
    • Anobium

      Anobium - 2022-01-22

      Not really Stan. I did say to use the function PixelStatus_SSD1306(GLCDX, GLCDY )


      This uses ANSI to show you the pixel in the GLCD buffer but on serial terminal


      Runs at 11500 BPS cus it has a lot of data to show

      #chip mega328p, 16
      #option explicit
      #include <glcd.h>
      
      
      #define GLCD_TYPE GLCD_TYPE_SSD1306
      
      GLCDfntDefaultsize=1
      dim pixelrow as Byte
      dim countx, county as Word
      dim count1 as Word
      
          'USART settings for USART1
          #define USART_BAUD_RATE 115200
          #define USART_TX_BLOCKING
          #define USART_DELAY OFF
      
      GLCDCLS:  ANSIERASECREEN
      box 0,0,127,63
      GLCDPrint 10,10,"Hello Stan"
      GLCDPrint 10,20,"PUTTY terminal"
      GLCDPrint 10,30,"Exposes "
      GLCDPrint 10,40,"PixelStatus_SSD1306"
      
      
      
      count1 = 0
      wait 3 s
      
        for countx=0 to 127
          for county=0 to 63
            ANSI countx+1, county+1
            if PixelStatus_SSD1306(countx, county ) = 1 then
              hserprint "x"
            else
              hserprint " "
            End if
          next
        next
      
      
      end
      
      
      ;8888888888888888888888 ANSI controls
      
      
      
      
      ; Position cursor on Terminal
      Sub ANSI ( IN ANSIxpos, IN ANSIypos )
          HSerSend 27
          HSerPrint "["
          HSerPrint ANSIypos
          HSerSend 59
          HSerPrint ANSIxpos
          HSerPrint "H"
      End Sub
      
      
      ; Eraase Terminal
      Sub ANSIERASECREEN
          HSerSend 27
          HSerPrint "["
          HSerPrint "2"
          HSerPrint "J"
          Ansi ( 0, 0 )
      
          HSerSend 27
          HSerPrint "["
          HSerPrint "?"
          HSerPrint "25"
          HSerPrint "l"
      
      end Sub
      
       

      Last edit: Anobium 2022-01-22
  • Anobium

    Anobium - 2022-01-22

    If you change the code above to this - you will see the Array address being used.

      for countx=0 to 127
        for county=0 to 63
          'ANSI (countx*4) +1, county+1
          if PixelStatus_SSD1306(countx, county ) = 1 then
            hserprint SSD1306_BufferLocationCalc
          else
            hserprint SSD1306_BufferLocationCalc
          End if
          HSerPrintCRLF
        next
    
      next
    

    You will see the following six (there are 1024 addresses shown in total) array addresses 1, 129,257,385,513,641. Yes.. every 128 because we scanning the array in this in the Y axis. And, you will see is reading the 8 bits from the array element byte. Why this seems odd - it is not. As this is the most optimal.

    Proof - change the For-Next

      for county=0 to 63
        for countx=0 to 127
    

    This will show the array elements being read in sequence 1-2-3-4 but it reading the same sequence 128 more times that the other method.

    So, think of the array holding data as shown is the attachment. Where XY pixels are held in the array.

    :-)

     

    Last edit: Anobium 2022-01-22
  • Anobium

    Anobium - 2022-01-22

    So, as i have no idea how the scan works on a TV - you need to take the next step.

     
  • stan cartwright

    stan cartwright - 2022-01-22

    @Anobium, Thanks for taking the time to explain things, it's appreciated. I should have looked up my uno code for serprint to terminal.
    The info I have is for a pic at 32MHz and the timing is important.
    You get 57uS of visible line scan to shift the byte in a ram buffer and switch a port pin hi/lo.
    It's the 2 port with a resistor in series with each pin joined and that's the composite video out.
    1 pin is b/w video and the other is the horizontal and vertical sync.
    Examples are pic asm and lots of nops to get the timing.
    PixelStatus_SSD1306(GLCDX, GLCDY ) takes probably longer than reading a byte from the buffer array and getting the bit. You don't get much time to do much so anything using multiplication would take too long... maybe. I'll check all options. A 16MHz Uno is twice as fast as a 32MHz pic... yes?
    The idea is using just a ucontroller and software not a cheap sync chip and I've seen rotating line cubes using the method and thinking of the code to do the trig to rotate a cube means there must be some time left to do stuff.
    I got to get as much info as possible because though I can fix old crt tvs I never had to know how the signal was displayed, more the common circuit failures.
    The pal idea of displaying the odd lines 1,3,5 etc then flyback and display even lines 2,4,6 etc probably don't apply to a lcd tv, probably process the signal then send each line.. but not sure.
    Lot's to try. If it works it would be cool.
    Thanks again.

     
  • Anobium

    Anobium - 2022-01-22

    This sub (which is essentially PIXEL_STATUS will toggle the port

    #DEFINE TVOUT PORTB.0
    TVOUT_SSD1306
    END
    
    
    Sub TVOUT_SSD1306
    
      For GLCDY = 0 to 63
          For GLCDX = 0 to 127  
                'Select correct buffer element
                SSD1306_BufferLocationCalc = GLCDY
                'Divide by 8
                Repeat 3
                  Set C Off
                  Rotate SSD1306_BufferLocationCalc Right
                End Repeat
    
                ' multiple by 128
                Set C Off
                Repeat 7
                   Rotate SSD1306_BufferLocationCalc Left
                End Repeat
    
                SSD1306_BufferLocationCalc = GLCDX + SSD1306_BufferLocationCalc+1  'add 1 as we dont use element (0)
                GLCDDataTemp = SSD1306_BufferAlias(SSD1306_BufferLocationCalc)
                'Change data to examine pixel by rotating our bit to bit zero
                GLCDBitNo = GLCDY And 7
                Repeat GLCDBitNo
                  Rotate GLCDDataTemp right
                End Repeat
                TVOUT = GLCDDataTemp.0
          Next
      Next
    end Sub
    

    It still may be faster enough. You will need a scope to see how long it takes.

     
  • stan cartwright

    stan cartwright - 2022-01-22

    That is ... dunno what to say. Thanks. Yes, the idea is for b/w it's just 0 is black and 1 is white.
    Incidentally, I had an email from "you" 2 years ago about composite video on pic then late last year another from "you" with a link to a seminar about snes games and how mario worked in so small memory. Not you I guess.
    Anyway lots to do. Thanks. Any joy and I'll post results.

     
  • stan cartwright

    stan cartwright - 2022-01-22

    It will be For GLCDX = 0 to 127 as it's one line at a time but I haven't tried the 4uS wait then send 64 uS then 4uS wait to do a line yet and stuff I missed. I gave up on this 2 years ago but now it looks more promising.
    I was thinking of a 50Hz interrupt I know and using that to do the display as tv's are 50Hz.. or were.
    Lots to research and do. Thanks for the help. I'll see if any tvs I got with scart have composite video to compare with the 10" lcd tv with comp vid phono socket using to test in case. I never had a b/w tv with comp vid, just an arial socket. Cheers.

     
  • stan cartwright

    stan cartwright - 2022-01-22

    I'm still re reading your post, lots of info, I try to make my code as fast as possible. Little things like don't use and. 2 if thens instead.
    if xxx= yy then if zzz=aaa then. If 1st test fails it doesn't test next whereas and always tests both.
    Probably lots of ways to make your code faster. Don't use subs put them in line. Use goto to end a loop.
    Yes goto. Often seems to make sense. But I don't cos it's bad :( . bet the asm uses jump though :)
    PS only used win putty to connect to rpi. I don't like command lines.

     

    Last edit: stan cartwright 2022-01-22
    • Anobium

      Anobium - 2022-01-23

      :-) Twas me in the past, tis me now.

      Good luck - you have a good start in the code.

       
  • Anobium

    Anobium - 2022-01-23

    I did some very, very basic tests. It take 123ms to send the complete array as bits with array orientation as it currently is. Meaning Y orientated bits. You may need to flip the array bits to X orientated bits so you can stream the bits out faster.

    Remember, the bit orientation matches the 1306 in the library. Making this for a TV is not the same... as you are learning.

     
  • stan cartwright

    stan cartwright - 2022-02-15

    Anobium- if the ssd buffer reads in such a way then it must be written to write the buffer that way.
    https://sourceforge.net/p/gcbasic/discussion/579125/thread/e1557a95ac/0e26/attachment/Screenshot%202022-01-22%20134954.jpg

    I'm going to look at ssd oled and the buffer and see if it could be linear as a continuous copy of the "screen" which is the point, A virtual screen that can be read and with an interrupt and some code could be composite video. Lots of timing. but I'm interested.

     
    • Anobium

      Anobium - 2022-02-16

      Correct approach.

      The representation in RAM of the display needs to optimised for the target display. Trying to using wrong representation will work... it will just be very slow.

      Give it a go

       
  • stan cartwright

    stan cartwright - 2022-02-16

    Thanks Anobium. Am I correct that a uno/nano 328 @16MHz is an instruction every clock so would16 nops would take 1uS ? Seems timing is the main problem.
    I also wonder if composite pal is the same on an old crt tv as it is on a lcd monitor as the guide I'm using is for a crt tv which were slow so more sync. Lcd would have no flyback period.

     
    • Anobium

      Anobium - 2022-02-16

      I would check the data sheet. I am not able to check.

      LGT will be a lot faster.

       
  • stan cartwright

    stan cartwright - 2022-02-17

    In your code "if PixelStatus_SSD1306(countx, county ) = 1 then" is irrelevant ??

      for countx=0 to 127
        for county=0 to 63
          'ANSI (countx*4) +1, county+1
          if PixelStatus_SSD1306(countx, county ) = 1 then
            hserprint SSD1306_BufferLocationCalc
          else
            hserprint SSD1306_BufferLocationCalc
          End if
          HSerPrintCRLF
        next
    
      next
    
     
    • Anobium

      Anobium - 2022-02-17

      oh yes... :-)

       

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.