A tamagotchi-like toy with an OLED display and Li-Ion battery.

Similar projects worth following
This is just a little tamagotchi-like toy I'm working on for my wife. I used to think that this is how a modern Tamagotchi could look like.

Xling can be powered by an external USB cable or by a single cell Li-Ion battery (which can be charged using USB).

Please, note that this is an ongoing project. Its hardware part is almost finished only. The only concern of mine is ATmega328P. I'd like to replace it with ATmega1284P which has 128 KiB of flash memory.

If you want to build Xling yourself, you'll find all of the required files here below.

  • Xling v3.1 - an animation demo, more checkpoints, 4-wire SPI and FreeRTOS

    dsl11/17/2019 at 19:45 0 comments

    Almost a month and a half passed since the previous update (not so much comparing to v0.3, eh?) and I'm here to share some details regarding the overall progress.

    First of all, I've finally got rid of the leading zero in the Xling PCB version because there are no chances that I'll be brave enough to change it in future. So, v0.3.1 became v3.1 and it means that the most recent changes of the Xling PCB will find their way into current/3.0 branch of the repository.

    Note that it has nothing in common with the firmware version of Xling. The most recent changes in code find their way into current/0.4 branch of the Xling-firmware repository

    Animation demo

    Anyway, I'd like to show you a walking animation demo at 24 FPS. There are only 4 images of the animation where each one stays on a screen during two frames.

    However, a driver for SH1106-based displays I've been working on can do its best and produce the same animation at full speed:

    You're probably interested in the technical information on the screen. Here it is:

    1. BAT_LVL - a raw ADC value of the battery voltage (voltage divider, ADC3, 10-bit, Vref = 1.1 V).
    2. BAT_STAT - a single bit, which is grabbed directly from the MCP73831 STAT pin (1 - when the battery current, Ibat, is below a selected threshold, Iterm, 0 - otherwise).
    3. Number of frames to re-draw before calculating a delay.
    4. Time spent to re-draw the frames.
    5. Current FPS (according to 3 and 4).

    More PCB checkpoints and 4-wire SPI

    Spending time debugging and optimizing the OLED driver, I've realised that it would be convinient to have additional test points on top of the PCB. It's now possible to solder wires and attach the oscilloscope probes easily, without turning the bottom part of the PCB into a mess.

    Another change is 4-wire SPI which is used to connect the display in v3.1. I've decided to give up with the 3-wire SPI support in the driver entierly because of the 8-bit SPI shift register available in ATmega1284P only.

    There is no room for the 9th bit required by the display controller to distinct between data for graphics RAM and command register. Moreover, there is no easy way to stop transmitting bits from the shift register to "hack" the protocol.

    FreeRTOS-based firmware

    This is probably the most interesting update of mine.

    I've got a demo project (FreeRTOS/Demo/AVR_ATMega323_WinAVR) of FreeRTOS v10.2.1, copied several files (including list.c, queue.c, tasks.c, croutine.c and port.c + headers) to the Xling-firmware project and adjusted CMake configuration file according to the makefile from the demo project.

    Another modification is the port.c file which has been re-programmed a bit in order to use a 16-bit Timer/Counter 1 of the ATmega1284P to generate ticks for the FreeRTOS scheduler.

    So, it means that I can do something like that from now on :)

    Other updates

    Personally, I'd like to thank the community of r/PrintedCircuitBoard and u/charliebruce123 in particular because they pointed me to the issues with the previous version of the PCB. I've tried to fix them all in v3.1.

    Xling v3.1 isn't the first PCB version which has been attached to the battery in order to check how load-sharing circuit works, but it is the first one which allowed me to measure a battery voltage obtained from ADC via a voltage divider, a direct battery voltage, an output voltage at +3.3V and a battery status pin.

    All of the information should be enough to program a task which monitors the battery status correctly and prevents overcharges and deep discharges.

    Anyway, if you have any questions and ideas on your mind, feel free to tell me then.

    Have a good time!

  • Xling v0.3 - an artistic PCB, ATmega1284P and white OLED with SPI

    dsl10/05/2019 at 18:45 2 comments

    The whole summer has passed and I've finally finished the next version of the toy according to my plan. There are several significant changes which you've probably noticed:

    The first one doesn't carry any technical function, but provides a unique look and feel of the PCB (many thanks to SierraSaura for this picture).

    The second change is a new ATmega1284P MCU which replaces the previous ATmega328P one.

    It is the most important improvement over the previous versions because of the 32 KiB -> 128 KiB flash memory (the only memory on the board to carry a lot of the graphic sprites, for example). An amount of RAM has also been increased from 2 KiB on ATmega328P to 16 KiB on ATmega1284P.

    The third change is almost the same OLED display which color is white now instead of the yellow on the previous prototypes and connected using SPI.

    All of the previous displays with SH1106 controller were connected via two-wire interface (TWI, another name for I2C) which is relatively slow comparing to the SPI.

    However, a driver for the SH1106-based displays I'm working on doesn't support SPI yet. This is the next step on my way and this new Xling v0.3 will help me testing it.

    Anyway, if you have any questions and ideas on your mind, feel free to tell me then.

    Have a good time!

  • Actual size (height)

    dsl05/24/2019 at 18:45 0 comments

  • Actual size (width)

    dsl05/24/2019 at 18:38 0 comments

View all 4 project logs

Enjoy this project?



Jacob MacLeod wrote 10/13/2019 at 20:55 point

Nice project!

  Are you sure? yes | no

dsl wrote 10/14/2019 at 06:00 point

Thanks :)

  Are you sure? yes | no

Tom Nardi wrote 10/11/2019 at 03:07 point

Love the Disenchantment reference, very impressive project.

  Are you sure? yes | no

dsl wrote 10/11/2019 at 07:53 point

Ah, you've noticed it! Thanks :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates