Skip to content

Commit

Permalink
Some typos fixed, deal with .gitatributes and line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
jbanaszczyk committed May 3, 2018
1 parent 923ddec commit 33a2016
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 45 deletions.
51 changes: 39 additions & 12 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
*.c text eol=lf
*.cpp text eol=lf
*.h text eol=lf
*.ino text eol=lf
*.md text eol=lf

###############################################################################
# Set the merge driver for project and solution files
Expand All @@ -22,18 +27,23 @@
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
*.sln text eol=crlf
*.csproj text eol=crlf
*.vbproj text eol=crlf
*.vcxproj text eol=crlf
*.vcproj text eol=crlf
*.dbproj text eol=crlf
*.fsproj text eol=crlf
*.lsproj text eol=crlf
*.wixproj text eol=crlf
*.modelproj text eol=crlf
*.sqlproj text eol=crlf
*.wmaproj text eol=crlf

*.xproj text eol=crlf
*.props text eol=crlf
*.filters text eol=crlf
*.vcxitems text eol=crlf

###############################################################################
# behavior for image files
Expand Down Expand Up @@ -61,3 +71,20 @@
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain


###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just comment the entries below and
# uncomment the group further below
###############################################################################
4 changes: 2 additions & 2 deletions Examples/p01basic/p01basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pmsx::Pms pms(&pmsSerial);
////////////////////////////////////////

// * PMS5003 Pin 1 (black) : VCC +5V
// * PMS5003 Pin 2 (brown) : GND
// * PMS5003 Pin 2 (brown) : GND
// Important: pms5003 uses 3.3V logic.Use converters if required or make sure your Arduino board uses 3.3V logic too.
// * PMS5003 Pin 4 (blue) : Digital pin 9 (there is no choice, forced by AltSerial)
// * PMS5003 Pin 5 (green) : Digital pin 8 (there is no choice, forced by AltSerial)
Expand All @@ -25,7 +25,7 @@ void setup(void) {
if (!pms.begin()) {
Serial.println("PMS sensor: communication failed");
return;
}
}

pms.setPinReset(6);
pms.setPinSleepMode(7);
Expand Down
4 changes: 2 additions & 2 deletions Examples/p02cStyle/p02cStyle.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pmsx::Pms pms(&pmsSerial);
////////////////////////////////////////

// * PMS5003 Pin 1 (black) : VCC +5V
// * PMS5003 Pin 2 (brown) : GND
// * PMS5003 Pin 2 (brown) : GND
// Important: pms5003 uses 3.3V logic.Use converters if required or make sure your Arduino board uses 3.3V logic too.
// * PMS5003 Pin 4 (blue) : Digital pin 9 (there is no choice, forced by AltSerial)
// * PMS5003 Pin 5 (green) : Digital pin 8 (there is no choice, forced by AltSerial)
Expand All @@ -25,7 +25,7 @@ void setup(void) {
if (!pms.begin()) {
Serial.println("PMS sensor: communication failed");
return;
}
}

pms.setPinReset(6);
pms.setPinSleepMode(7);
Expand Down
2 changes: 1 addition & 1 deletion Examples/p03cppStyle/p03cppStyle.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pmsx::Pms pms(&pmsSerial);
#endif

// * PMS5003 Pin 1 (black) : VCC +5V
// * PMS5003 Pin 2 (brown) : GND
// * PMS5003 Pin 2 (brown) : GND
// Important: pms5003 uses 3.3V logic.Use converters if required or make sure your Arduino board uses 3.3V logic too.
// * PMS5003 Pin 4 (blue) : Digital pin 9 (there is no choice, forced by AltSerial)
// * PMS5003 Pin 5 (green) : Digital pin 8 (there is no choice, forced by AltSerial)
Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void setup(void) {
if (!pms.begin()) {
Serial.println("PMS sensor: communication failed");
return;
}
}

pms.setPinReset(6);
pms.setPinSleepMode(7);
Expand Down Expand Up @@ -257,7 +257,7 @@ The next step is to define Arduino pins connected to pms5003:
* SET (pms5003 pin 3, white) (sleep/wakeup)
* RESET (pms5003 pin 6, violet) (sensor reset)

This step is optional.
This step is optional.
* If SET pin is not connected - sleep/wakeup commands are executed using serial connection
* If RESET pin is not connected - sleep and then wakeup works like reset

Expand All @@ -268,7 +268,7 @@ If pins are not connected - just remove appropriate `setPinReset`/`setPinSleepMo
pms.setPinSleepMode(7);
```

The next task is to put sensor in a well known state.
The next task is to put sensor in a well known state.
There are two aspects of PMS5003 state:
* sleep/waken up
* passive/active
Expand All @@ -287,9 +287,9 @@ Well known state (woken up and active) can be achieved after sensor reset or sle
```
The next task is to make sure, that Arduino can communicate with PMS5003. To accomplish the task we are:
* forcing passive mode (PMS5003 sends data if asked),
* ask for data,
* wait for the response
* forcing passive mode (PMS5003 sends data if asked),
* ask for data,
* wait for the response
* and check the response
```C++
Expand All @@ -315,7 +315,7 @@ Finally we put PMS5003 in active mode - it sends data periodically and automatic

### loop()

First of all: __pms5003 does not block on data read__
First of all: __pms5003 does not block on data read__

Try to read the data :

