Tamaguino AB --Tamagotchi for Arduino


(Scott R) #1

Tamaguino AB --Tamagotchi for Arduino

This Afternoon I migrated Alojz Jakob’s [Tamaguino] to the Arduboy

ArduboyRecording

Download: Tamaguino-AB

Controls:
UP = Button 1- MENU
A = Button 2 - SELECT
B = Button 3 - BACK
LEFT + B = Display Off
RIGHT + B = Display On

Changes made:
Move to Arduboy2 Library
Remove Wire + SPI Stuff
Convert & relocate Images
Edit Speaker pin
Framerate too fast
Migrate From Arduino Tone() to ArduboyTones
LED stuff
Print stuff (BLACK) -(WHITE)
Improve Button Handling
OLED Sleep

To Do:
More intereaction
Better handling for audio - Maybe Arduboy Beep
Improved Power saving

Before posting code the project uses GNU GPLv3. I am unsure what the best practise is, can I just provide the code I want to keep with my changes in my own git master with licence and link to the original authors? or do I have to fork and include all original code?


Is there a virtual pet game?
PWR_DOWN & external interrupt
Just got my Arduboy - What Game Should I Make? + Giving Away My Concept Images!
Running Arduboy sketches on a UNO or other 328p based board
Complete newbie looking for help with a goal
A-Maze a game of random generated mazes
ArduBreakout on a watchX
(Scott) #2

I doubt OLED sleep will get you much savings (relative to the overall system power), than just setting all pixels off would, but its easy to do since there are already Arduboy2 library functions to do it.

As you are probably aware, improved power saving for this sort of thing has been discussed here:


(Pharap) #3

Glad to see you managed to cut “10 months” down substantially. :P


According to https://choosealicense.com/licenses/gpl-3.0/ the GPLv3 requires that you:

  • disclose your source
  • include the licence and copyright notice of the original
  • state any changes you have made
  • release your code under the same licence

(The last of those conditions being why it’s sometimes considered to be a controversial licence.)


(Scott R) #4

I guess all that staring at all that D&U source for so long has paid off :stuck_out_tongue:

I ‘think’ I’ve covered it.


I love how making my own $12 Arduboy and playing around with the D&U code made it so much easier to figure out what was what.

One day I may be able to completely code something myself…Give or take a lifetime :joy:


#5

This is so cool. I am a huge fan of tamagotchi! This is one of the best things I’ve downloaded for my Arduboy!


(Pharap) #6

I found mine a while back. It needs new batteries.


(Scott R) #7

Thanks I have added displayOn/Off with button combos.

Thank you, I’m glad someone is enjoying it.
If you really want to show your appreciation there’s a “buy me a coffee” button on the original authors site (link in first post).


(Simon) #8

Great effort Scott. How much work was involved in the migration?


(Scott R) #9

Initially replacing WIRE.h and SPI.h with the Arduboy2 library + adding arduboy. to most and changing the pins to correspond with my pro micro clone was pretty much enough to get it running with garbled graphics.

I had to convert of the images with Team a.r.g’s tool and remove the width+height to fix the image display issues.

All the Button pin stuff now removed to use arduboy.pressed()

Only pin 5 (speaker) temporarily remains.

The Library changes made a huge reduction in size.
Before:
Sketch uses 32616 bytes (113%) of program storage space.
After:
Sketch uses 26378 bytes (88%) of program storage space.


(Scott R) #10
  • Improved input now using justPressed for all except the OLED on/off.
  • removed [WIP] from topic title - project has all features of original

I am able to put the system into PWR_DOWN and wake with the watchdog timer. But am struggling to figure out the interrupt using a button.

Looking at the watchdog timer it looks like I would have to wake every 8 seconds and increase a counter to extend sleep time and finally using an interrupt to wake and trigger events.


(Kevin) #11

I thought I put a button on the same as a hardware interrupt pin but it looks like I gave that up for having a better bitmask for reading the buttons. Sorry!


PWR_DOWN & external interrupt
(Scott R) #12

Micro, Leonardo, other 32u4-based boards -Digital Pins Usable for interrupts - 0, 1, 2, 3, 7

on a Leonardo:
7 is INT.6
8 is PCINT4

Arduboy:
7 is A
8 is B

I’m 99% sure its my implementation …but then I don’t really know what I’m doing really so…

Also on the Arduino board reference (at the bottom) pin 7 = INT.4 where on leonardo boards it is labelled as PE6 (INT.6/AIN0)(1) https://www.arduino.cc/en/Hacking/PinMapping32u4


(Scott) #13

At my suggestion, you did. The A button is on INT6 (PE6, Arduino Pin 7), which is directly supported as an Arduino interrupt.

The B button can also generate an interrupt : PCINT4 (PB4, Arduino Pin 8).


(Scott R) #14

Yep the 1% of it not being me went out the window.
Right now I can sleep or wake and am slowly joining the dots to wake and sleep.

to clear up where I was being confused with the labels

External Interrupts:
Pin 3 (interrupt 0),
Pin 2 (interrupt 1),
Pin 0 (interrupt 2),
Pin 1 (interrupt 3)
Pin 7 (interrupt 4)

I still have no idea what the INT.6 label is all about…?


(Scott R) #15

Sketch now uses 25322 bytes (88%) of program storage space now that I’m using ArduboyTones instead of Arduino tone().

Not really sure if the power saving stuff will be required I’m yet to keep one alive longer than half a day…


(Scott R) #16

Highly likely my code needs a some work but I got it working.

Next up is extending the watchdog timer beyond 8 seconds…