Projekte mit dem S65-Shield

Andreas Watterott User 2009-08-20 15:52:16 Link
Hier einige Projekte, die das S65-Shield verwenden:

Naguino: an Arduino-based LCD monitor for Nagios and Icinga
http://blog.fupps.com/2009/05/11/naguino-an-arduino-based-lcd-monitor-fo...

Arduino Oscilloscope
http://traegerwelle.blogspot.com/2009/08/arduino-oscilloscope.html

Arduino Skype monitor
http://www.youtube.com/watch?v=xqSP4FT9r8o

Durchflussmesser
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1249637090

Andreas Watterott User 2009-10-03 18:14:39 Link
Game of Life
http://www.youtube.com/watch?v=kzGmagCqVGI

Andreas Watterott User 2009-11-14 13:12:29 Link
Some cool projects from codetorment:

Game of Life
http://vimeo.com/7421217

Arduino Pong
http://www.codetorment.com/2009/11/11/arduino-pong-using-s65-shield/
http://vimeo.com/7558097
http://vimeo.com/7596054

Per-Tore Aasestrand User 2009-12-07 12:49:00 Link
My first attempt on the Game-Of-Life.

The rotary encoder controls the iteration speed.

//==============================
// +++ Conways Game-Of-Life +++
//------------------------------
// First crude attempt, Nov 2009
//        P-T.Aasestrand
//==============================

/*
For a space that is 'populated':
  -  Each cell with only one or no neighbors dies, as if by loneliness. 
  -  Each cell with two or three neighbors survives. 
  -  Each cell with four or more neighbors dies, as if by overpopulation. 

For a space that is 'empty' or 'unpopulated'
  -  Each cell with three neighbors becomes populated. 
*/

#include <S65Display.h>
#include <RotaryEncoder.h>
#include <PString.h>

#define RECTSIZE 5		        // size of rectangle
//#define DIMX (S65_WIDTH  / RECTSIZE)	// world size X
//#define DIMY (S65_HEIGHT / RECTSIZE)	// world size Y

void fill(void);
void show(void);
int8_t neigh(int8_t i, int8_t j);

int8_t DIMX  = (S65_WIDTH  / RECTSIZE);	// world size X
int8_t DIMY  = (S65_HEIGHT / RECTSIZE);	// world size Y
int8_t world[44][33];		        // our world

// --------------------------
// Bit Meaning     Mask  Name
// --------------------------
//  0  Filled      0x01  FILL
//  1  Displayed   0x02  DISP
//  2  Delete      0x04  DEL
// --------------------------
#define FILL 0x01
#define DISP 0x02
#define DEL  0x04

char buff[25];

int8_t  move, press;
int16_t  interval = 25;

S65Display lcd;
RotaryEncoder encoder;

ISR(TIMER2_OVF_vect)
{
    TCNT2 -= 250;			// 1000 Hz
    encoder.service();
}

void setup()
{
    randomSeed(analogRead(0));
    PString mystring(buff, sizeof(buff));	// setup print to buffer
    lcd.init(4);                		// spi-clk = Fcpu/4
    encoder.init();                             // init Rotary Encoder

    // Setup initial world
/*
    // R-pentomino
    world[5][2] = FILL;
    world[3][3] = FILL;
    world[4][3] = FILL;
    world[5][4] = FILL;
    world[6][4] = FILL;
    world[4][5] = FILL;
*/    
/*
    // Blinker
    world[5][5] = FILL;
    world[5][6] = FILL;
    world[5][7] = FILL;
*/    
/*
    // Toad
    world[10][6] = FILL;
    world[10][7] = FILL;
    world[10][8] = FILL;
    world[11][7] = FILL;
    world[11][8] = FILL;
    world[11][9] = FILL;
*/

    //init Timer2
    TCCR2B  = (1<<CS22);        		// clk=F_CPU/64
    TCNT2   = 0x00;	
    TIMSK2 |= (1<<TOIE2);			// enable overflow interupt

    //interrupts on
    sei();

    // Print to buffer
    mystring.print(" X = ");
    mystring.print(DIMX);
    mystring.print(", Y = ");
    mystring.print(DIMY);
    mystring.print(" ");

    lcd.clear(RGB(0,255,0));
    lcd.drawTextPGM(25,40, PSTR("  Game Of Life  "), 1, RGB(  0,255,  0),
RGB(0,0,255));
    lcd.drawTextPGM(25,55, PSTR(" P-T.Aasestrand "), 1, RGB(255,255,255),
RGB(255,0,0));
    lcd.drawText   (25,70, buff,                     1, RGB(255,255,255),
RGB(255,0,0));
    delay (1000);
    
    lcd.clear(RGB(0,255,0));
    fill();
}