Expand Down Expand Up @@ -357,8 +357,8 @@ Lets go back to the situation where there is something interesting:
#### views
Data received form PMS5003 (see [Appendix I](https://github.com/jbanaszczyk/pms5003/blob/master/doc/pms5003-manual_v2-3.pdf)) may be worth attention:
* as a whole (13 numbers)
Data received from PMS5003 (see [Appendix I](https://github.com/jbanaszczyk/pms5003/blob/master/doc/pms5003-manual_v2-3.pdf)) may be worth attention:
* as a whole (12 numbers)
* in groups:
* (3 numbers) PM 1.0/2.5/10.0 concentration unit µ g/m3 (CF=1,standard particle) (_really? I have no idea what does it mean_)
* (3 numbers) PM 1.0/2.5/10.0 concentration unit µ g/m3 (under atmospheric environment) (_looks good_)
Expand Down Expand Up @@ -390,7 +390,7 @@ or
```

Each "view" provides similar interface:
* use `getSize()` to get counter of data in a view:
* use `getSize()` to get counter of data in a view:
* `for (auto i = 0; i < view.getSize(); ++i)`
* use `.getValue()` to get particular data from index
* `Serial.print(view.getValue(i));`
Expand Down Expand Up @@ -446,7 +446,7 @@ If you prefer C style: constants and arrays instead of method calls - please not
}
```
* use `SIZE` to get counter of data in a view:
* use `SIZE` to get counter of data in a view:
* `for (auto i = 0; i < view.SIZE; ++i)`
* use array index `[]` to get particular data
* `Serial.print(view[i]);`
Expand Down Expand Up @@ -776,7 +776,7 @@ _Shown in_: [Basic scenario](#Hello)
private: static const auto TIMEOUT_ACK = 30U;
```

Used internally (inside write()). Defines timeout for response read after write command.
Used internally (inside write()). Defines timeout for response read after write command.

write() can block up to TIMEOUT_ACK.

Expand All @@ -786,13 +786,13 @@ write() can block up to TIMEOUT_ACK.
static const auto WAKEUP_TIME = 2500U;
```

WAKEUP_TIME defines time after power on, reset or write(CMD_WAKEUP) when the sensor is blind for any commands.
WAKEUP_TIME defines time after power on, reset or write(CMD_WAKEUP) when the sensor is blind for any commands.

_Shown in_: [Basic scenario](#Hello)

## Commands and states<a name="commands"></a>

PMS5003 accepts a few commands. They are not fully documented.
PMS5003 accepts a few commands. They are not fully documented.

You can send commands to the PMS5003 sensor using [write()](#API_write).

Expand All @@ -810,4 +810,3 @@ You can send commands to the PMS5003 sensor using [write()](#API_write).

# Configuration <a name="Cfg_PMS_DYNAMIC"></a>


4 changes: 2 additions & 2 deletions src/pms.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Pin 2: GND

// Using AltSoftSerial:
// Pin 4: Digital pin 9 (there is no choice)
// Pin 4: Digital pin 9 (there is no choice)
// Pin 5: Digital pin 8 (there is no choice)
// in file pmsConfig.h: Enable #define PMS_ALTSOFTSERIAL
// Install DrDiettrich' fork of AltSoftSerial Library: https://github.com/DrDiettrich/AltSoftSerial.git
Expand Down Expand Up @@ -436,7 +436,7 @@ namespace pmsx {
*sum += (data & 0xFF) + (data >> 8);
}

////////////////////////////////////////
////////////////////////////////////////

public:
void setTimeout(decltype(timeout) timeout) {
Expand Down
12 changes: 6 additions & 6 deletions src/pmsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

////////////////////////////////////////////

// Use one of:
// Use one of:
// it depends on Serial Library (and serial pin connection)

#define PMS_ALTSOFTSERIAL
Expand All @@ -14,20 +14,20 @@
////////////////////////////////////////////

// Use PMS_DYNAMIC to be C++ strict
// Without PMS_DYNAMIC:
// Without PMS_DYNAMIC:
// con: PMS5003 related object should be defined as global variable (C style): Pms pms;
// con: It can not be initialized inside constructor. It is too early, serial ports and other pins will be redefined by Arduino bootloader
// con: It has to be initialzed within setup() - see examples: uses of begin()
// con: It has to be initialized within setup() - see examples: uses of begin()
// With PMS_DYNAMIC:
// pro: PMS5003 related object instance should be created (C++ style) using _pms = new Pms();
// pro: It can be created within setup(), it is good time to initialze class instance in the constructor. Arduino board was initialzed here.
// con: If you are not using heap: it uses heap, it adds meaningful code overhead - malloc, new() and memory mangement should be included. ( 0.5kb of program memory, a few memory bytes)
// pro: It can be created within setup(), it is good time to initialize class instance in the constructor. Arduino board was initialized here.
// con: If you are not using heap: it uses heap, it adds meaningful code overhead - malloc, new() and memory management should be included. ( 0.5kb of program memory, a few memory bytes)

// #define PMS_DYNAMIC

////////////////////////////////////////////

// Undef to use modern min() template function instead of min() macro. I hate unnecessary macros.
// Undefine to use modern min() template function instead of min() macro. I hate unnecessary macros.
// Works with Visual Studio, compiler errors with Arduino IDE.

#define NOMINMAX
Expand Down
2 changes: 1 addition & 1 deletion src/pmsSerialAltSoftSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PmsAltSerial : public IPmsSerial {
void setTimeout(const unsigned long timeout) override {
serial.setTimeout(timeout);
}

size_t available() override {
return serial.available();
}
Expand Down
5 changes: 1 addition & 4 deletions src/tribool.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef _tribool_h_
#define _tribool_h_
#pragma once

#include <Arduino.h>

Expand Down Expand Up @@ -85,5 +84,3 @@ constexpr inline tribool operator!=(unknown_keyword_t, tribool lhs) { return tri
constexpr inline tribool operator!=(tribool lhs, unknown_keyword_t) { return lhs != tribool(unknown); }

constexpr inline bool unknown(tribool arg, unknown_t dummy) { return false; };

#endif

0 comments on commit 33a2016

Please sign in to comment.