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

Edits to EduMKII BP Examples #849

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

croberts15
Copy link

These edits make the code compatible across multiple boards. They have been tested on the MSP432,
MSP4305529, MSP430FR6989, and TivaC123.

A change log can be seen below:

i. AccelermoeterLED

  1. Permanently uncomment analogReadResolution(12)

ii. AccelerometerSerial

  1. Permanently uncomment analogReadResolution(12)

iii. EduBP_MKII_Production_Test

  1. Added analogReadResolution(12)
  2. Changed joystick threshold for MSP432 to be able to trigger
  3. Change myScreen.setFontSize(1) instead of 2, line 372
  4. Add in opt3001

iv. EduBP_MKII_Production_Test_Serial

  1. Added analogReadResolution(12)
  2. Changed joystick threshold
  3. Add in opt3001

v. GatorHoleBuzzer

  1. Edited comments to fit the code
  2. Add delay for 432 and Tiva

vi. joystickDrawColor

  1. add analogReadResolution(12)
  2. pinMode(drawButton, INPUT_PULLUP);
  3. pinMode(32,INPUT_PULLUP);
  4. pinMode(33,INPUT_PULLUP);

vii. joystickSerial

  1. analogReadResolution(12)

viii. KonamiContra

  1. Analogreadresolution(12)
  2. Fixed comments for buttonA and B, waiting for right
  3. Delete Delay for button B
  4. Lower threshold for push up and push right to 4085 for msp432
  5. Add condition to fail when waiting up and goes down, waiting left goes right etc

ix. KonamiContraBuzzer

  1. Same as KonamiContra

x. LCD_Joystick

  1. Permanently uncomment analogReadResolution(12)

xi. LCD_LifeGame

  1. Add this into the board definitions above
  2. #if defined(MSP430FR6989)
  3. #define ROWS 25
  4. #define COLS 25

xii. MicophoneInLEDOut

  1. Permanently uncomment anologReadResolution(12)

xiii. ServoFromJoystick

  1. Add analogreadResolution(12)
  2. Correct comments/variable names

These edits make the code compatible across multiple boards with a few
additional core file tweaks.  They have been tested on the MSP432,
MSP4305529, MSP430FR6989, and TivaC123
@robertinant
Copy link
Member

Thanks for the pull!

Reviewing the code I see that you added analogReadResolution(12) to all Sketches. Note that not all LaunchPad's support this which will break the example Sketches for those platforms. Is there a specific reason to want 12 bit vs the standard 10 bit? I would rather see analogReadResolution(12) commented out and then add a comment stating that if you would like higher resolution on platforms that support to comment out that line.

@croberts15
Copy link
Author

The example code was already written with 4096 as a maximum value when either mapping an analog value to an LED, detecting a direction of the joystick, etc. Since different boards were defaulting to different analog read resolutions (MSP432 was 10 bit while I believe the rest that I tested were 12 bit) the code examples with hard coded max values would break unless run with 12 bit resolution. I found it easier to just declare 12 bit as the default, especially knowing the G2 is incompatible with the EduMKII BP due to the 40 pin header.

It can easily be changed to the default 10 bit, but this would either take defining the max value at run time dependent on the read resolution, or ensuring all boards were defaulting to 10 bit resolution and dropping the max values to 1024.

@rei-vilo
Copy link
Member

As a solution, add a getAnalogMaxValue() function which returns the maximum value linked to the resolution.

Very useful for mapping data.

uint32_t grossValue = readAnalog(pinNumber);
uint32_t netValue = map(grossValue, 0, getAnalogMaxValue(), 0, 3300);

@croberts15
Copy link
Author

@rei-vilo Are you saying create this function or is this something that already exists?

I'm having trouble finding anything like this in energia documentation, but would be glad to try and put something together and then revise the eduMKII code to reflect this change. It would definitely help make the code more robust.

@rei-vilo
Copy link
Member

@croberts15 The getAnalogMaxValue() function doesn't exist yet. You need to create and add it.

Added the functions to make is to the analog resolution maximum value
didn't have to be hardcoded
@croberts15
Copy link
Author

I added a function in to get the current analog read resolution as well as a function to return the maximum value for the current resolution for all non-MT devices, but I can't figure out how to edit core files for the MT devices and have energia factor the changes in for testing. Any advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants