VGA library - now with TV output

Sure -- 1024x675x8 would need 675KB, little bit more than 96KB,

Instead of just drawing rectangles I made a Sierpinski triangle demo myself (big photo):

What this photo shows is the "White line / missing first pixel in mono modes" known bug mentioned in VGA.h. But hey, for a complete (and programmable) VGA card plus microcontroller for programs all for 12$ that is more than good for me.

Next you see at bottom 32x32 font output. I just used the DueVGA 8x8 font and scaled it. You may want to use "drawText32()" yourself, it allows to read text on photos taken from screen and reduced in size as above.

The sketch shown below does all what you see, and it does some measurements at microsecond resolution, reporting to Serial:

...
743 1777 375564 92 61763 1
739 1778 375513 92 61721 1
741 1778 375523 93 61714 1
702 1781 375519 101 61720 1
818 1773 375512 96 61728 1
815 1774 375497 92 61727 1
...

After drawing the screen it delays for 2 seconds before starting again.

743 is the time taken by "clearScreenMono()" function. It is 1ms quicker than "VGA.clear()" with 1777μs, most times VGA.clear() should be good enough. "clearScreenMono()" is so quick that you can never seen top of screen empty, neither on video nor directly on monitor.

375564μs or 0.376s is the time to compute and draw the Sierpinski triangle. Just the compute time for 675*(675+1)/2=228150 binomial values is only 92μs on Arduino Due -- have I said that I like the performance of Due's SAM processor?

And here is the sketch:

#include <VGA.h>

#define w 1024
#define h 675
#define S "Sierpinski triangle"
#define T "1024 x 675  DueVGA lib"

void setup() {
  VGA.begin(w,h);
  Serial.begin(57600);
}

void loop(){
  unsigned char L[2][h];
  int n,k,o=0;
  unsigned long t0,t1,t2,t3,t4,t5,s=0;
  
  t0=micros();
  clearScreenMono();

  t1=micros();
  VGA.clear();

  t2=micros();  
  for(n=0; n<h; ++n, o=1-o) {
    L[1-o][0]=L[1-o][n]=1; 
    for(k=1; k<n; ++k) { L[1-o][k]=L[o][k-1]+L[o][k]; }
    for(k=0; k<=n; ++k) { 
      VGA.drawPixel(w/2-n+2*k,n,(L[1-o][k]%2)!=0);
    }
  }  
  
  t3=micros();  
  for(n=0; n<h; ++n, o=1-o) {
    L[1-o][0]=L[1-o][n]=1; 
    for(k=1; k<n; ++k) { L[1-o][k]=L[o][k-1]+L[o][k]; }
    for(k=0; k<=n; ++k) { 
//      VGA.drawPixel(w/2-n+2*k,n,(L[1-o][k]%2)!=0);
      ++s;
    }
  }  
  
  t4=micros();
  drawText32(T,w/2-16*strlen(T),h-64);
  drawText32(S,w/2-16*strlen(S),h-32);

  t5=micros();
  Serial.print(t1-t0);  Serial.print(" ");
  Serial.print(t2-t1);  Serial.print(" ");
  Serial.print(t3-t2);  Serial.print(" ");
  Serial.print(t4-t3);  Serial.print(" ");
  Serial.print(t5-t4);  Serial.print(" ");
  Serial.println(s!=0);

  delay(2000);
}

void clearScreenMono() {    
  memset(VGA.pb,0,2*VGA.pbsize);
}

void drawText32(char *text, int x, int y)
{
  uint8_t t;
  while(t=(uint8_t)*text++){
    for(int j=0;j<8;j++)for(int i=0;i<8;i++){
      bool p=(_vga_font8x8[8*t+j]&(128>>i))!=0;
      for(int a=0; a<4; ++a)for(int b=0; b<4; ++b) {
        VGA.drawPixel(x+4*i+a,y+4*j+b,p);
      }
    }
    x+=32;  
  }
}

Hermann.