diff --git a/Examples/MakerKit/Mission4_Potentiometer_RGB/Sources/Mission4_Potentiometer_RGB/Mission4_Potentiometer_RGB.swift b/Examples/MakerKit/Mission4_Potentiometer_RGB/Sources/Mission4_Potentiometer_RGB/Mission4_Potentiometer_RGB.swift index e8665cd..14e1c2e 100644 --- a/Examples/MakerKit/Mission4_Potentiometer_RGB/Sources/Mission4_Potentiometer_RGB/Mission4_Potentiometer_RGB.swift +++ b/Examples/MakerKit/Mission4_Potentiometer_RGB/Sources/Mission4_Potentiometer_RGB/Mission4_Potentiometer_RGB.swift @@ -29,7 +29,7 @@ public struct Mission4_Potentiometer_RGB { led.toggle() // Return the percentage of the voltage in the range of 0.0 to 1.0. - let analogValue = a0.readPercent() + let analogValue = a0.readPercentage() let delayTime = Int(analogValue * 500) // Stop the program for a certain period based on the value to keep current led state. diff --git a/Examples/MakerKit/Mission5_Buzzer/Sources/Mission5_Buzzer/Mission5_Buzzer.swift b/Examples/MakerKit/Mission5_Buzzer/Sources/Mission5_Buzzer/Mission5_Buzzer.swift index 395ee8d..020779e 100644 --- a/Examples/MakerKit/Mission5_Buzzer/Sources/Mission5_Buzzer/Mission5_Buzzer.swift +++ b/Examples/MakerKit/Mission5_Buzzer/Sources/Mission5_Buzzer/Mission5_Buzzer.swift @@ -32,9 +32,9 @@ public struct Mission5_Buzzer { while true { // Read the input voltage. - let value = a0.readPercent() + let value = a0.readPercentage() - //let value = a0.readPercent() + //let value = a0.readPercentage() let frequency = Int(400 + 2000 * value) // calculate the float value into Int type to serve as frequency. buzzer.set(frequency: frequency, dutycycle: 0.5) // Set PWM parameters. diff --git a/Examples/MakerKit/Mission7_DC_Motors/Sources/Mission7_DC_Motors/Mission7_DC_Motors.swift b/Examples/MakerKit/Mission7_DC_Motors/Sources/Mission7_DC_Motors/Mission7_DC_Motors.swift index 919261c..8e309f3 100644 --- a/Examples/MakerKit/Mission7_DC_Motors/Sources/Mission7_DC_Motors/Mission7_DC_Motors.swift +++ b/Examples/MakerKit/Mission7_DC_Motors/Sources/Mission7_DC_Motors/Mission7_DC_Motors.swift @@ -28,7 +28,7 @@ public struct Mission7_DC_Motors { while true { // Read the input value and use it to set the duty cycle of pwm. - let value = a0.readPercent() + let value = a0.readPercentage() motor.setDutycycle(value) sleep(ms: 50) } diff --git a/Examples/MakerKit/Mission8_Servo_Motor/Sources/Mission8_Servo_Motor/Mission8_Servo_Motor.swift b/Examples/MakerKit/Mission8_Servo_Motor/Sources/Mission8_Servo_Motor/Mission8_Servo_Motor.swift index f4f163f..a2643f5 100644 --- a/Examples/MakerKit/Mission8_Servo_Motor/Sources/Mission8_Servo_Motor/Mission8_Servo_Motor.swift +++ b/Examples/MakerKit/Mission8_Servo_Motor/Sources/Mission8_Servo_Motor/Mission8_Servo_Motor.swift @@ -37,7 +37,7 @@ public struct Mission8_Servo_Motor { let servo = PWMOut(Id.PWM4A) while true { - let value = a0.readPercent() // Read the analog value and return a value between 0.0 and 1.0. + let value = a0.readPercentage() // Read the analog value and return a value between 0.0 and 1.0. let pulse = Int(500 + 2000 * value) // Calculate the value to get the pulse duration. servo.set(period: 20000, pulse: pulse) // Set the servo position according to the scaled value. diff --git a/Examples/SwiftIOPlayground/04Potentiometer/DoubleLEDDimmer/Sources/main.swift b/Examples/SwiftIOPlayground/04Potentiometer/DoubleLEDDimmer/Sources/main.swift index d325361..1f10649 100644 --- a/Examples/SwiftIOPlayground/04Potentiometer/DoubleLEDDimmer/Sources/main.swift +++ b/Examples/SwiftIOPlayground/04Potentiometer/DoubleLEDDimmer/Sources/main.swift @@ -22,10 +22,10 @@ while true { // Map the analog value from the range 0-1 to the range minIntensity-maxIntensity. // It decides the max duty cycle for the PWM signal. // That's to say, it changes the maximum intensity of the LED. - let maxDutycycle = intensityPot.readPercent() * (maxIntensity - minIntensity) + minIntensity + let maxDutycycle = intensityPot.readPercentage() * (maxIntensity - minIntensity) + minIntensity // Read the analog value (0-1) from the pin A0 which serves as ratio for final duty cycle. - let dutycycleRatio = brightnessPot.readPercent() + let dutycycleRatio = brightnessPot.readPercentage() // Calculate the final duty cycle value (0-maxDutycycle). // Set the PWM output using the result. diff --git a/Examples/SwiftIOPlayground/04Potentiometer/LEDBlinkControl/Sources/main.swift b/Examples/SwiftIOPlayground/04Potentiometer/LEDBlinkControl/Sources/main.swift index 2ae34a8..686c306 100644 --- a/Examples/SwiftIOPlayground/04Potentiometer/LEDBlinkControl/Sources/main.swift +++ b/Examples/SwiftIOPlayground/04Potentiometer/LEDBlinkControl/Sources/main.swift @@ -20,7 +20,7 @@ while true { // Read value from the analog pin. // It serves as duty cycle for PWM to set LED brightness. - led.setDutycycle(brightnessPot.readPercent()) + led.setDutycycle(brightnessPot.readPercentage()) sleep(ms: blinkTime) // After a specified time, suspend the output to turn off the LED. diff --git a/Examples/SwiftIOPlayground/04Potentiometer/LEDDimmer/Sources/main.swift b/Examples/SwiftIOPlayground/04Potentiometer/LEDDimmer/Sources/main.swift index 93b4e29..ba92205 100644 --- a/Examples/SwiftIOPlayground/04Potentiometer/LEDDimmer/Sources/main.swift +++ b/Examples/SwiftIOPlayground/04Potentiometer/LEDDimmer/Sources/main.swift @@ -11,7 +11,7 @@ let led = PWMOut(Id.PWM4A) // The value is represented in percentage, while the duty cycle is also between 0 and 1, // so you can directly use the reading value to set the PWM. while true { - let dutycycle = pot.readPercent() + let dutycycle = pot.readPercentage() led.setDutycycle(dutycycle) sleep(ms: 20) diff --git a/Examples/SwiftIOPlayground/04Potentiometer/PitchControl/Sources/main.swift b/Examples/SwiftIOPlayground/04Potentiometer/PitchControl/Sources/main.swift index 05ea75a..df2eaeb 100644 --- a/Examples/SwiftIOPlayground/04Potentiometer/PitchControl/Sources/main.swift +++ b/Examples/SwiftIOPlayground/04Potentiometer/PitchControl/Sources/main.swift @@ -11,7 +11,7 @@ let buzzer = PWMOut(Id.PWM5A) // Then calculate the value into the frequency. // Set the PWM with the frequency and a duty cycle. while true { - let potPercentage = pot.readPercent() + let potPercentage = pot.readPercentage() let frequency = 50 + Int(1000 * potPercentage) buzzer.set(frequency: frequency, dutycycle: 0.5) sleep(ms: 20)