Comments (4)
I'm not sure if I understand your question correctly, but maybe something like this?
// factory function for PWM
GPIO::PWM CreatePWMObject(int output_pin)
{
// Pin Setup.
// Board pin-numbering scheme
GPIO::setmode(GPIO::BOARD);
// set pin as an output pin with optional initial state of HIGH
GPIO::setup(output_pin, GPIO::OUT, GPIO::HIGH);
GPIO::PWM p(output_pin, 50);
return p;
}
// declare "p" as a global variable
static GPIO::PWM p = CreatePWMObject(output_pin);
int main()
{
// your code...
}
from jetsongpio.
Oke thanks you
from jetsongpio.
/home/jetson/Desktop/person_detection/pedestrian_detection/test.cpp:246:10: error: use of deleted function βGPIO::PWM::PWM(const GPIO::PWM&)β
return p;
I used it but error.
from jetsongpio.
Oops, my bad. I forgot that PWM objects cannot be copied.
I added move constructor and move assign operator to PWM class just now. Now you can move the PWM object.
So,
-
Update your local repository:
(Assume you're in the JetsonGPIO directory)
git pull
-
Rebuild & reinstall the library:
cd build
make all
sudo make install
- Try the above example code again.
Or you can also just use p as reference to the static instance.
Something like this:
// get the reference to static instance of PWM object
GPIO::PWM& GetPWMObject(int output_pin)
{
// Pin Setup.
// Board pin-numbering scheme
GPIO::setmode(GPIO::BOARD);
// set pin as an output pin with optional initial state of HIGH
GPIO::setup(output_pin, GPIO::OUT, GPIO::HIGH);
// note that p will be initialized only once even if you call GetPWMObject function multiple times.
static GPIO::PWM p(output_pin, 50);
return p;
}
// declare "p" as a global reference to the static instance of PWM object.
static GPIO::PWM& p = GetPWMObject(output_pin);
int main()
{
// your code...
}
from jetsongpio.
Related Issues (20)
- Improve PWM part of the API document
- GPIO::remove_edge_detect function: add warning for no event found HOT 1
- Update sysfs pwm dir
- Add more sample codes
- Add prerequisites info to the installation guide HOT 1
- Add pre-built binaries to release page
- How to control Rx, Tx pin on Jetson Nano? HOT 1
- orin nano run error HOT 1
- No support for PQ.02 for Jetson Orin NX
- Jetson Orin Nano: cannot find GPIO chip 2200000.gpio HOT 11
- Jetson Orin GPIO Chip cannot find Jetpack 6
- Support for Jetson Orin NX
- Support for Nano and Xavier NX HOT 2
- Error compiling with CmakeLists HOT 4
- "When importing both JetsonGPIO.h and cuda_runtime.h at the same time, a compilation error occurs." HOT 4
- Docker Image CI fails HOT 1
- Can I reboot the nano system through GPIO? HOT 1
- Adding Compat models for Jetson Orin HOT 3
- Move to gpio character device implementation HOT 1
- Divide README into multiple documents for readability
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jetsongpio.