Repository navigation
Virtual pet face or "tamagotchi" - #255
Conversation
|
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. |
… change meds behaviour
|
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? |
|
I was planning on doing just that today. Just uploaded the firmware to my second sensor watch. |
|
Sensor Watch Virtual Pet Guide.odt I have written a guide on how to use the Virtual Pet Face. |
|
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; |
|
Also, I see a lot of functions that take in |
|
Done. Thanks again. |
…if not hungry and happy
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):