Skip to content

Virtual pet face or "tamagotchi" - #255

Merged
voloved merged 67 commits into
joeycastillo:mainfrom
evyd13:virtual-pet
Nov 22, 2026
Merged

voloved merged 67 commits into
joeycastillo:mainfrom
evyd13:virtual-pet

Conversation

@evyd13

@evyd13 evyd13 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Here it is! The virtual pet face. It is heavily inspired by Tamagotchi Uni and P1/P2.

Written user guide

Sensor Watch Virtual Pet Guide.odt
Sensor Watch Virtual Pet Guide.pdf

I have written a guide on how to use the Virtual Pet Face.

Virtual Pet Face

(Note: this was written before major changes were made to the background functionality of the virtual pet face. Please refer to the written guide or virtual_pet_face.h for an updated version)

PXL_20261015_085935220.2.mp4

In this demo, it woke up at 11 AM. That was not supposed to happen. Time alive was shown in minutes, not days. Part of testing :-)

It has all of the features you would expect a virtual pet to have. It works perfectly on both classic and custom LCDs, as it was designed with the classic LCD in mind. It has some restrictions with which segments can and can't be used which made it a challenge to think of what to put on the display. It works as primary or secondary watch face, whatever floats your boat. In the low energy mode, the display updates once every minute while still showing animations.

What is most notable is how it handles being in the background: every time it needs to poop, grows more hungry, evolves into its next life phase, hatches, or whatever, it will run the game logic.

The background task used to be run every minute, even if nothing were to happen. I've done a lot of work to make sure it's as power efficient as possible. If it's something major, like it needs your attention, it will jump to the foreground and make noise. I will be keeping track of the battery voltage for as long as I take care of casiotchi.

If you don't like the noises, you can turn those off. There is a toggle in the action menu. I am in situations where loud noises can be extremely disruptive so the safety of being able to turn it off is very nice. Just don't forget to turn them on again... 💔 Even button beeps are disabled with this toggle. You can safely feed it during your "important" meeting. Nothing is more important than casiotchi. Want to take a pause? Do you really want to abandon your pet? You'll kill them 😭

Reviewer, please note that I might update the phase values (time_hunger, etc) later, because it takes a long time to test those. No AI tools were used in the development of this watch face. This is my first project in C as well. If I could have done something a different (better) way, please let me know.

I saw two other pet faces being made by danielschrempf and MitchMitch42, which sadly didn't get into Second Movement, so I hope I don't step on any toes. Their work inspired me to take on this project.

Virtual pets were harmed in the making of this watch face.

Full explanation (as found in virtual_pet_face.h):

The virtual pet face is a virtual pet, which can grow, live happily depending on how you take care of it,
or die.
Life phases:

  • Egg (5-120 min)
  • Baby (45 min)
  • Child (~1 day)
  • Adult

Depending on how you take care of it, you can get a different type of pet.
Types:

  • Needy (More than 4 care mistakes)
  • Average (2-4 care mistakes)
  • Easy (less than 2 care mistakes)

The type describes the amount of care one needs. If you take bad care of your pet, it will need more care in the future.
Care mistakes only count in the child phase.

Happiness: The pet will appear:

  • Sad if happiness is below 2
  • Neutral if happiness is between 2 and 4
  • Happy is happiness is above 4 (max 6)

Happiness can be improved with snacks (dont overfeed!) or by playing a game. This stat will go down with time.

Hunger: Your pet will get hungry over time, just like it will be less happy if you don't play with it!

Sickness: Sometimes your pet gets sick. It happens when you don't take good care of your pet. To heal your pet, give it medicine.
Sickness will be shown as a skull in the top left (weekday).

Poop: Sometimes your pet will poop. It will be on the screen, usually in the lower or upper right corner, as a box with a visible odor going back and forth.
To remove poop, clean the pet. If you fail to remove poop, the pet might become sick.

Attention: When your pet needs attention, it will make a noise and the bell indicator will appear. If you don't take care of your pet within 15 minutes,
it might get sick! (It counts as a care mistake)

Sleep: Just like you, your pet sleeps. In every life phase it will sleep a different amount of time.
Sleep is visible on with "ZZ" in the top left. A bed will be visible. You can't wake it up, it will wake up on its own.

Buttons:
Press Light to open the status menu. In the status menu, you can advance the menu by pressing the Light button again.
When at the last menu item, pressing Light will exit the menu and show the pet.
The following stats can be seen:

  • Hu - hunger
  • Ha - happiness
  • Al - days alive (age)
  • Ph - type/phase

Press Alarm to open the action menu. Here you can feed your pet, play with it or give it medicine. Use Light to advance, Alarm to confirm your choice.
When at the last item, advancing will close the menu.

Unfortunately, not all pets life forever. This watch face keeps track of time using the RTC counter. This is uninterrupted and won't change when the watch time or date changes.
This also means that every 388 days after inserting the battery, the pet will die of "age", or in this case, of integer overflow.

Game (higher/lower):
If your happiness level is low, you can increase it by playing a game. The game is always a "higher/lower" card game.
The game has 5 rounds. In each round, a number is displayed. Guess if the next number will be higher or lower.

  • Press Light for higher, Mode for lower.
  • Press Alarm to go back.

