Introduction - Recap what PWM is and why it’s useful - You do PWM the same way on Linux as you would on an Arduino, as we will show - But you have to handle a multi threaded environment, that means jitter
Writing the daemon: - Brief: high level design of my daemon - Brief: how to control GPIO pins on the raspberry pi (memory mapping with /dev/mem, /dev/gpiomem) - Brief: introduction to daemons (fork/exit, start new process group with setsid, close standard file descriptors that were cloned by fork) - Brief: open FIFO, endless loop on main thread waiting for messages, update the control structure based on the control message parameters for the pin, spawn a thread if needed
PWM: - Detailed: how the threads actually control LED brightness, basically each one does a mark/space and turns the LEDs on and off on a 100Hz cycle with varying duty cycle.
YOU MAY ALSO LIKE:
PWM from a Linux Daemon, I Told You It Was a Bad Idea, Now Here’s How to Do It
Carl Peto
I have spent 20 or 30 years working with all kinds of computer tech I could get my hands on. From big machines back in the 90s down to little shiny phones you hold in your hand nowadays. Writing iOS since pretty much the first iPhones, my day job is Swift fanatic with a dash of objective C and a side interest in "IoT". I'm currently working at a start up specialising in high tech IoT projects. And Arduino and Pi have been my side interest for ages. Half my flat is connected to one prototype or another.