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

Make sample show more examples of std::function and std::bind #1378

Merged

Conversation

frankdownunder
Copy link
Contributor

No description provided.

myLed1.blink(true);
myLed2.setTimer(500);
myLed2.blink(true);
WifiStation.enable(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the Wifi* call on this line and the one below. They are not directly related to the example and to what you are trying to demonstrate.

@slaff slaff added this to the 3.6.0 milestone May 14, 2018
@slaff
Copy link
Contributor

slaff commented May 14, 2018

@frankdownunder Before I merge this PR I would like to know if you tested it on a real device?

{

public:
Task() {};
bool setTimer(int reqInterval) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding-Style: Put the opening curly brace on the next line.

}

// This example show the way delegates have been used in Sming in the past.
void callOldDelegate() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding-Style: Put the opening curly brace on the next line.

bool ledState = true;
};
// This example shows how to use a plain old ordinary function as a callback
void callPlainOldOrdinaryFunction() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding-Style: Put the opening curly brace on the next line.



// This example shows how to use std::bind to make us of a function that has more parameters than our signature has
void showHowToUseBind() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding-Style: Put the opening curly brace on the next line.


// Sming now allows the use of std::function
// This example shows how to use a lamda expression as a callback
void callLamda() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding-Style: Put the opening curly brace on the next line.

LedBlinker myLed2 = LedBlinker(LEDPIN_2);

// This example shows how to use a member function as a callback
void callMemberFunction() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding-Style: Put the opening curly brace on the next line.

@frankdownunder
Copy link
Contributor Author

@slaff I built this sample using Ubuntu from the Windows Store (the replacement for WSL on Windows 10). To build it, I had to add these lines into makefile-user.mk (which I did not commit)

size of the flash chip

SPI_SIZE ?= 4M
COM_PORT = /dev/ttyS7

I tested it on a Wemos D1 mini by running it for a couple of minutes.

@frankdownunder
Copy link
Contributor Author

@slaff Its hard to know what coding style sming uses.
I dislike having the curly brace on the same line, but I tried to follow the convention, eg in HardwareSerial

      if(uart_get_debug() == uartNr) {
          uart_set_debug(UART_NO);
      }

Similarly if you turn on visible spaces, approx third of all lines in source code use spaces instead of tabs.
Im quite happy to follow the coding style if I can guess what it might be!

@slaff
Copy link
Contributor

slaff commented May 15, 2018

Its hard to know what coding style sming uses.

That is something that, hopefully, will be explained and enforced soon. For now please make the requested changes above.

@frankdownunder
Copy link
Contributor Author

frankdownunder commented May 15, 2018 via email

@slaff
Copy link
Contributor

slaff commented May 15, 2018

I did

@frankdownunder Can you push your changes to github? I don't see them and there is no new commit showing up.

@frankdownunder
Copy link
Contributor Author

frankdownunder commented May 15, 2018 via email

@slaff
Copy link
Contributor

slaff commented May 15, 2018

I am new to git, I find it very confusing ☹

It is not that difficult ;-) . Go to your branch: feature/DelegatorsAndStdFunction_1337x2

git checkout  feature/DelegatorsAndStdFunction_1337x2

Then make sure that you have commited your changes and finally do

git push

So that those changes show up also in the PR.
Thanks in advance.

@frankdownunder
Copy link
Contributor Author

frankdownunder commented May 15, 2018 via email

@slaff slaff merged commit e71d02c into SmingHub:develop May 15, 2018
@slaff slaff removed the 3 - Review label May 15, 2018
@slaff slaff mentioned this pull request May 15, 2018
24 tasks
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

Successfully merging this pull request may close these issues.

2 participants