Skip to content

Commit

Permalink
Merge pull request zhaolei#9 from pctj101/fixPwmTone
Browse files Browse the repository at this point in the history
Fix duty cycle to half period
  • Loading branch information
hunanchenxingyu authored Aug 10, 2017
2 parents c063551 + 095aab2 commit c67bb62
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# check if sudo is required and save the result as ${PFX}:
[[ ${EUID} -ne 0 ]] && PFX='sudo ' || PFX=''
Expand Down
16 changes: 16 additions & 0 deletions examples/cli_song.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Example of how to export PWM Pin and play tones via CLI

export WIRINGPI_DEBUG=true
export WIRINGPI_CODES=true
GPIO=../gpio/gpio

$GPIO export 1 out
$GPIO mode 1 pwm
$GPIO pwmTone 1 1033

for i in 262 523 220 440 233 466 0 0 262 523 220 440 233 466 0 0 175 349 147 294 156 311 0 0 175 349 147 294 156 311 0 0 311 277 294 277 311 311 208 196 277 262 370 349 165 466 440 415 311 247 233 220 208 0 0 0 ; do
$GPIO pwmTone 1 $i;
sleep 0.15;
done
4 changes: 2 additions & 2 deletions wiringPi/wiringPi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2317,9 +2317,9 @@ void pwmToneWrite (int pin, int freq)
pwmWrite (pin, 0) ; // Off
else
{
range = 600000 / freq ;
range = 200000 / freq ;
pwmSetRange (range) ;
pwmWrite (pin, freq / 2) ;
pwmWrite (pin, range / 2) ;
}
}

Expand Down

0 comments on commit c67bb62

Please sign in to comment.