Git Product home page Git Product logo

tetrisanimation's Introduction

TetrisAnimation

Compile Examples

An Arduino library for drawing letters and numbers using a falling block style animation.

alt text

Deisgined orginally for RGB LED Matrixes, but it should in theory work with any display that uses the Adafruit GFX library.

Displays/Libraries tested ( Examples included)

PLEASE NOTE: There are some issues with ESP8266 sketches that make use of WiFi as well, there is an issue open for this: #3

Installation & Setup

Search for "Tetris Animation" on the Arduino library manager

Basic Usage

See examples for more details.

Intialise library by passing in a display:

PxMATRIX display(64, 32, P_LAT, P_OE, P_A, P_B, P_C, P_D, P_E); //Intialise any display that makes use of Adafruit GFX
TetrisMatrixDraw tetris(display); //Pass it into the library

Set the value:

Set the value of the library by using one of: setTime, setNumbers or setText commands

// Usage: setTime(time_string, forceRefresh = false)
// time_string = time in the format "21:23"
// forceRefresh: by default, a digit will only redraw if it's value has changed
//               (so for a clock the hour digit would only draw once an hour)
//               but setting this value to true tells the library to redraw
//               all the digits.  
tetris.setTime("12:34");

// Usage: setNumbers(num, forceRefresh = false)
// num = Integer value. Max: 999999999 (9 digits long) Min: 0 (negative not currently supported).
// forceRefresh: by default, a digit will only redraw if it's value has changed
//               (so for a clock the hour digit would only draw once an hour)
//               but setting this value to true tells the library to redraw
//               all the digits.  
tetris.setNumbers(1234);

// Usage: setText(string, forceRefresh = false)
// string = regular text string, Use uppercase letters only.
// forceRefresh: by default, a digit will only redraw if it's value has changed
//               (so for a clock the hour digit would only draw once an hour)
//               but setting this value to true tells the library to redraw
//               all the digits.
//
// For full list of characters supported, check the AlphaTest examples.
tetris.setText("HOWDY!");

Draw the value:

These will normally be called in a timer or ticker (see any example). How often they are called will increase/decrease the speed of which the blocks drop.


// Usage: drawNumbers(x, y, showColon) (for use with setTime or setNumber)
// x = most left Pixel of the text 
// y = The bottom of the number when it lands, they will start falling from y + (16 * scale)
// showColon = (optional) show the colon or not, defaults to false (only applicaple when using setTime)
//
// Returns a boolean to indicate if its finished animating
// (will return false if there is still falling blocks)
tetris.drawNumbers(16,8, true);

// Usage: drawText(x, y) (for use with setText)
// x = most left Pixel of the text 
// y = The bottom of the text when it lands, they will start falling from y + (16 * scale)
//
// Returns a boolean to indicate if its finished animating
// (will return false if there is still falling blocks)
tetris.drawText(16,8);

Scale the font:

// Usage: scale = 2
// Will scale up the size of the characters
// Can be used with either numbers or text 

tetris.scale = 2; // must be called before setText, setTime or setNumbers
tetris.setText("BIG"); // This will be twice the size as normal
delay(5000);
tetris.setText("STILL BIG"); // scale persists
delay(5000);
tetris.scale = 1; // can be reset to normal size if required
tetris.setText("SMALL");

tetrisanimation's People

Contributors

aentinger avatar diplfranzhoepfinger avatar per1234 avatar toblum avatar vortigont avatar witnessmenow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tetrisanimation's Issues

Led matrix 64x64 Fall problems

Hi,

I modify the variable TETRIS_Y_DROP_DEFAULT so that the fall starts much topper, change the 16 to 24.

tetris.scale = 2
/ /Main Clock
tetris1Done = tetris.drawNumbers(-6, 56, showColon);


TetrisMatrixDraw.cpp

int y = 56 - (24 * 2); // what I comment is correct ? y = 8

TETRIS_Y_DROP_DEFAULT 16

TYD_D16

TETRIS_Y_DROP_DEFAULT 24
TETRIS_Y_DROP DEFAULT 24

How can I make it start much topper ?

