Coder Social home page Coder Social logo

peggy's People

Watchers

 avatar

peggy's Issues

test buttons

Here is a simple program that uses the Peggy library to test the buttons on
the board.  Note that button B0 corresponds to PORT B pin 0 and buttons B1
- B5 correspond to PORTC pins 0 - 4 respectively.

When I first looked at the sample code "Bounce" I noticed that button B0
corresponded to PORT B pin 0. Soooooooo, I didn't bother to look at the
schematic and instead assumed buttons "B1" - "B5" were attached to PORT B
pins 1 - 5.  Nope!  So I thought this simple sample might be helpful for
others who are just getting started with the board.


Original issue reported on code.google.com by [email protected] on 17 Jun 2008 at 4:23

Attachments:

PeggyWriter example has erors

The example 'PeggyWriter_Hello' has a few errors in it that prevent compiling 
as well as some kerning errors in the text display. A corrected version is 
below:



/* Simple example code for Peggy 2.0, using the Peggy2 and PeggyWriter libraries
*/

#include <Peggy2.h>
#include <stdlib.h> 
#include <PeggyWriter.h>

Peggy2 frame1;     // Make a frame buffer object, called frame1
PeggyWriter myWriter;  // Make a PeggyWriter object

void setup()                    // run once, when the sketch starts
{
     frame1.HardwareInit();   // Call this once to init the hardware
}  // End void setup()  


void loop()                     // run over and over again
{ 
  byte x = 2, y = 1;

  myWriter.drawCharacter('H',&frame1, x, y);
  x += 5;
  myWriter.drawCharacter('E',&frame1, x, y);
  x += 4;
  myWriter.drawCharacter('L',&frame1, x, y);
  x += 4;
  myWriter.drawCharacter('L',&frame1, x, y);
  x += 4;
  myWriter.drawCharacter('O',&frame1, x, y);
  x = 0;
  y += 7;
  myWriter.drawCharacter('W',&frame1, x, y);
  x += 6;
  myWriter.drawCharacter('O',&frame1, x, y);
  x += 5;
  myWriter.drawCharacter('R',&frame1, x, y);
  x += 5;
  myWriter.drawCharacter('L',&frame1, x, y);
  x += 4;
  myWriter.drawCharacter('D',&frame1, x, y);
  x += 5;

  while (1)
  {
    frame1.RefreshAll(1);
    delayMicroseconds(1000);
  }

}

Original issue reported on code.google.com by [email protected] on 28 Mar 2011 at 8:15

Peggy2 0.30b line() improvement

The Peggy2.cpp 0.30b line() function was returning some strange results.  
For example, (10,0) to (11,24) resulted in all points from (10,0) to 
(10,23), and point (11,24) being activated.  To me it would be better to 
have the 'split' show up in the middle - something like (10,0)-(10,12) and 
(11,13)-(11,24).

A simple change in the library function made this work.  See the "Count=
(dx-dy)/2" line and its counterpart in the snippet below.

Cheers,
Tim

void Peggy2::Line(int8_t x1, int8_t y1, int8_t x2, int8_t y2)
{
  if ( (x1>=25 && x2>=25) || (y1>=25 && y2>=25) ) return;
  int8_t dx = abs(x2 -x1);
  int8_t dy = abs(y2 -y1);

  int8_t p1x,p1y,p2x,p2y,i;

  if (dx > dy)
  {
    if (x2>x1) {
      p1x=x1;
      p1y=y1;
      p2x=x2;
      p2y=y2;
    } 
    else {
      p1x=x2;
      p1y=y2;
      p2x=x1;
      p2y=y1;
    }

    int8_t y = p1y;
    int8_t x = p1x;
    int8_t count = 0;
    int8_t increment = p2y > p1y ? 1 : -1;
count=(dx-dy)/2;
    for (i=0; i<=dx; i++)
    {   
      count += dy;
      if (count > dx)
      {
        count -= dx; 
        y+= increment;
      }             
      if (y>=0 && y<25 && x>=0 && x<25) 
        SetPoint(x,y);
        x++; 
      if (x>=25) 
        break;
    }
  }
  else
  {
    if (y2>y1) {
      p1x=x1;
      p1y=y1;
      p2x=x2;
      p2y=y2;
    } 
    else {
      p1x=x2;
      p1y=y2;
      p2x=x1;
      p2y=y1;
    }
    int8_t y = p1y;
    int8_t x = p1x;
    int8_t count = 0;
    int8_t increment = p2x > p1x ? 1 : -1;
count=(dy-dx)/2;
    for (i=0; i<=dy; i++)
    {   
      count += dx;
      if (count > dy)
      {
        count -= dy; 
        x+= increment;
      }             
      if (y>=0 && y<25 && x>=0 && x<25) SetPoint(x,y);
      y+=1; 
      if (y>=25) break;
    }
  }
}


Original issue reported on code.google.com by [email protected] on 5 Jan 2010 at 4:36

RE: I did some cleaning up and added a tiny bit

A couple of things.

First. I love peggy. :D It's a lot of fun to toy around.

With regards to the library, I have some suggestions and a few additions.
It'd be pretty awesome if you took all of them!

I'm pretty positive you were going wayyyyyy out of your calloc'd space.
Arrays do all the pointer arithmetic for you. So, if buffer is a uint32_t
pointer, doing buffer[5] is the same as doing *(buffer+(5*sizeof(uint32_t))).
That means your array calls were asking for stuff way out of the array. I
think the only reason it worked is because your Clear() was clearing the
random memory anyways. With enough framebuffers, they would definitely
start colliding or accessing space outside of the addressable memory space.

For C++ classes, having the Peggy_ prefix on all the functions is
unnecessary. People using the objects know what type of object they are
calling functions on.

Move the comments about what each function does to the header file. People
don't need to see what's inside, just how to use it.

I made all of those edits tonight as well as make some consistent tabbing
to make it look cleaner. I also added a SetRow and a WriteRow function.
I'll probably add more too.

Please see my attachment for all the changes I've wrote about! Feel free to
use or ignore any of the suggestions! (I didn't edit the examples though)

Original issue reported on code.google.com by yincrash on 28 May 2008 at 3:39

Attachments:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.