Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32/ESP8266 port? #1

Open
NoNamedCat opened this issue Mar 25, 2022 · 8 comments
Open

ESP32/ESP8266 port? #1

NoNamedCat opened this issue Mar 25, 2022 · 8 comments

Comments

@NoNamedCat
Copy link

Hello Gary. Thks a lot for porting this to the Arduino IDE.
I try to compile the source for the ESP32 and i cant. I think that the problem is that you put in the emulator assembly code for the atMega328 architecture...

Im trying to port the emulator for this architecture the esp32 and/or esp8266 and my head crashes a lot in the journey.
Can you give me a hint of what i need to do for porting this code or the mcuGotchi to this plataforms?

@NoNamedCat
Copy link
Author

Maybe a pure c++ or c emulator like the mcugotchi?

@GaryZ88
Copy link
Owner

GaryZ88 commented Mar 25, 2022

Hi,

I didn't use any assembly in this project, it is a pure C implementation. There is one Arduino directive I used, "PROGMEM", it will force the compiler to put static variable into FLASH instead of RAM.

Also, to reduce the program size, I used U8g2 library to handle graphics. Due to the complex paging mechanism in U8g2, the graphical routine is very hard to understand.

I suggest you can start your porting with TamaTool, the original emulator created by TamaLib creator.

@NoNamedCat
Copy link
Author

NoNamedCat commented Mar 25, 2022

Ok I have it working now in the ESP32... And using a Nokia display... I made a few changes in the code to make it work. Are you interested in the code?

I have problems with the resolution but now i can see the egg trying to hatch :)

Also I noted that you hardcoded the Buttons and the Speaker pins.... So i made a change in the code so you can select the pinmap using #define in the main file

image

@GaryZ88
Copy link
Owner

GaryZ88 commented Mar 25, 2022

Please noted that I disabled all the CPU clock speed emulation code to improve the speed and program size. If you are using ESP32, you have to add back the clock speed emulation parts.

static void hal_sleep_until(timestamp_t ts) {
...
}

static timestamp_t hal_get_timestamp(void) {
...
}

@NoNamedCat
Copy link
Author

NoNamedCat commented Mar 25, 2022

Tks Gary.

Now I'm reading the code for the graphics. Now i have to solder some buttons to see the icons. But now i resized the pixel size and centered in the screen. I have modiefied the code so no blank spaces between the pixels. Tks a lot!

BTW... this screen (nokia 1100) consumes less than 1mA without the Back-Light, so the battery will least longer!

image

@NoNamedCat
Copy link
Author

Is there a way to update the screen dynamically? I noted that the emulator update the screen every defined time...
If we can update the screen only when the image is changed we can get some time for other things like the emulation itself.

@GaryZ88
Copy link
Owner

GaryZ88 commented Mar 26, 2022

It can't. But I can direct you the location to tune the graphics refresh rate and CPU speed:
tamalib.c

  • tamalib_mainloop_step_by_step()

cpu.c

  • Search the variable "CPU_SPEED_RATIO"

ArduinoGotchi.ino

  • hal_sleep_until()
  • hal_get_timestamp()

@AljokExe
Copy link

Hey Gary, can I get your email? I am trying to replicate your tamagotchi project as a gift for my girlfriend, yet I cant find an available ROM anywhere.
Care to provide me with some info? alvaro.ps.graca@gmail.com

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

No branches or pull requests

3 participants