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

fixes #93 #167

Merged
merged 12 commits into from Sep 17, 2017
Merged

fixes #93 #167

merged 12 commits into from Sep 17, 2017

Conversation

@brihijoshi
Copy link
Contributor

brihijoshi commented Aug 1, 2017

This fixes #93

@HipsterBrown - Could you please let us know where to add the Fritzing demo as stated in the issue?

Yet to add - the "Available pin modes" section as done in the documentation of Interrupt Pins and the default setting of the pin if the mode is 'none'

@HipsterBrown

This comment has been minimized.

Copy link
Contributor

HipsterBrown commented Aug 1, 2017

@brihijoshi The Fritzing for Interrupts and PWM was moved to its own Tutorial page -> https://tessel.gitbooks.io/t2-docs/content/Tutorials/Interrupts.html

That issue was made before we refactored the docs to just show the available methods, events, and usage. The Fritzing with a brief tutorial description could now be it's own PR for the Tutorials section.

@brihijoshi

This comment has been minimized.

Copy link
Contributor Author

brihijoshi commented Aug 2, 2017

Thanks a lot! We will add the example in the Tutorial section.

@brihijoshi brihijoshi changed the title fixes #93 (DO NOT MERGE) fixes #93 Aug 11, 2017
@brihijoshi

This comment has been minimized.

Copy link
Contributor Author

brihijoshi commented Aug 11, 2017

Hey @HipsterBrown @Frijol we added the tutorial for the pin.pull() as well as a fritzing image that is uploaded on imgur. Please review.

var pin = tessel.port.A.pin[2]; // Select pin 2 on port A
var pullType = "pullup"; // Set the mode of `pin.pull to pullup`

This comment has been minimized.

Copy link
@HipsterBrown

HipsterBrown Aug 14, 2017

Contributor

Can you change this to single quotes, 'pullup' instead of "pullup", to keep it consistent in the sample code?

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Done (This code now resides in Tutorials)

var led = tessel.led[3]; // Blue LED of Tessel
pin.pull(pullType,(error, buffer) => { // Pin 2 pulled high

This comment has been minimized.

Copy link
@HipsterBrown

HipsterBrown Aug 14, 2017

Contributor

Do you know what the value of that buffer should be?

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

We're trying to check manually by making the circuit.

});
}, 500);

This comment has been minimized.

Copy link
@HipsterBrown

HipsterBrown Aug 14, 2017

Contributor

So this setInterval and led example code is out of scope for the API documentation. Just showing:

var tessel= require('tessel'); // Import Tessel

var pin = tessel.port.A.pin[2]; // Select pin 2 on port A

pin.pull('pullup', (error, buffer) => { // Pin 2 pulled high
  if (error) {
    throw error;
  }
  console.log(buffer.toString()) // what should this be?
}

displays how pin.pull is called with all its arguments. The rest of the example code is great for the Tutorial page.

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Thanks! This looks better for a basic code demonstration :)

This comment has been minimized.

Copy link
@brihijoshi

This comment has been minimized.

Copy link
@mittalshravika

mittalshravika Aug 21, 2017

Contributor

screenshot 2017-08-21 20 55 56

