Skip to content

Commit

Permalink
Merge branch 'master' of ../Arduino-Helpers into new-input
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Jun 24, 2021
2 parents ecc3caa + f6c9239 commit f6b6ec5
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion examples/Arduino-Helpers/Hardware/2.Button/2.Button.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <AH/Hardware/Button.hpp>

// Create a Button object that reads a push button connected to pin 2:
Button pushbutton = {2};
Button pushbutton {2};

// The pin with the LED connected:
const pin_t ledPin = LED_BUILTIN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const unsigned long minInterval = 100; // ms
const unsigned long defaultInterval = 500; // ms
const int intervalDelta = 100; // ms

IncrementDecrementButtons buttons = {2, 3};
IncrementDecrementButtons buttons {2, 3};
Timer<millis> timer = defaultInterval;

void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
#include <AH/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp>

// Instantiate a multiplexer
CD74HC4067 mux = {
CD74HC4067 mux {
A0, // analog pin
{3, 4, 5, 6}, // Address pins S0, S1, S2, S3
// 7, // Optionally, specify the enable pin
};

// Alternatively, if you have a 3-bit mux:
// CD74HC4051 mux = {
// CD74HC4051 mux {
// A0,
// {3, 4, 5},
// // 7, // Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
#include <AH/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp>

// Instantiate a multiplexer
CD74HC4067 mux = {
CD74HC4067 mux {
2, // input pin
{3, 4, 5, 6}, // Address pins S0, S1, S2, S3
// 7, // Optionally, specify the enable pin
};

// Alternatively, if you have a 3-bit mux:
// CD74HC4051 mux = {
// CD74HC4051 mux {
// 2,
// {3, 4, 5},
// // 7, // Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
#include <AH/Containers/ArrayHelpers.hpp> // copyAs<>

// Instantiate a multiplexer
CD74HC4067 mux = {
CD74HC4067 mux {
A0, // analog pin
{3, 4, 5, 6}, // Address pins S0, S1, S2, S3
// 7, // Optionally, specify the enable pin
};

// Alternatively, if you have a 3-bit mux:
// CD74HC4051 mux = {
// CD74HC4051 mux {
// A0,
// {3, 4, 5},
// // 7, // Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace ExtIO; // Bring the ExtIO pin functions into your sketch

// Instantiate a shift register with the SPI slave select pin as latch pin, most
// significant bit first, and a total of 8 outputs.
SPIShiftRegisterOut<8> sreg = {SPI, SS, MSBFIRST};
SPIShiftRegisterOut<8> sreg {SPI, SS, MSBFIRST};

const pin_t ledPin = sreg.pin(0); // first pin of the shift register

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const pin_t clockPin = 13; // Pin connected to SH_CP of 74HC595

// Instantiate a shift register on the correct pins, most significant bit first,
// and a total of 8 outputs.
ShiftRegisterOut<8> sreg = {dataPin, clockPin, latchPin, MSBFIRST};
ShiftRegisterOut<8> sreg {dataPin, clockPin, latchPin, MSBFIRST};

const pin_t ledPin = sreg.pin(0); // first pin of the shift register

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const uint8_t ShiftRegisterOutRGB::blueBit = 2;
// Create a new shift register output connected to pins 11, 13 and 10,
// shift the data out with the most significant bit first.
// There are 24 (= 3×8) outputs in total.
SPIShiftRegisterOut<24> sreg = {SPI, SS, MSBFIRST};
SPIShiftRegisterOut<24> sreg {SPI, SS, MSBFIRST};

void setup() {
// Initialize the shift registers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace ExtIO; // Bring the ExtIO pin functions into your sketch
// Instantiate a MAX7219 with the SPI slave select pin as latch pin
// There's just 1 MAX7219 in the chain, if you have more of them daisy-chained
// together, you can increase the template argument (between angled brackets)
MAX7219<1> max7219 = {SPI, SS};
MAX7219<1> max7219 {SPI, SS};

const pin_t ledPin1 = max7219.pin(0); // first LED of the MAX7219
const pin_t ledPin2 = max7219.pin(63); // last LED of the MAX7219
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@
#include <AH/Hardware/ExtendedInputOutput/SPIShiftRegisterOut.hpp>

// Instantiate a multiplexer
CD74HC4067 mux = {
CD74HC4067 mux {
2, // input pin
{3, 4, 5, 6}, // Address pins S0, S1, S2, S3
// 7, // Optionally, specify the enable pin
};

// Alternatively, if you have a 3-bit mux:
// CD74HC4051 mux = {
// CD74HC4051 mux {
// 2,
// {3, 4, 5},
// // 7, // Optional
// };

// Instantiate a shift register with the SPI slave select pin as latch pin, most
// significant bit first, and a total of 16 outputs.
SPIShiftRegisterOut<mux.length()> sreg = {SPI, SS, MSBFIRST};
SPIShiftRegisterOut<mux.length()> sreg {SPI, SS, MSBFIRST};

// Instantiate an array of momentary push buttons.
// It generates an array of Buttons on pins:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ using MCPEncoderType = MCP23017Encoders<WireType, EncoderPositionType, IntSafe>;

const uint8_t interrupt_pin = 12;

MCPEncoderType enc = {Wire, 0x0, interrupt_pin};
// │ │ └─ Interrupt pin
// │ └────── Address offset
// └──────────── I²C interface
MCPEncoderType enc {Wire, 0x0, interrupt_pin};
// │ │ └─ Interrupt pin
// │ └────── Address offset
// └──────────── I²C interface

void isr() {
enc.update(); // Read the state of the encoders and update the positions
Expand All @@ -84,7 +84,7 @@ void loop() {
// No `enc.update()` here, everything happens inside of the ISR

// Save the previous positions
static EncoderPositionType prevPositions[8] = {};
static EncoderPositionType prevPositions[8] {};
// Check if an encoder position changed and print it
for (uint8_t i = 0; i < 8; ++i) {
auto newPosition = enc.read(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ using WireType = decltype(Wire); // The type of I²C driver to use
using EncoderPositionType = int32_t; // The type for saving encoder positions
using MCPEncoderType = MCP23017Encoders<WireType, EncoderPositionType>;

MCPEncoderType enc = {Wire, 0x0, 12};
// │ │ └─ Interrupt pin
// │ └────── Address offset
// └──────────── I²C interface
MCPEncoderType enc {Wire, 0x0, 12};
// │ │ └─ Interrupt pin
// │ └────── Address offset
// └──────────── I²C interface

void setup() {
Serial.begin(115200);
Expand All @@ -72,9 +72,9 @@ void setup() {

void loop() {
enc.update(); // Read the state of the encoders and update the positions

// Save the previous positions
static EncoderPositionType prevPositions[8] = {};
static EncoderPositionType prevPositions[8] {};
// Check if an encoder position changed and print it
for (uint8_t i = 0; i < 8; ++i) {
if (enc.read(i) != prevPositions[i]) {
Expand Down
4 changes: 2 additions & 2 deletions examples/Arduino-Helpers/Math/Quaternion/Quaternion.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ bool close(float actual, float expected, float atol) {
void setup() {
Serial.begin(115200);

Vec3f vector = {-0.414578098794425, 0.829156197588850, 0.375000000000000};
Vec3f vector {-0.414578098794425, 0.829156197588850, 0.375000000000000};
Quaternion result = Quaternion::fromDirection(vector);
Quaternion expected = {0.829156197588850, -0.5, -0.25, 0.0};
Quaternion expected {0.829156197588850, -0.5, -0.25, 0.0};
float atol = 1e-7;

Serial << setprecision(7) << "Result = " << result << endl;
Expand Down
2 changes: 1 addition & 1 deletion examples/Arduino-Helpers/STL/ArraySort/ArraySort.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void setup() {
while (!Serial)
;

Array<int, 10> array = {3, 5, 9, 2, 1, 8, 6, 4, 7, 0};
Array<int, 10> array {3, 5, 9, 2, 1, 8, 6, 4, 7, 0};

Serial << "Before sorting: " << array << endl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <AH/STL/numeric> // std::accumulate

// An array of debounced buttons connected to the given pins
Button buttons[] = {
Button buttons[] {
2, 3, 4, 5, 6, 7, 8, 9,
};

Expand Down
2 changes: 1 addition & 1 deletion examples/test/STL-test/STL-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void setup() {
TEST_CMATH_FUNCTION2(std::hypot);
TEST_CMATH_FUNCTION3(std::fma);

std::vector<int> vec = {1, 2, 3, 4};
std::vector<int> vec {1, 2, 3, 4};
vec.reserve(100);
vec.resize(50);
vec[1] = -2;
Expand Down

0 comments on commit f6b6ec5

Please sign in to comment.