Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 6b17229

Browse files
authored
v1.1.0 to convert to h-only style, etc.
### Releases v1.1.0 1. Convert to `h-only` style 2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project 3. Fix `setPulseWidth()` bug. Check [setPulseWidth - removed wrong map #2](#2) 4. Optimize code by using passing by `reference` instead of by `value`
1 parent 39e1604 commit 6b17229

File tree

10 files changed

+783
-381
lines changed

10 files changed

+783
-381
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1414

1515
Please ensure to specify the following:
1616

17-
* Arduino IDE version (e.g. 1.8.16) or Platform.io version
18-
* `Arduino mbed_rp2040` Core Version (e.g. Arduino mbed_rp2040 core v2.5.2) or `RP2040` Core Version (e.g. RP2040 core v1.9.5)
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* `Arduino mbed_rp2040` Core Version (e.g. Arduino mbed_rp2040 core v2.7.2) or `RP2040` Core Version (e.g. RP2040 core v1.12.0)
1919
* `RP2040` Board type (e.g. Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc.)
2020
* Contextual information (e.g. what you were trying to achieve)
2121
* Simplest possible steps to reproduce
@@ -27,11 +27,11 @@ Please ensure to specify the following:
2727
### Example
2828

2929
```
30-
Arduino IDE version: 1.8.16
31-
Arduino mbed_rp2040 core v2.5.2
30+
Arduino IDE version: 1.8.19
31+
Arduino mbed_rp2040 core v2.7.2
3232
RASPBERRY_PI_PICO board
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3535
3636
Context:
3737
I encountered a crash while trying to use the Timer Interrupt.
@@ -52,3 +52,4 @@ There are usually some outstanding feature requests in the [existing issues list
5252
### Sending Pull Requests
5353

5454
Pull Requests with changes and fixes are also welcome!
55+

README.md

Lines changed: 55 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
## Table of Contents
1515

16+
* [Important Change from v1.1.0](#Important-Change-from-v110)
1617
* [Why do we need this RP2040_ISR_Servo library](#why-do-we-need-this-rp2040_isr_servo-library)
1718
* [Features](#features)
1819
* [Important Notes about using ISR](#important-notes-about-using-isr)
@@ -23,11 +24,13 @@
2324
* [Use Arduino Library Manager](#use-arduino-library-manager)
2425
* [Manual Install](#manual-install)
2526
* [VS Code & PlatformIO](#vs-code--platformio)
27+
* [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
2628
* [What special in this RP2040_ISR_Servo library](#what-special-in-this-RP2040_ISR_Servo-library)
2729
* [HOWTO Usage](#howto-usage)
2830
* [Examples](#examples)
2931
* [ 1. RP2040_MultipleRandomServos](examples/RP2040_MultipleRandomServos)
3032
* [ 2. RP2040_MultipleServos](examples/RP2040_MultipleServos)
33+
* [ 3. multiFileProject](examples/multiFileProject) **New**
3134
* [Example RP2040_MultipleServos](#example-rp2040_multipleservos)
3235
* [1. File RP2040_MultipleServos.ino](#1-file-rp2040_multipleservosino)
3336
* [Debug Terminal Output Samples](#debug-terminal-output-samples)
@@ -45,6 +48,14 @@
4548
* [Copyright](#copyright)
4649

4750

51+
---
52+
---
53+
54+
### Important Change from v1.1.0
55+
56+
Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
57+
58+
4859
---
4960
---
5061

@@ -92,7 +103,7 @@ This library enables you to use `1 Hardware Timer` on an RP2040-based board to c
92103

93104
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
94105
2. [`Arduino mbed_rp2040 core 2.7.2+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) RP2040-based boards, such as **Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest)
95-
3. [`Earle Philhower's arduino-pico core v1.10.0+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest)
106+
3. [`Earle Philhower's arduino-pico core v1.12.0+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest)
96107

97108
---
98109

@@ -116,9 +127,35 @@ Another way to install is to:
116127

117128
1. Install [VS Code](https://code.visualstudio.com/)
118129
2. Install [PlatformIO](https://platformio.org/platformio-ide)
119-
3. Install [**RP2040_ISR_Servo** library](https://platformio.org/lib/show/12713/RP2040_ISR_Servo) by using [Library Manager](https://platformio.org/lib/show/12713/RP2040_ISR_Servo/installation). Search for **RP2040_ISR_Servo** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22)
130+
3. Install [**RP2040_ISR_Servo** library](https://registry.platformio.org/libraries/khoih-prog/RP2040_ISR_Servo) by using [Library Manager](https://registry.platformio.org/libraries/khoih-prog/RP2040_ISR_Servo/installation). Search for **RP2040_ISR_Servo** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22)
120131
4. Please visit documentation for the other options and examples at [Project Configuration File](https://docs.platformio.org/page/projectconf.html)
121132

133+
---
134+
---
135+
136+
### HOWTO Fix `Multiple Definitions` Linker Error
137+
138+
The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases.
139+
140+
You can include this `.hpp` file
141+
142+
```
143+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
144+
#include "RP2040_ISR_Servo.hpp" //https://github.com/khoih-prog/RP2040_ISR_Servo
145+
```
146+
147+
in many files. But be sure to use the following `.h` file **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error
148+
149+
```
150+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
151+
#include "RP2040_ISR_Servo.h" //https://github.com/khoih-prog/RP2040_ISR_Servo
152+
```
153+
154+
Check the new [**multiFileProject** example](examples/multiFileProject) for a `HOWTO` demo.
155+
156+
Have a look at the discussion in [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80)
157+
158+
122159
---
123160
---
124161

@@ -304,7 +341,8 @@ void loop()
304341
### Examples:
305342

306343
1. [RP2040_MultipleRandomServos](examples/RP2040_MultipleRandomServos)
307-
2. [RP2040_MultipleServos](examples/RP2040_MultipleServos)
344+
2. [RP2040_MultipleServos](examples/RP2040_MultipleServos)
345+
3. [multiFileProject](examples/multiFileProject) **New**
308346

309347
---
310348

@@ -313,113 +351,8 @@ void loop()
313351

314352
#### 1. File [RP2040_MultipleServos.ino](examples/RP2040_MultipleServos/RP2040_MultipleServos.ino)
315353

316-
```cpp
317-
#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || \
318-
defined(ARDUINO_GENERIC_RP2040) ) && !defined(ARDUINO_ARCH_MBED)
319-
#if !defined(RP2040_ISR_SERVO_USING_MBED)
320-
#define RP2040_ISR_SERVO_USING_MBED false
321-
#endif
322-
323-
#elif ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || \
324-
defined(ARDUINO_GENERIC_RP2040) ) && defined(ARDUINO_ARCH_MBED)
325-
326-
#if !defined(RP2040_ISR_SERVO_USING_MBED)
327-
#define RP2040_ISR_SERVO_USING_MBED true
328-
#endif
329-
330-
#else
331-
#error This code is intended to run on the mbed / non-mbed RP2040 platform! Please check your Tools->Board setting.
332-
#endif
333-
334-
#define TIMER_INTERRUPT_DEBUG 4
335-
#define ISR_SERVO_DEBUG 4
336-
337-
#include "RP2040_ISR_Servo.h"
338-
339-
// Published values for SG90 servos; adjust if needed
340-
#define MIN_MICROS 800
341-
#define MAX_MICROS 2450
342-
343-
#define SERVO_PIN_1 16
344-
#define SERVO_PIN_2 17
345-
#define SERVO_PIN_3 18
346-
#define SERVO_PIN_4 19
347-
#define SERVO_PIN_5 20
348-
#define SERVO_PIN_6 21
349-
350-
typedef struct
351-
{
352-
int servoIndex;
353-
uint8_t servoPin;
354-
} ISR_servo_t;
355-
354+
https://github.com/khoih-prog/RP2040_ISR_Servo/blob/39e160439b9b4e7c5238202379bd042121784f65/examples/RP2040_MultipleServos/RP2040_MultipleServos.ino#L45-L149
356355

357-
#define NUM_SERVOS 6
358-
359-
ISR_servo_t ISR_servo[NUM_SERVOS] =
360-
{
361-
{ -1, SERVO_PIN_1 }, { -1, SERVO_PIN_2 }, { -1, SERVO_PIN_3 }, { -1, SERVO_PIN_4 }, { -1, SERVO_PIN_5 }, { -1, SERVO_PIN_6 }
362-
};
363-
364-
void setup()
365-
{
366-
for (int index = 0; index < NUM_SERVOS; index++)
367-
{
368-
pinMode(ISR_servo[index].servoPin, OUTPUT);
369-
digitalWrite(ISR_servo[index].servoPin, LOW);
370-
}
371-
372-
Serial.begin(115200);
373-
while (!Serial);
374-
375-
delay(200);
376-
377-
#if defined(ARDUINO_ARCH_MBED)
378-
Serial.print(F("\nStarting RP2040_MultipleServos on Mbed "));
379-
#else
380-
Serial.print(F("\nStarting RP2040_MultipleServos on "));
381-
#endif
382-
383-
Serial.println(BOARD_NAME);
384-
Serial.println(RP2040_ISR_SERVO_VERSION);
385-
386-
for (int index = 0; index < NUM_SERVOS; index++)
387-
{
388-
ISR_servo[index].servoIndex = RP2040_ISR_Servos.setupServo(ISR_servo[index].servoPin, MIN_MICROS, MAX_MICROS);
389-
390-
if (ISR_servo[index].servoIndex != -1)
391-
{
392-
Serial.print(F("Setup OK Servo index = ")); Serial.println(ISR_servo[index].servoIndex);
393-
394-
RP2040_ISR_Servos.setPosition(ISR_servo[index].servoIndex, 0);
395-
}
396-
else
397-
{
398-
Serial.print(F("Setup Failed Servo index = ")); Serial.println(ISR_servo[index].servoIndex);
399-
}
400-
}
401-
}
402-
403-
void loop()
404-
{
405-
int position; // position in degrees
406-
407-
for (position = 0; position <= 180; position += 10)
408-
{
409-
// goes from 0 degrees to 180 degrees
410-
// in steps of 10 degree
411-
for (int index = 0; index < NUM_SERVOS; index++)
412-
{
413-
RP2040_ISR_Servos.setPosition(ISR_servo[index].servoIndex, position);
414-
}
415-
416-
// waits 1s for the servo to reach the position
417-
delay(1000);
418-
}
419-
420-
delay(5000);
421-
}
422-
```
423356
---
424357
---
425358

@@ -430,7 +363,7 @@ void loop()
430363

431364
```
432365
Starting RP2040_MultipleRandomServos on Mbed RaspberryPi Pico
433-
Mbed RP2040_ISR_Servo v1.0.1
366+
Mbed RP2040_ISR_Servo v1.1.0
434367
Setup OK Servo index = 0
435368
Setup OK Servo index = 1
436369
Setup OK Servo index = 2
@@ -474,7 +407,7 @@ Servos idx = 5, act. pos. (deg) = 800, pulseWidth (us) = 800
474407

475408
```
476409
Starting RP2040_MultipleRandomServos on RaspberryPi Pico
477-
RP2040_ISR_Servo v1.0.1
410+
RP2040_ISR_Servo v1.1.0
478411
Setup OK Servo index = 0
479412
Setup OK Servo index = 1
480413
Setup OK Servo index = 2
@@ -519,7 +452,7 @@ Servos idx = 5, act. pos. (deg) = 800, pulseWidth (us) = 800
519452
```
520453
521454
Starting RP2040_MultipleServos on RASPBERRY_PI_PICO
522-
RP2040_ISR_Servo v1.0.1
455+
RP2040_ISR_Servo v1.1.0
523456
Setup OK Servo index = 0
524457
Setup OK Servo index = 1
525458
Setup OK Servo index = 2
@@ -573,6 +506,9 @@ Submit issues to: [RP2040_ISR_Servo issues](https://github.com/khoih-prog/RP2040
573506
2. Add functions `getPosition()` and `getPulseWidth()`
574507
3. Optimize the code
575508
4. Add complicated examples
509+
5. Convert to `h-only` style
510+
6. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project
511+
7. Optimize code by using passing by `reference` instead of by `value
576512

577513
---
578514
---
@@ -581,6 +517,13 @@ Submit issues to: [RP2040_ISR_Servo issues](https://github.com/khoih-prog/RP2040
581517

582518
Many thanks for everyone for bug reporting, new feature suggesting, testing and contributing to the development of this library. Especially to these people who have directly or indirectly contributed to this [RP2040_ISR_Servo library](https://github.com/khoih-prog/RP2040_ISR_Servo)
583519

520+
1. Thanks to [Radek Voltr](https://github.com/RadekVoltr) for the PR [**setPulseWidth - removed wrong map** #2](https://github.com/khoih-prog/RP2040_ISR_Servo/pull/2), leading to new version v1.1.0
521+
522+
<table>
523+
<tr>
524+
<td align="center"><a href="https://github.com/RadekVoltr"><img src="https://github.com/RadekVoltr.png" width="100px;" alt="RadekVoltr"/><br /><sub><b>Radek Voltr</b></sub></a><br /></td>
525+
</tr>
526+
</table>
584527

585528
---
586529

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.1.0](#releases-v110)
1516
* [Releases v1.0.1](#releases-v101)
1617
* [Releases v1.0.0](#releases-v100)
1718

@@ -20,6 +21,13 @@
2021

2122
## Changelog
2223

24+
### Releases v1.1.0
25+
26+
1. Convert to `h-only` style
27+
2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project
28+
3. Fix `setPulseWidth()` bug. Check [setPulseWidth - removed wrong map #2](https://github.com/khoih-prog/RP2040_ISR_Servo/pull/2)
29+
4. Optimize code by using passing by `reference` instead of by `value`
30+
2331
### Releases v1.0.1
2432

2533
1. Fix platform in `library.json`

keywords.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ getNumAvailableServos KEYWORD2
3636
#######################################
3737
# Literals (LITERAL1)
3838
#######################################
39+
40+
RP2040_ISR_SERVO_VERSION LITERAL1
41+
RP2040_ISR_SERVO_VERSION_MAJOR LITERAL1
42+
RP2040_ISR_SERVO_VERSION_MINOR LITERAL1
43+
RP2040_ISR_SERVO_VERSION_PATCH LITERAL1
44+
RP2040_ISR_SERVO_VERSION_INT LITERAL1

library.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "RP2040_ISR_Servo",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"keywords": "timing, device, control, timer, interrupt, isr, isr-based, hardware-timer, mission-critical, accuracy, precise, non-blocking, mbed, rpi-pico, rp2040, nano-rp2040-connect, servo",
55
"description": "This library enables you to use 1 Hardware Timer on RP2040-based board, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, to control up to 16 or more servo motors.",
66
"authors":
@@ -21,9 +21,10 @@
2121
"extras",
2222
"tests"
2323
]
24-
},
24+
},
25+
"license": "MIT",
2526
"frameworks": "*",
2627
"platforms": ["raspberrypi"],
2728
"examples": "examples/*/*/*.ino",
28-
"license": "MIT"
29+
"headers": ["RP2040_ISR_Servo.h","RP2040_ISR_Servo.hpp"]
2930
}

library.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name=RP2040_ISR_Servo
2-
version=1.0.1
2+
version=1.1.0
33
author=Khoi Hoang
44
maintainer=Khoi Hoang <khoih.prog@gmail.com>
55
license=MIT
66
sentence=This library enables you to use Interrupt from Hardware Timers on RP2040 board to control multiple servo motors.
77
paragraph=This library enables you to use 1 Hardware Timer on RP2040-based board, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, to control up to 16 or more servo motors.
88
category=Device Control
99
url=https://github.com/khoih-prog/RP2040_ISR_Servo
10-
architectures=mbed_rp2040, rp2040
11-
includes=RP2040_ISR_Servo.h
10+
architectures=mbed_rp2040, mbed_nano, rp2040
11+
includes=RP2040_ISR_Servo.h, RP2040_ISR_Servo.hpp

0 commit comments

Comments
 (0)