We are getting the output as shown above when we are trying to print the value of buffer.

}
});
setInterval({

This comment has been minimized.

Copy link
@HipsterBrown

HipsterBrown Aug 14, 2017

Contributor

setInterval accepts a function as the first argument to be called at the interval of time set as the second argument. https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval#Example_1_Basic_syntax

To fix this:

setInterval(() => {
  ... // call pin.read
}, 500);

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 15, 2017

Author Contributor

Thanks for this! :)


Take a look at the following circuit. The code example given below turns on the Blue LED of the Tessel module when the pushbutton is pressed and turns off the Blue LED when the pushbutton is released.

![Pin-Pull using Push buttons](http://i.imgur.com/OYJZ8Dp.jpg)

This comment has been minimized.

Copy link
@HipsterBrown

HipsterBrown Aug 14, 2017

Contributor

Nice Fritzing! 👏

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Thanks! @mittalshravika at it :)

pin.pull(pullType, callback);
```

Example of the `pin.pull(mode)` command using a pushbutton. The code example given below turns on the Blue LED of the Tessel module when the pushbutton is pressed and turns off the Blue LED when the pushbutton is released.

This comment has been minimized.

Copy link
@HipsterBrown

HipsterBrown Aug 14, 2017

Contributor

This should just say Example: to stay consistent with the other Usage documentation. Then link to Tutorial page after the example, i.e.:

[Learn more about using the Pullup / Pulldown API.](/Tutorials/pinpull.html)

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Done


Pins 2-7 on both Ports are available for pullup and pulldown.

The basic function of a pull-up resistor is to insure that given no other input, a circuit assumes a default value. The 'pullup' mode pulls the line high and the 'pulldown' mode pulls it low.

This comment has been minimized.

Copy link
@HipsterBrown

HipsterBrown Aug 14, 2017

Contributor

Nice description. 👍

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Thanks! :)


Pins 2-7 on both Ports are available for pullup and pulldown.

The basic function of a pull-up resistor is to insure that given no other input, a circuit assumes a default value. The 'pullup' mode pulls the line high and the 'pulldown' mode pulls it low.

This comment has been minimized.

Copy link
@Frijol

Frijol Aug 15, 2017

Member

typo: "insure" -> "ensure"

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Done


Pins 2-7 on both Ports are available for pullup and pulldown.

The basic function of a pull-up resistor is to insure that given no other input, a circuit assumes a default value. The 'pullup' mode pulls the line high and the 'pulldown' mode pulls it low.

This comment has been minimized.

Copy link
@Frijol

Frijol Aug 15, 2017

Member

Agreed, this is a lovely description. Can you add "pullup" and "pulldown" to the docs glossary?

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Added

led.off();
}
// Pin 2 reads low when the pushbutton is pressed since its connection with ground gets complete

This comment has been minimized.

Copy link
@Frijol

Frijol Aug 15, 2017

Member

suggest changing phrasing "gets complete" to "is completed"

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Done (The code now resides in "Tutorials")

@@ -0,0 +1,49 @@
# Pull- Pins

Suppose a pin is configured as an input. If nothing is connected to the pin and the program tries to read the state of the pin, it would be in a 'floating' state i.e an unknown state. To prevent this, a pull-up or a pull-down state is defined. They are often used in the case of Buttons and Switches.

This comment has been minimized.

Copy link
@Frijol

Frijol Aug 15, 2017

Member

"pull-up" and "pullup" are both used in this PR, but it would be better to choose a standard. I think hyphenated is standard, but haven't researched this.

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Yes indeed. Hyphenated is standard. Will edit it everywhere.

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Hyphenated is now used in the text as per wikipedia (https://en.wikipedia.org/wiki/Pull-up_resistor) but non-hyphenated is the default arg value in the firmware, so we can't change it in the text.

var pin = tessel.port.A.pin[2]; // Select pin 2 on port A
var pullType = "pullup"; // Set the mode of `pin.pull to pullup`

This comment has been minimized.

Copy link
@Frijol

Frijol Aug 15, 2017

Member

"pullup" vs "pull-up" in comment

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

"pullup" is the default arg value as defined in the t2-firmware code here : https://github.com/tessel/t2-firmware/blob/master/node/tessel-export.js#L737-L758

var pin = tessel.port.A.pin[2]; // Select pin 2 on port A
var pullType = "pullup"; // Set the mode of `pin.pull to pullup`

This comment has been minimized.

Copy link
@Frijol

Frijol Aug 15, 2017

Member

backtick is in the wrong place, should end backtick quotes after pin.pull

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Done

}, 500);
```
[More Information on Pull-up pins and resistors](https://learn.sparkfun.com/tutorials/pull-up-resistors)

This comment has been minimized.

Copy link
@Frijol

Frijol Aug 15, 2017

Member

Information should not be capitalized

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Done

}, 500);
```
[More Information on Pull-up pins and resistors](https://learn.sparkfun.com/tutorials/pull-up-resistors)

This comment has been minimized.

Copy link
@Frijol

Frijol Aug 15, 2017

Member

Optional, might be useful to mention that the link goes to Sparkfun or otherwise designate it as an external (non-Tessel) link

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Aug 21, 2017

Author Contributor

Done :)

@brihijoshi

This comment has been minimized.

Copy link
Contributor Author

brihijoshi commented Aug 29, 2017

@Frijol @HipsterBrown Could you please review the same? We have made the changes and also put up a doubt regarding "Buffer"

@HipsterBrown

This comment has been minimized.

Copy link
Contributor

HipsterBrown commented Aug 31, 2017

@brihijoshi The content looks good to me. Based on my testing, the buffer returned in the pin.pull callback is a hex address 88. If you change your sample code to:

pin.pull('pullup', (error, buffer) => {
    if (error) {
        throw error;
    }
    console.log(buffer.toString('hex'));
})

You'll see the console.log outputs 88. I believe that is the OK code from the communication with the SAMD21. Maybe @Frijol can confirm that.

}
});
setInterval(() => {

This comment has been minimized.

Copy link
@HipsterBrown

HipsterBrown Aug 31, 2017

Contributor

Place this setInterval inside the callback of pin.pull so we know that command is done before calling the first pin.read.

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Sep 3, 2017

Author Contributor

Cool. Will do that

This comment has been minimized.

Copy link
@brihijoshi

brihijoshi Sep 3, 2017

Author Contributor

Done!

@brihijoshi

This comment has been minimized.

Copy link
Contributor Author

brihijoshi commented Sep 3, 2017

@HipsterBrown @Frijol Made the required changes. Please review :)

Copy link
Member

Frijol left a comment

Looks good, thanks for the hard work! A couple of extra comments to really polish, but this is mergeable as is.

throw error;
}
console.log(buffer.toString('hex')); // The output would be 88. Which is an OK Signal from SAMD21

This comment has been minimized.

Copy link
@Frijol

Frijol Sep 3, 2017

Member

Nice! Glad you found it.


Suppose a pin is configured as an input. If nothing is connected to the pin and the program tries to read the state of the pin, it would be in a 'floating' state i.e an unknown state. To prevent this, a pull-up or a pull-down state is defined. They are often used in the case of Buttons and Switches.

Pins 2-7 on both the Ports are available for interrupts.

This comment has been minimized.

Copy link
@Frijol

Frijol Sep 3, 2017

Member

"...available for interrupts" – did you mean to say pull-up and pull-down instead of interrupts?

}
setInterval(() => {
pin.read(function(error, number){

This comment has been minimized.

Copy link
@Frijol

Frijol Sep 3, 2017

Member

Optionally, can you use a more descriptive variable name than "number"? What does the number represent?

@Frijol
Frijol approved these changes Sep 3, 2017
@Frijol

This comment has been minimized.

Copy link
Member

Frijol commented Sep 3, 2017

Ah- I think you also need to run npm run build to update the table of contents with your tutorial (@HipsterBrown correct me if I'm wrong on that?)

@HipsterBrown

This comment has been minimized.

Copy link
Contributor

HipsterBrown commented Sep 5, 2017

book.json should be updated as well -> https://github.com/tessel/t2-docs#changing-the-contents

@brihijoshi

This comment has been minimized.

Copy link
Contributor Author

brihijoshi commented Sep 11, 2017

@HipsterBrown @Frijol , I ran the gitbook locally and updated the SUMMARY.md file by running npm run build. The contents have been updated as well. Please review.

@Frijol Frijol merged commit 004ef42 into tessel:master Sep 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.