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

Fix pinout selection #1

Open
bschulz1701 opened this issue Jul 6, 2018 · 1 comment
Open

Fix pinout selection #1

bschulz1701 opened this issue Jul 6, 2018 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@bschulz1701
Copy link
Contributor

Improve the way pinout is selected between various margay boards

@bschulz1701 bschulz1701 added bug Something isn't working enhancement New feature or request labels Jul 6, 2018
@bschulz1701 bschulz1701 self-assigned this Jul 6, 2018
@bschulz1701
Copy link
Contributor Author

By reading the EEPROM logger info this could be made automatic.

I propose making multiple options:
Margay Logger(Model_1v0); Forces the logger instatiated to use the Model_1v0 parameters, or any other board options
Margay Logger(Auto); Reads the serial number written to the EEPROM, checks the board type, and chooses the appropriate logger based on this. Should default to most recent production version.

Code (Proposed, but untested:

In Margay.h

enum board
{
    Model_0v0 = 0,
    Model_1v0 = 1,
    Auto = 255
};

In Margay.cpp

Margay::Margay(board Model_)
{
	if(Model_ == Auto) {
		unsigned int Len = EEPROM.length(); //Define local shorthand for length
		unsigned int Val = (EEPROM.read(Len - 8) << 8) | (EEPROM.read(Len - 7)); //Get device ID bytes of SN
		switch(Val) {
			case 0x4D00:  //Check against serial number ID of model v0.0
				Model_ = Model_0v0;  //Overide model definition
				break;
			case 0x4D01: //Check against serial number ID of model v1.0
				Model_ = Model_1v0;  //Overide model definition
				break;
			default:
				Model_ = Model_1v0; //Overide with most recent production version
			...
		}
	}


	//Define model params as normal. Either using forced model name, or overwritten model name due to auto selection
	if(Model_ == 1) {  
		...
	}

	else if(Model_ == 0) {
		...
	}

	Model = Model_;
}

@bschulz1701 bschulz1701 added good first issue Good for newcomers and removed bug Something isn't working labels Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant