Maintenance notice: These forum archives are read-only, and will be removed shortly. Please visit our forums at their new location, https://www.evilmadscientist.com/forums/.

Peggy 2/2LE Photo Display - Part 3

edited December 2012 in General

// [8] - Adafruit
{
  0x00000000, 0x00000000, 0x00008000, 0x00000000, 0x00000000, 0x00000000, 0x0000001C, 0x00000000, 0x00000000, 0x00200000, 0x00000000, 0x00001400, 0x00000000, 0x00000800, 0x00000000, 0x00000000, 0x00002000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00002040, 0x00004000, 0x00040000, 0x00000000}
,
{
  0x00008000, 0x00004000, 0x00008000, 0x00000800, 0x00000000, 0x00010200, 0x00000061, 0x00000000, 0x000B0000, 0x00800004, 0x00800100, 0x01000108, 0x00002010, 0x00404800, 0x00283600, 0x00057700, 0x00024010, 0x00000010, 0x00000808, 0x00000800, 0x00000180, 0x00002038, 0x00000008, 0x00000000, 0x00000000}
,
{
  0x00004000, 0x00008000, 0x00000000, 0x00000C00, 0x00000000, 0x00000000, 0x000102FE, 0x00010001, 0x000F0000, 0x00600002, 0x01000104, 0x01000508, 0x00802400, 0x00200820, 0x00103200, 0x00001000, 0x00006010, 0x00040000, 0x00040000, 0x00040C00, 0x00040100, 0x00042060, 0x00044000, 0x00048000, 0x00000000}
,
{
  0x00002000, 0x00007000, 0x00007800, 0x0000F000, 0x0000FC00, 0x0000FC00, 0x0000FC00, 0x0000FFFE, 0x0000FFFE, 0x001FEFFC, 0x00FFEEF8, 0x00FFF8F0, 0x007F1BF0, 0x003FF7C0, 0x000FC9E0, 0x0003CDE0, 0x00039FE0, 0x0003FFF0, 0x0003FFF0, 0x0003F3F8, 0x0003F0F8, 0x0003C018, 0x00038000, 0x00030000, 0x00020000}
,
);


int NumberPics = ((PictureTable.rows()+1)/4); // Determine the number of pictures in the table

// declare frame buffers
Peggy2 frame1;
Peggy2 frame2;
Peggy2 frame3;
Peggy2 frame4;

 

void setup()

{
  // Call this once to init the hardware.
  // (Only needed once, even if you've got lots of frames.)
  frame1.HardwareInit();

  randomSeed(analogRead(0)); //set up random seed generator

  /* write each row of the frame buffers from the bitmap data.
   Initial writing of rows so there is something to erase in
   the begining of the frame-writing loop*/
  int row;
  for (row = 0; row < 25; row++)
  {
    frame1.WriteRow(row, PictureTable[0][row]);
    frame2.WriteRow(row, PictureTable[1][row]);
    frame3.WriteRow(row, PictureTable[2][row]);
    frame4.WriteRow(row, PictureTable[3][row]);
  }

}

void loop()
{
  /* Clears frame from memory when no longer needed */
  if (PictureNew == 1) {
    frame1.Clear();
    frame2.Clear();
    frame3.Clear();
    frame4.Clear();
    PictureNew = 0;

    int row;
    for (row = 0; row < 25; row++)
    { /* Reads frames from flash memory and writes frame to SRAM */
      frame1.WriteRow(row, PictureTable[((PictureNumber*4)-4)][row]);
      frame2.WriteRow(row, PictureTable[((PictureNumber*4)-3)][row]);
      frame3.WriteRow(row, PictureTable[((PictureNumber*4)-2)][row]);
      frame4.WriteRow(row, PictureTable[((PictureNumber*4)-1)][row]);
    }
  }
  /* Draw the picture in greyscale  */
  frame1.RefreshAll(1);  // draw frame buffer 1 time
  frame2.RefreshAll(2);  // draw frame buffer 2 times
  frame3.RefreshAll(4);  // draw frame buffer 4 times
  frame4.RefreshAll(8);  // draw frame buffer 8 times

  CountNumber++;             // increase timer counter

  if (CountNumber == 900){ // Balpark estimate of 12 seconds for picture to display

    PictureNumber = random(NumberPics);
    PictureNumber++;       // These lines select new picture at random

    PictureNew = 1;        // Let the 'frame.clear' routine know it's a new picture

    CountNumber = 0;       // Reset display timer
  }

}

 

 

Sign In or Register to comment.