Faster block fall and block color change? Only animate changed digit?

Hi,

not sure if this is the right place :-)
I was searching for a possiblity to adjust the animation to be a bit quicker, maybe be able to change the block colors but couldn't find the place. I think it also would be nice to be able only to animate the digit which has changed, but couldn't find an option fot this either.

Am I right that those "features/whishes" aren't supported at the moment?

Regards

Add outline only option

to use with drawOutline on monochrome displays

drawOutlineOnly maybe?

And have it toggle the fill
Screen Shot 2019-06-13 at 1 01 46 PM

Using TFT screens without flickering

I would like to use your library to build a clock with an TFT screen. I'm using one of these ESP32 boards https://github.com/Xinyuan-LilyGO/TTGO-T-Display, which have a 135x240 IPS TFT screen.

Instead of the Adafruit_GFX library I'm using the optimized https://github.com/Bodmer/TFT_eSPI library. I simply replaced references to Adafruit_GFX with TFT_eSPI and everything works well. Kudos for writing a truly general library.

The main issue I'm facing is that there's no equivalent to the VGA.show() or PDC_8544.display() function, so in the animation loop I'm forced to erase the actual screen, resulting in flickering while drawing the dropping Tetris pieces.

I know I can use the sprite object in the TFT_eSPI library to draw in RAM and quickly overlap on screen (that's my next step). But I was wondering if you thought about having your dropping pieces reset the background color while drawing a dropping piece. That would make your library working universally on any type of screen, even ones with no sprite or ability to refresh the display at once. Basically the pieces would have a background "pixel" above each drawn pixel, and instead of leaving a trace of color behind, would simply restore the background. I understand that this would not work with variable color background (say, a bitmap as background), but given how busy a display with dropping Tetris pieces already is, I'd say it's an acceptable compromise

If interested, I can attach my example once I get it working (sprite or not)

Examples not working out of the box

Hi, thank you for sharing.

but Examples has missing items and gives several errors while compiling.
am i missing something?
i believe examples should work out of the box(with little changes like panel size etc of coarse).

Support for WS2812B/NeoMatrix?

Since the NeoMatrix library has an API fairly similar to the displays, it would be nice to add an example of how to use these instead. Since WS2812B leds are so ubiquitous many people will have strands (or even matrices) that would make for really nice projects :)

The library: https://github.com/adafruit/Adafruit_NeoMatrix

I had a quick go at it myself but so far my ESP32 seems to be crashing when simply plugging it in. Although I'm not 100% sure if that is due to incorrect usage or just a faulty ESP32.

characters % and @ have overlapping pixels

This piece config will avoid the overlap for % (and avoid the 7 "cheat" piece)

    (0, 6, 4, 16, 0),
    (2, 3, 0, 16, 0),
    (0, 0, 2, 13, 0),
    (2, 7, 4, 11, 2),
    (0, 2, 0, 10, 0)

Character will look slightly different:

**  **
**  * 
    * 
  **  
  **  
 *    
 *  **
**  **

This piece config will avoid the overlap for @:

    (6, 2, 1, 16, 0),
    (6, 1, 3, 16, 2),
    (1, 3, 0, 15, 0),
    (1, 4, 2, 13, 1),
    (2, 5, 0, 12, 2),
    (1, 2, 4, 12, 2),
    (0, 2, 2, 10, 2)

Character will look slightly different:

  **  
******
*    *
* ****
* *   
*     
******
 **** 

draw routines should call startWrite/endWrite on display

Hi, I think it would be useful if the draw routines (drawText, drawNumbers) call display->startWrite and display->endWrite at the beginning and end of the routines. This would allows the backing renderer to perform optimizations (for example flushing the frame to the bus after all pixels are configured).

P3 64*64 program segmentation

Hey, I bought the p3 6464 board, but I ran the example with a fault in between. Even if I modified the parameter PxMATRIX display(64, 64, P_LAT, P_OE, P_A, P_B, P_C, P_D, P_E);
But he still can't run.
Oh, 64
32 works perfectly. I am just looking for a way to run 64*64.
Thank you

IMG_20190701_104910

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.