void loop()
{
    show();
    scan();

    delay(interval);

    move  = encoder.step();
  
    if(move)
    {
        if(interval < 10)
            interval += move;
        else
            interval += move * 10;  

        if((interval < 0) || (interval > 1000))
            interval = 0;
    }
}

void show()
{
static int8_t i, j, x, y;
    
    for (i = 1; i < DIMX-1; i++)
    {
        for (j = 1; j < DIMY-1; j++)
        {
            if (world[i][j] & FILL)
            {
                if (world[i][j] & DEL)
                {   // Position to be deleted
                    x = i * RECTSIZE;
                    y = j * RECTSIZE;
                    lcd.fillRect(x, y, x + RECTSIZE - 2, y + RECTSIZE - 2 ,
RGB(0,255,0));
                    world[i][j] &= !DEL;    // Clear DEL flag
                }
                else
                if (!(world[i][j] & DISP))
                {   // Position to be displayed
                    x = i * RECTSIZE;
                    y = j * RECTSIZE;
                    lcd.fillRect(x, y, x + RECTSIZE - 2 , y + RECTSIZE - 2
, RGB(0,0,255));
                    world[i][j] |= DISP;    // Clear DISP flag
                }
            }
        }
    }
}

void scan(void)
{
static int8_t i, j, n;

    // Interior scan
    for (i = 1; i < DIMX-1; i++)
    {
        for (j = 1; j < DIMY-1; j++)
        {
            // Get neighbors to this cell
            n = neigh(i, j);
            // Check if populated
            if (world[i][j] & FILL)
            {   // We have life here
                Serial.print(" Life ");
                // Check survival conds:
                //  -  Each cell with only one or no neighbors dies, as if
by loneliness. 
                if ( (n == 0) || (n == 1) )
                {   // Did not survive, clear out
                    world[i][j] |= DEL;    // Flag as deleted
                }
                else
                //  -  Each cell with four or more neighbors dies, as if by
overpopulation. 
                if ( n >= 4 )
                {   // Did not survive, clear out
                    world[i][j] |= DEL;    // Flag as deleted
                }
            }
            else
            //  Empty cells with three neighbors becomes populated
            if ( n == 3 )
            {
                world[i][j] |= FILL;
            }
        }
    }
}

// Find number of neighbors for interior cells
int8_t neigh(int8_t i, int8_t j)
{
static int8_t n;

    n = 0;
    
    // Above
    if ( (world[i-1][j+1] & DISP) && (world[i-1][j+1] & FILL) )
        n++;
    if ( (world[i][j+1] & DISP) && (world[i][j+1] & FILL) )
        n++;
    if ( (world[i+1][j+1] & DISP) && (world[i+1][j+1] & FILL) )
        n++;

    // Sides
    if ( (world[i-1][j] & DISP) && (world[i-1][j] & FILL) )
        n++;
    if ( (world[i+1][j] & DISP) && (world[i+1][j] & FILL) )
        n++;

    // Below
    if ( (world[i-1][j-1] & DISP) && (world[i-1][j-1] & FILL) )
        n++;
    if ( (world[i][j-1] & DISP) && (world[i][j-1] & FILL) )
        n++;
    if ( (world[i+1][j-1] & DISP) && (world[i+1][j-1] & FILL) )
        n++;

    return n;
}

void fill(void)
{
static int8_t x, y;

    for (x = 1; x < DIMX-1; x++)
    {
        for (y = 1; y < DIMY-1; y++)
        {
            world[x][y] = (int8_t)random(2);    // Pseudo-random nbr: 0 or
1
        }
    }
}



Regards,

Per-Tore

Andreas Watterott User 2010-04-07 18:28:41 Link
PONGuino – Arduino & S65 Shield
http://lab.synoptx.net/2010/02/12/ponguino-arduino-s65-shield-2-player-m...

Andreas Watterott User 2010-08-10 22:35:14 Link
SMSlingshot from VR/URBAN:
http://www.vrurban.org/smslingshot.html

Antworten

Name
eMail (wird nicht angezeigt)
Betreff (keinen Text nur mit Großbuchstaben; kein HILFE, HELP...)
Text
HTML Tags werden nicht unterstützt und Links werden automatisch erstellt, wenn sie mit http o. ftp beginnen.
Längeren Sourcecode oder Logdateien bitte als Dateianhang einfügen (nur registrierte Benutzer).
Bitte die Zahl eingeben 2633