A description of Life can be found at Wikipedia.org. The rules are simple:
- Any live cell with fewer than two live neighbours dies, as if caused by under-population.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overcrowding.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
Life 64x32
There are two arrays each 256 bytes. The first array contains the seed colony or the previous generation. The second array is populated by applying the life rules to the first array. After the new colony is created, it becomes the new display colony and the process repeats.
Because of the 2KB RAM limitation of the ATmega328, I limited the colony to 64x32. The native Monochron display size is 128x64. I scaled this down to 64x32 squares where each square is made of native 2x2 pixels. The colony array is 64x26 to reserve some space at the bottom for the date and time display.
Life 128x64
2K of RAM would be required if the above double RAM buffer approach was used. Instead there is one 1K buffer in RAM and the LCD display is the second buffer. The LCD display is read into the RAM buffer which is processed using the life rules and the output is written back to the display. The colony array is 128x53 to reserve some space at the bottom for the date and time display.
This is the 128x64 version. At the top of each minute the colony is reset using the date and time as a seed.
This video shows the clock displaying a birthday message and playing a tune on the hour. The date and time bar is highlighted during the birthday date to notify there is a birthday event that day. The birthday message and the person's name is shown and a tune played on the hour from 8am to 8pm. In addition the message is shown and tune played when the set or increment buttons are pressed.
Here is the code:
Monochron Life Source Code 64x32
Monochron Life Source Code 128x64
My clocks collection can be found in my earlier blog post.
Hello i'm a beginner could you post the monochrom.hex ?
ReplyDeletebest regards
Seb
Hi Seb,
ReplyDeleteI added monochron.hex to the source code download files.
Mike