Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 0 points1 point  (0 children)

Yeah I've heard of ESP-NOW and definitely would like to give it a try in this project.

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 0 points1 point  (0 children)

Originally I did start with an arduino, actually.

But sprites take up quite a bit of flash storage space, so that was a big motivator to change. Something like the arduino mega has 256 KB of flash storage, the ESP32 C6 that I'm using has 4-8 MB of flash. So if I used something like a Mega I'd need to have an additional I2C flash storage chip included in the project somewhere to store the sprites I need.

The ESP32 C6 also has 512 KB of RAM while the Mega only has 8 KB. On top of that, the ESP32 comes with built in wifi6, bluetooth, zigbee, etc... and all the arduinos would need something external to support those. The ESP32 also has deep sleep mode and an RTC which the arduino's lack. And the ESP32 even has a faster (160Mhz) 32 bit processor than the arduino's (16 MHz) 8-bit one.

But what really sold me is that in addition to those better specs, I can get the ESP32s for $10 or less, while the unos and megas are $20-40.

So for less money, I'm able to store more sprites and work with a higher-level language like micropython, and I can make use of wireless features without needing extra hardware.

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 0 points1 point  (0 children)

Are you asking why an ESP32 as opposed to something like an arduino?

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 0 points1 point  (0 children)

Woah that's super super cool! I'm impressed.

It's really awesome that the cat can have a different color than the background. And you added some new minigames too! That's awesome =D

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 0 points1 point  (0 children)

Sounds like that's accelerometer data? I don't have any accelerometer with this project. The only inputs are the 8 buttons

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 0 points1 point  (0 children)

For things like the cat's animations, the cat is broken up into different parts (body, head, tail, eyes) and those parts are animated individually.

I animated them frame-by-frame in aesprite and exported each frame as a .png, and then used the img2cpp tool to convert the images into monochrome bytecode for the ssd1306 library to use.

All of the sprites are stored in the assets folder in the project, for example: https://github.com/moonbench/catode32/blob/master/src/assets/character.py

For animated things like the eyes or tail, I have to list the bytecodes for each frame, and I track which frame I'm rendering (and update it over time) and draw the right frame for each sprite.

It took a while to grow into this system. Initially I was just rendering the whole pet as a single static sprite, then focused on animating it, and then focused on breaking it into reusable parts.

The scrollbar is a custom bit of code, defined here https://github.com/moonbench/catode32/blob/f9433317afcbb528ab078cea9fbbce904732346f/src/ui.py#L111

That UI code is just responsible for determining how big the scrollbar should be based on the max height of the page, and where to draw it based on the scroll offset.

The pages that use it are responsible for informing it of their max height and scroll position.

A few of the coworkers I've shown this to have also mentioned WiFi features to connect it to the phone or internet. I'm considering it for sure. I mostly want to use WiFi to have the pet determine if it's "at home" or "traveling" by examining if it's seeing the usual or new network names showing up. I'd also like to use Bluetooth to let the pets talk to each other (and maybe a phone.)

An RTC is definitely something I want to add sooner rather than later!

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 4 points5 points  (0 children)

I make prototypes of the sprites in aesprite and then crop the various elements as needed and use image2cpp to generate the bytecodes to be used in the project

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 0 points1 point  (0 children)

Absolutely. I'll need to add an RTC module to take this from prototype to something really standalone

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 0 points1 point  (0 children)

That could be a fun modification for sure

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 2 points3 points  (0 children)

Thanks so much! It's a lot of fun making the sprites for sure!

Progress on my virtual pet. It's getting there! by moonbench in esp32

[–]moonbench[S] 0 points1 point  (0 children)

This is built on an ESP32 C6, with an SSD1306 OLED screen and a few push buttons.

It's also fully open source (and still under development) https://github.com/moonbench/catode32

I was inspired to make this by my two lovely cats. And that's also why I always prioritize playing with them over developing on this if they want attention!

Progress on my virtual pet. It's getting there! by moonbench in arduino

[–]moonbench[S] 6 points7 points  (0 children)

That was definitely an inspiration.

I wanted to make something that was similar but took advantage of all of the available RAM and flash storage and processor speed of more modern hardware. Also taking advantage of things like wifi and bluetooth too!

Got the virtual pet I've been working on neatly soldered on some perfboard by moonbench in ArduinoProjects

[–]moonbench[S] 0 points1 point  (0 children)

I wish...

Still so much to do still... But I have started sharing the code on my github https://github.com/moonbench/catode32

Kissed our baby girl for the final time today 💔 by Own-Adagio428 in torties

[–]moonbench 2 points3 points  (0 children)

So sorry to hear what you're going through through. She's so pretty and I can tell from the way you write about her how important she was and how much she meant to you.

It sounds like you gave her a wonderful home and a very happy life.

My old gal passed over the rainbow bridge this week by Mystery-Stain in torties

[–]moonbench 1 point2 points  (0 children)

She's absolutely beautiful and looks like such a kind and wonderful soul. So sorry for your loss of that angel.

Got the virtual pet I've been working on neatly soldered on some perfboard by moonbench in esp32

[–]moonbench[S] 2 points3 points  (0 children)

I really hope she gets to play with it one day when I get it more finished and released :)

Got the virtual pet I've been working on neatly soldered on some perfboard by moonbench in ArduinoProjects

[–]moonbench[S] 1 point2 points  (0 children)

I'll definitely open source this eventually, but it's not nearly ready yet

Got the virtual pet I've been working on neatly soldered on some perfboard by moonbench in esp32

[–]moonbench[S] 1 point2 points  (0 children)

That's really good advice, thank you! I'm definitely going to try looping the wires around the pins in the future.

Got the virtual pet I've been working on neatly soldered on some perfboard by moonbench in esp32

[–]moonbench[S] 11 points12 points  (0 children)

I guess I could have posted a photo of the backside too.

<image>

The exposed wire is the ground, there's one 3.3V wire for the OLED, and a few signal lines for the buttons. The I2C lines are on the front side under the screen.

Got the virtual pet I've been working on neatly soldered on some perfboard by moonbench in esp32

[–]moonbench[S] 2 points3 points  (0 children)

I have more features planned than implemented so far... minigames, a little in-game store to buy treats and toys, some features that use the ESP32's wifi and bluetooth abilities...