At the end of the game, the score is displayed.
Did you win? Your pet will be very happy!

@evyd13
evyd13 marked this pull request as ready for review October 18, 2026 06:03
@evyd13 evyd13 changed the title Add virtual pet face Virtual pet face or "tamagotchi" Oct 18, 2026
@evyd13

evyd13 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

I just noticed that it won't go to sleep, because when a background task is planned, the inactivity timer is reset. Thus it won't go to sleep. I will rewrite it to use the advisory instead.

@evyd13
evyd13 marked this pull request as draft October 21, 2026 15:59
@evyd13
evyd13 marked this pull request as ready for review October 21, 2026 18:13
@evyd13

evyd13 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

I have finally pretty much fixed the sleep issue. Maybe a bug or a feature, when waking up from sleep, I try to go back to sleep on timeout. however, on waking up, you first have to press a button to fully wake the watch up. I'd like the watch to fully wake up until timeout and then go back to sleep if no button was pressed. Could use some help, but I think it is fine as it is right now. This is behaviour in the emulator.

This means the watch face is done, really.

@voloved

voloved commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

I have finally pretty much fixed the sleep issue. Maybe a bug or a feature, when waking up from sleep, I try to go back to sleep on timeout. however, on waking up, you first have to press a button to fully wake the watch up. I'd like the watch to fully wake up until timeout and then go back to sleep if no button was pressed. Could use some help, but I think it is fine as it is right now. This is behaviour in the emulator.

This means the watch face is done, really.

Have you tested all of this sleeping and timing out on the hardware itself as well as the simulator?

@evyd13

evyd13 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

I was planning on doing just that today. Just uploaded the firmware to my second sensor watch.

@evyd13

evyd13 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Sensor Watch Virtual Pet Guide.odt
Sensor Watch Virtual Pet Guide.pdf

I have written a guide on how to use the Virtual Pet Face.

@voloved

voloved commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

For the title, you can avoid rewriting the top-left every from when there's no title with this change:

diff --git a/watch-faces/complication/virtual_pet_face.c b/watch-faces/complication/virtual_pet_face.c
index 774b2f53..1333c71f 100644
--- a/watch-faces/complication/virtual_pet_face.c
+++ b/watch-faces/complication/virtual_pet_face.c
@@ -899,17 +899,17 @@ static void _draw_sickness(void *context) {
     );
 }
 
-static bool _should_show_title(void *context) {
-    virtual_pet_state_t *state = (virtual_pet_state_t *)context;
-    uint32_t now_ts = rtc_counter_to_seconds(watch_rtc_get_counter());
-    return (now_ts - state->show_title_ts) < 2;
-}
 static void _draw_title(void *context) {
     virtual_pet_state_t *state = (virtual_pet_state_t *)context;
-    if (_should_show_title(state))
-        watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "Pet", "PE");
-    else
+    if (state->show_title_sec < 0) {
+        return;
+    } else if (state->show_title_sec == 0) {
         watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "   ", "  ");
+        state->show_title_sec = -1;
+    } else {
+        watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "Pet", "PE");
+        state->show_title_sec--;
+    }
 }
 
 static void _draw_attention(void *context) {
@@ -978,7 +978,7 @@ static void _draw_pet(void *context) {
     if (state->paused) return;
     if (state->phase > VIRTUAL_PET_PHASE_EGG && state->phase != VIRTUAL_PET_PHASE_DEAD) {
         _draw_poop(state);
-        if (!_should_show_title(state)) _draw_sickness(state);
+        if (state->show_title_sec == 0) _draw_sickness(state);
         if (state->is_eating) _draw_food(state);
     } else if (state->phase == VIRTUAL_PET_PHASE_DEAD) {
         _draw_little_ghost(state);
@@ -1876,7 +1876,7 @@ void virtual_pet_face_activate(void *context) {
     _exit_menu(state);
     state->face_active = true;
     _activate_ts(state);
-    state->show_title_ts = rtc_counter_to_seconds(watch_rtc_get_counter());
+    state->show_title_sec = 3;
     if (state->paused && state->paused_automatically) _unpause(state);
     // Handle any tasks related to your watch face coming on screen.
 }
diff --git a/watch-faces/complication/virtual_pet_face.h b/watch-faces/complication/virtual_pet_face.h
index 623b50c8..4b8b110f 100644
--- a/watch-faces/complication/virtual_pet_face.h
+++ b/watch-faces/complication/virtual_pet_face.h
@@ -263,7 +263,7 @@ typedef struct {
     uint8_t face_idx; // needed for boot sound
     bool face_active;
     uint32_t activate_ts;
-    uint32_t show_title_ts;
+    int8_t show_title_sec;
     bool paused;
     bool paused_automatically;

@voloved

voloved commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Also, I see a lot of functions that take in void *context and cast it to virtual_pet_state_t.
In all of them, it seems that you're sending in an already cast state. You can instead drop the cast and use the input of virtual_pet_state_t *state

@evyd13

evyd13 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Done. Thanks again.

@voloved
voloved merged commit 2704b6f into joeycastillo:main Nov 22, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants