Forum Index > Projects > LED Pegboard and Matrix Projects
 XOR Point code
 |  Printable Version
By: Anonymous: Doormatt () on Saturday, July 12 2008 @ 01:04 AM PDT (Read 5074 times)  
Anonymous: Doormatt

Hey All!

Now, I'm attempting to modify the line drawing routing to have an xor option. So if you set that option, then draw over an existing line, it'll erase it.

I've modified the Linecode to use the WritePoint sub, and then modified the WritePoint sub as follows:

PHP Formatted Code

void Peggy2::WritePoint2(uint8_t xPos, uint8_t yPos, uint8_t Value)
{
  switch (Value) {
        case 0:
                buffer[yPos] &= ~((uint32_t) 1 << xPos);
                break;
        case 1:
                buffer[yPos] |= (uint32_t) 1 << xPos;
                break;
        case 2:
                buffer[yPos] &= ~((uint32_t) 1 << xPos);
                break;
        }
}
 



However, it doesn't like my second (#2 that is...the xor routine) case. I'm honestly not enough of a code guru to figure out what I'm doing wrong here...

Would anyone mind helping out?

Thanks!





       
   
By: Anonymous: Doormatt () on Saturday, July 12 2008 @ 01:07 AM PDT  
Anonymous: Doormatt

*Sigh*

Ignore the code in the last section.

Here's the proper code:

PHP Formatted Code

void Peggy2::WritePoint2(uint8_t xPos, uint8_t yPos, uint8_t Value)
{
  switch (Value) {
        case 0:
                buffer[yPos] &= ~((uint32_t) 1 << xPos);
                break;
        case 1:
                buffer[yPos] |= (uint32_t) 1 << xPos;
                break;
        case 2:
                buffer[yPos] &= ^((uint32_t) 1 << xPos);
                break;
        }
}
 





       
   
By: Art Dahm (offline) on Sunday, July 13 2008 @ 11:05 AM PDT  
Art Dahm

Try:
buffer[yPos] ^= ((uint32_t) 1 << xPos);


Art Dahm My Peggy 2.0 Web Page www.mindlessdiversions.com/peggy2/

Forum Apprentice
Apprentice

Status: offline

Registered: 06/07/08
Posts: 10
Los Angeles, CA

Profile Email Website  
   
By: Windell (offline) on Sunday, July 13 2008 @ 08:25 PM PDT  
Windell

Art, you beat me to it! Smile



Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Doormatt (offline) on Wednesday, July 16 2008 @ 11:20 PM PDT  
Doormatt

Woo!

Thanks guys! I really appreciate it. I know enough C++ just to get me in trouble.

Thanks again!

-Matt


Forum Apprentice
Apprentice

Status: offline

Registered: 07/13/08
Posts: 1

Profile Email    
   



 All times are PDT. The time is now 08:18 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?