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

Commit 39e1604

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 7495a44 commit 39e1604

File tree

5 files changed

+98
-16
lines changed

5 files changed

+98
-16
lines changed

examples/RP2040_MultipleRandomServos/RP2040_MultipleRandomServos.ino

+1-8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
99
Built by Khoi Hoang https://github.com/khoih-prog/RP2040_ISR_Servo
1010
Licensed under MIT license
11-
12-
Based on SimpleTimer - A timer library for Arduino.
13-
Author: mromani@ottotecnica.com
14-
Copyright (c) 2010 OTTOTECNICA Italy
15-
16-
Based on BlynkTimer.h
17-
Author: Volodymyr Shymanskyy
1811
*****************************************************************************************************************************/
1912

2013
/****************************************************************************************************************************
@@ -66,9 +59,9 @@
6659
#error This code is intended to run on the mbed / non-mbed RP2040 platform! Please check your Tools->Board setting.
6760
#endif
6861

69-
#define TIMER_INTERRUPT_DEBUG 4
7062
#define ISR_SERVO_DEBUG 4
7163

64+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
7265
#include "RP2040_ISR_Servo.h"
7366

7467
// Published values for SG90 servos; adjust if needed

examples/RP2040_MultipleServos/RP2040_MultipleServos.ino

+1-8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
99
Built by Khoi Hoang https://github.com/khoih-prog/RP2040_ISR_Servo
1010
Licensed under MIT license
11-
12-
Based on SimpleTimer - A timer library for Arduino.
13-
Author: mromani@ottotecnica.com
14-
Copyright (c) 2010 OTTOTECNICA Italy
15-
16-
Based on BlynkTimer.h
17-
Author: Volodymyr Shymanskyy
1811
*****************************************************************************************************************************/
1912

2013
/****************************************************************************************************************************
@@ -66,9 +59,9 @@
6659
#error This code is intended to run on the mbed / non-mbed RP2040 platform! Please check your Tools->Board setting.
6760
#endif
6861

69-
#define TIMER_INTERRUPT_DEBUG 4
7062
#define ISR_SERVO_DEBUG 4
7163

64+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
7265
#include "RP2040_ISR_Servo.h"
7366

7467
// Published values for SG90 servos; adjust if needed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/****************************************************************************************************************************
2+
multiFileProject.cpp
3+
RP2040_MultipleServos.ino
4+
For :
5+
- MBED RP2040-based boards such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
6+
- RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040 using arduino_pico core
7+
8+
Written by Khoi Hoang
9+
10+
Built by Khoi Hoang https://github.com/khoih-prog/RP2040_ISR_Servo
11+
Licensed under MIT license
12+
*****************************************************************************************************************************/
13+
14+
// To demo how to include files in multi-file Projects
15+
16+
#include "multiFileProject.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/****************************************************************************************************************************
2+
multiFileProject.h
3+
RP2040_MultipleServos.ino
4+
For :
5+
- MBED RP2040-based boards such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
6+
- RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040 using arduino_pico core
7+
8+
Written by Khoi Hoang
9+
10+
Built by Khoi Hoang https://github.com/khoih-prog/RP2040_ISR_Servo
11+
Licensed under MIT license
12+
*****************************************************************************************************************************/
13+
14+
// To demo how to include files in multi-file Projects
15+
16+
#pragma once
17+
18+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
19+
#include "RP2040_ISR_Servo.hpp"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/****************************************************************************************************************************
2+
multiFileProject.ino
3+
RP2040_MultipleServos.ino
4+
For :
5+
- MBED RP2040-based boards such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
6+
- RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040 using arduino_pico core
7+
8+
Written by Khoi Hoang
9+
10+
Built by Khoi Hoang https://github.com/khoih-prog/RP2040_ISR_Servo
11+
Licensed under MIT license
12+
*****************************************************************************************************************************/
13+
14+
// To demo how to include files in multi-file Projects
15+
16+
#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || \
17+
defined(ARDUINO_GENERIC_RP2040) ) && !defined(ARDUINO_ARCH_MBED)
18+
#if !defined(RP2040_ISR_SERVO_USING_MBED)
19+
#define RP2040_ISR_SERVO_USING_MBED false
20+
#endif
21+
22+
#elif ( defined(ARDUINO_NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || \
23+
defined(ARDUINO_GENERIC_RP2040) ) && defined(ARDUINO_ARCH_MBED)
24+
25+
#if !defined(RP2040_ISR_SERVO_USING_MBED)
26+
#define RP2040_ISR_SERVO_USING_MBED true
27+
#endif
28+
29+
#else
30+
#error This code is intended to run on the mbed / non-mbed RP2040 platform! Please check your Tools->Board setting.
31+
#endif
32+
33+
#define RP2040_ISR_SERVO_VERSION_MIN_TARGET "RP2040_ISR_Servo v1.1.0"
34+
#define RP2040_ISR_SERVO_VERSION_MIN 1001000
35+
36+
#include "multiFileProject.h"
37+
38+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
39+
#include "RP2040_ISR_Servo.h"
40+
41+
void setup()
42+
{
43+
Serial.begin(115200);
44+
while (!Serial);
45+
46+
Serial.println("\nStart multiFileProject");
47+
Serial.println(RP2040_ISR_SERVO_VERSION);
48+
49+
#if defined(RP2040_ISR_SERVO_VERSION_MIN)
50+
if (RP2040_ISR_SERVO_VERSION_INT < RP2040_ISR_SERVO_VERSION_MIN)
51+
{
52+
Serial.print("Warning. Must use this example on Version equal or later than : ");
53+
Serial.println(RP2040_ISR_SERVO_VERSION_MIN_TARGET);
54+
}
55+
#endif
56+
}
57+
58+
void loop()
59+
{
60+
// put your main code here, to run repeatedly:
61+
}

0 commit comments

Comments
 (0)