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

EEPROM Initialization #4

Open
delipunch opened this issue Jun 12, 2015 · 7 comments
Open

EEPROM Initialization #4

delipunch opened this issue Jun 12, 2015 · 7 comments

Comments

@delipunch
Copy link

No way given, aside from normal use, to initialize EEPROM.

@pepijndevos
Copy link
Owner

This is true. What I did the first time is comment out some code so the data is read from FLASH. Then I forgot about it.

https://github.com/pepijndevos/arduino-boy/blob/master/gameboy.ino#L167

@delipunch
Copy link
Author

How about this

//This sketch is a way of initializing the EEPEROM for Bill's Arduino (https://github.com/pepijndevos/arduino-boy)
//By Alex McPhail
//I don't care how you use this
#include <EEPROM.h>
#include "output.h"

void setup()
{
  for(int i=0;i<=PLAYER_LENGTH;i++)
    EEPROM.write(i,DATA_BLOCK[i]);
}

void loop() {}//nothing to do

@pepijndevos
Copy link
Owner

That would work. How would you suggest to include it in the project? Maybe the init could check if the EEPROM contains valid data and fill it in otherwise. PR welcome.

@pepijndevos
Copy link
Owner

Actualy, it's a bit more subtle. Since I only store one Pokemon, the layout in EEPROM is different from the one in FLASH.

@delipunch
Copy link
Author

So what's the difference in the layouts? And you could include it as a separate .ino

@pepijndevos
Copy link
Owner

If you'll look at output.h you'll see there are 6 Pokemon, 6 trainer names, and 6 nicknames. Just the first of those are stored in EEPROM. You can see the code in the main loop. The indices start at 0, 44 and 55.

@delipunch
Copy link
Author

So I've made a fork, and it mirrors your data, thus doesn't need initialization, because it's your save, "copied". All I did was remove all instances of Serial, and changed three 44's to 48's (lines 78, 86, 93). No idea why it's done what it's done :P

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

2 participants