Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ Programming ➜ General ➜ Additions to your very useful uvga class

Additions to your very useful uvga class

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Dustintweir   (1 post)  Bio
Date Tue 11 Mar 2014 07:47 PM (UTC)
Message
Thanks for the great library for operating my micro vga. I've been using mine to paint terminal screens compressed and stored in the Arduino's EEPROM. I've stored these "templates" as strings of ASCII codes starting at address 0 in the EEPROM, and ending with EOF character 034. This assumes the strings are in left-to-right, top-down order in the EEPROM up to the screen size of 2,000 characters.

To save memory, any time I have 4 or more identical characters to print I add character 021, followed by the repeat character, followed by the quantity of repeats. Finally I return the memory index of the first character after EOF, so I can re-call the function to read the next screen.


Used in sketches

int ROMScreen(int index)
{
  byte buf, character; //incoming character and repeating character storage
  int quantity; //number of character repeats
  uvga.gotoxy(1,1);
  
  do{
    buf = EEPROM.read(index); //read current byte
    if (buf == 21){ //indicates repeating character
      index++;
      character = EEPROM.read(index); //read the character to be repeated
      index++;
      quantity = EEPROM.read(index); //read the quantity of repeats
      if (character==255) //special character to indicate "don't write anything"
        uvga.advance(quantity);
      else 
        for (int i=0; i<quantity; i++){
          uvga.write(character);
        }
    }
    else if (buf != 34){ //non-repeating but not EOF
      if (buf == 255)
        uvga.advance(1);
      else
        uvga.write(buf);
    }
    index++;   
  } while (buf != 34); //continue to read until EOF

  return index;
  
}


Finally, I added a function to advance the cursor a number of places without moving the cursor to each place. This greatly speeds paint time

To uvga.h, line 93

void advance (char i);

To uvga.cpp, at the end of the file

void uVGA::advance (char i)
{
	write (ESC "[");
	write ((i / 100)+'0');
	i = i-(i/100)*100;
	write ((i / 10) + '0');
	write ((i % 10) + '0');
	write ('C');

}

Top

Posted by Fiendish   USA  (2,555 posts)  Bio   Global Moderator
Date Reply #1 on Tue 11 Mar 2014 11:13 PM (UTC)
Message
Template:Arduino Please post Arduino-related questions to the Arduino Forum or to StackExchange: Arduino. This saves splitting questions and answers between this forum and the Arduino ones.

https://github.com/fiendish/aardwolfclientpackage
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,561 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.