2023-03-14 14:56:39 +00:00
|
|
|
# WIP
|
|
|
|
|
|
|
|
## Implemented features:
|
|
|
|
```ruby
|
|
|
|
# Initialization: Takes a hash with configuration.
|
2023-03-16 10:42:55 +00:00
|
|
|
led_red = Machine::GPIO.new(38, {mode: Machine::GPIO::OUTPUT_OD, init: Machine::GPIO::ON})
|
|
|
|
led_blue = Machine::GPIO.new(36, {mode: Machine::GPIO::OUTPUT_OD, init: Machine::GPIO::ON})
|
|
|
|
led_green = Machine::GPIO.new(39, {mode: Machine::GPIO::OUTPUT_OD, init: Machine::GPIO::ON})
|
2023-03-14 14:56:39 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
led_red.value # Get LED pin input value
|
|
|
|
led_red.value = Machine::GPIO::OFF # Turn on the LED (Level is reversed)
|
|
|
|
led_red.off # Same as above
|
|
|
|
led_red.on # Turn off the LED (Level is reversed)
|
|
|
|
led_red.toggle # Toggle output
|
|
|
|
```
|
|
|
|
|
2023-03-16 10:42:55 +00:00
|
|
|
```ruby
|
|
|
|
ana_bg = Machine::ADC.new(52) # BandGap
|
|
|
|
ana_bg.value
|
2023-03-18 02:18:53 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
1000.times do |_|
|
|
|
|
puts "[#{Time.now}] BandGap voltage: #{'%.2f' % (ana_bg.value.to_f / 1000.0)}mV"
|
|
|
|
led_red.toggle
|
|
|
|
usleep(100 * 1000)
|
|
|
|
end
|
2023-04-12 16:54:45 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
pwm_blue = Machine::PWM.new(18)
|
|
|
|
pwm_blue.duty = 65535
|
|
|
|
pwm_blue.duty # Get duty cycle
|
2023-03-16 10:42:55 +00:00
|
|
|
```
|