It’s official: the Tinusaur will be presented at Maker Faire in New York

Posted on

Maker Faire New York - The Greatest Show and Tell on EarthIt’s official: The Tinusaur Project will be presented at the Maker Faire that is taking place in New York this month – on Sunday, September 21st at 3:15pm on the “Make: Electronics Stage”

 

Come see us there!

 

More information is available at this address: http://makerfaire.com/makers/the-tinusaur-project-minimal-microcontroller-platform-to-start-with-learning-and-creating-things/

C Library for ATtiny85 to Work with SSD1306 Controlled OLED Display

Posted on Updated on

I recently bought an OLED display 128×64 from eBay (http://www.ebay.com/sch/i.html?_nkw=OLED+128) – very inexpensive (about 4 euro) but when I finally received it I was surprised to see how small it was – I was expecting something that looked more like the Nokia 3310 LCD. So I thought – this is perfect for the Tinusaur Project. The 128×64 OLED is controlled by a SSD1306 circuit and could be interfaced over I²C. The first challenge that I faced was that all existing libraries that I found were for Arduino boards … and I wrote my own based, of course, on existing code – the SSD1306xLED library.

SSD1306xLED library for OLED/PLED 128x64

SSD1306xLED is a C library for working with the SSD1306 display driver to control dot matrix OLED/PLED 128×64 displays. It is intended to be used with the Tinusaur board but should also work with any other board based on ATtiny85 or similar microcontroller – ATtiny45/ATtiny25, even ATtiny13.

The code could be divided in 3 pieces: (1) communication over I²C with the SSD1306; (2) sending graphical commands to the display; (3) high-level functions such as printing characters.

The I²C communication part is based on modified IIC_wtihout_ACK library that is available on the Internet but its original website (http://www.14blog.com/archives/1358) is no longer functional. Basically, it made it to work on ATtiny85 and Tinusaur.

The SSD1306xLED library still needs work and improvements.

The main location for the library is SSD1306xLED page.

The source code along with very simple example is available on Bitbucket at this address: https://bitbucket.org/tinusaur/ssd1306xled

 

The Tinusaur will be presented at Maker Faire New York

Posted on

Maker Faire New York - The Greatest Show and Tell on Earth

We are glad to share with you that we’ve been accepted to present the Tinusaur project at the Maker Faire New York on Sept. 20 & 21.

The exact date and time are not known yet but we will post more info here as soon as it become available.

Come see us there!

 

Tinusaur Starter and Tinusaur Board are Available for Preorder

Posted on

As you already know we ran out of all the kits at our online store and because we also received a lot of questions when the Tinusaur Starter and Tinusaur Board will be available we decided to allow you to preorder them. This way we’ll know how many of you are actually interested in buying so we’ll order the necessary quantities from our suppliers.

If you decided to preorder please should allow us between 2 and 3 weeks to get all the parts from our suppliers.

If you find The Tinusaur Project useful we would really appreciate you considering a small donation. Please look at the right side bar for more information.

Thank again for you interest and support.

 

Out-of-Stock Items at Our Online Store

Posted on

Dear friends, due to increased popularity of our Tinusaur Project in the last couple of days and unexpected high demand for the kits in our online store . . . we just ran out of almost all of them.

We contacted our suppliers and ordered more parts but it could take up to 3 weeks until they arrive so please be patient.

If you need just the PCB you can order it directly from OSH Park at this address: https://oshpark.com/shared_projects/9IZsFiXL.

Please follow us on Twitter at @tinusaur where we post more updates.

 

 

The Tinusaur Plays Conway’s Game of Life

Posted on Updated on

MAX7219 LED 8x8 ATtiny Tinusaur Conway’s Game of Life

I was playing with the MAX7219LED8x8 library and writing some code for how to use a simple scheduler to automate the task of outputting the buffer to the LED 8×8 matrix. So I was thinking … may be writing a simple game will illustrate the use of those libraries very well. Because just few days earlier I was looking at some Arduino projects implementing the Conway’s Game of Life I decided to write it for ATtiny85 and MAX7219/LED 8×8.

The Game of Life is a classical computer game and a cellular automaton created by the British mathematician John Horton Conway in 1970. This is a zero-player game which means that once it starts no input from user is required to play the game’s turns – it goes by itself.

Its simple rules (outlined below) allow to be implemented on very simple microprocessor systems and Tinusaur (and ATtiny systems in general) could be perfect platform for that.

Hardware

One Tinusaur Board connected to LED matrix 8×8 controlled by MAX7219.

Drivers

The MAX7219Led8x8 library is used to output the pixels to the LED 8×8 matrix.

MAX7219 LED 8x8 Conway’s Game of LifeThe Rules

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by overcrowding.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called atick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.

(ref: Wikipedia/Conway’s_Game_of_Life)

The Program

The board is defined as a short byte array:

typedef uint8_t life_board[8];

An initial board is specified by the bits in that array:

life_board life_oscillators_blinkers = {
    0b00000000,
    0b00000000,
    0b01110000,
    0b00000000,
    0b00000100,
    0b00000100,
    0b00000100,
    0b00000000
};

Here are the most important functions that are implemented:

void life_board_init(life_board buffer);
void life_board_out(void);
uint8_t life_cell_count(uint8_t cx, uint8_t cy);
void life_board_turn(void);
void life_board2_copy(void);

The life_board_init function initializes the board with preset values and life_board_out outputs the content of the boards to the LED 8×8 matrix.

The life_cell_count function counts how many neighbors the specified cell has.

The life_board_turn performs one turn of the game based on the rules described above. It reads the data from the main buffer life_board_buffer array and stores the result in the life_board_buffer2 array. After that life_board2_copy copies the new data to the main buffer which then is outputted to the LED 8×8 matrix.

Here is the source code of the most important function – life_board_turn:

void life_board_turn(void) {
    for (uint8_t y = 0; y <= 7; y++) {
        for (uint8_t x = 0; x <= 7; x++) {
            uint8_t count = life_cell_count(x, y);
            if (LIFE_CELL_ISSET(x, y)) {
                if (count < 2)
                    LIFE_CELL_CLR(x, y);
                else if (count == 2 || count == 3)
                    LIFE_CELL_SET(x, y);
                else if (count > 3)
                    LIFE_CELL_CLR(x, y);
            } else {
                if (count == 3)
                    LIFE_CELL_SET(x, y);
                else
                    LIFE_CELL_CLR(x, y);
            }
        }
    }
}

This function implements the rules of the Game of Life.

That’s it.

In the program there is some more code that shows about 10 well know and interesting shapes such as blinker, toad, beacon, glider, etc.

The source code is part of the MAX7219LED8x8 library and it is available at https://bitbucket.org/tinusaur/max7219led8x8.

 

 

This article was permanently put at Conway’s Game of Life page.

UPDATE: MAX7219LED8x8 uses simple scheduler

Posted on Updated on

max7219 LED 8x8 Tinusaur ATtiny85

The MAX7219LED8x8 library uses now simple scheduler to automate the task of outputting the buffer to the LED 8×8 matrix. This is not like a real task scheduler (in a real operating system) but it uses the ATtiny85 microcontroller‘s timer and its interrupt to do certain things on regular intervals.

So this is how I’ve got the idea …

While I was working on some code that uses the MAX7219LED8x8 library I figured out that the task of writing the content of the memory buffer to the MAX7219 could be automated by hooking some code to the ATtiny85 timer.

The modification and additions could be broken down into 2 parts:

First, the scheduling part that initializes the ATtiny85 timer, starts it and handles the hardware interrupt.

Second, the MAX7219LED8x8 library functions for setting/clearing pixels and outputting the buffer that now should work with the scheduler.

There are only 3 functions to handle the scheduling:

void scheduler_init(void);
void scheduler_start(uint8_t max);
void scheduler_userfunc(void);

The scheduler_init function initializes the timer and the scheduler_start starts the timer task to be executed on equal interval defined by the max parameter.

The scheduler_userfunc function should be implemented in the application so it could be called on regular intervals.

There is not “stop” function at the moment since it was not needed in this particular case.

The code for initializing and starting the ATtiny85 timer is very simple:

void scheduler_init(void) {
    // Setup Timer
    TCCR0A |= (1 << WGM01); // set timer in CTC mode
    TIMSK |= (1 << OCIE0A); // set Bit 4 – OCIE0A:
    // ... Timer/Counter0 Output Compare Match A Interrupt Enable
}

void scheduler_start(uint8_t max) {
    // IMPORTANT: Requires TIMER0_COMPA_vect to be setup.
    sei(); //  Enable global interrupts
    OCR0A = max;    // set value for OCR0A - Output Compare Register A
    // Prescale and start timer: 1/1024-th
    TCCR0B |= (1 << CS02) | (0 << CS01) | (1 << CS00);
}

// Define interrupt vector
ISR(TIMER0_COMPA_vect)
{
    scheduler_userfunc();
    // Note: No need to clear flags in TIFR - done automatically
}

On the MAX7219LED8x8 side there are only 3 functions currently implemented:

void max7219s_init(void);
void max7219s_start(void);
void max7219s_buffer_out(void);

The max7219s_buffer_out function is the one called within the scheduler_userfunc timer handler.

Everything else remains the same – we use MAX7219_buffer_set(x, y) to set pixel and MAX7219_buffer_clr(x, y) to clear pixel.

What could be improved and optimized: output the buffer only when it is changed.

More information is available at the MAX7219LED8x8 library page.

The source code of the MAX7219LED8x8 library, the scheduler and everything else is available at https://bitbucket.org/tinusaur/max7219led8x8.