Skip to content

Add PWM driver and test app - #589

Open
bradjc wants to merge 2 commits into
masterfrom
dev/pwm-pulse
Open

bradjc wants to merge 2 commits into
masterfrom
dev/pwm-pulse

Conversation

@bradjc

@bradjc bradjc commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

This adds libtock support for PWM and adds a test app for pulsing LEDs via PWM. I'm not entirely sure why we didn't have this support before.

This is all claude. It's just so much faster at creating this rote code. I've tested this with the kernel and even sent a video of the leds pulsing.

// Offset each pin's starting phase within the pulse so pins do not all
// pulse in lockstep.
uint32_t phase_offset = PULSE_STEPS / count;
if (phase_offset == 0) phase_offset = 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (phase_offset == 0) phase_offset = 1;

weird check for an impossible condition (PULSE_STEPS can't be 0, both because it makes no sense and because it's the divisor of a mod higher in this file so you'd get a compile-error if you tried).

Comment on lines +12 to +13
// Maximum duty cycle accepted by the PWM driver (100.00%).
#define MAX_DUTY_CYCLE 10000

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in pwm.h, it's part of the interface contract of the driver, not specific to this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants