- mruby/cIDE version:1.0
- mrbwrite version:1.0
- mrbc compiler version:2.0
The corresponding firmware can be downloaded from here.
Ruby
For the Ruby classes supported by mruby/c, please refer to the official URL below.https://www.s-itoc.jp/activity/research/mrubyc/mrubyc_docs/library
ADC
start
ADC Startstop
ADC Stopread
Output the acquired value as an integer.Return value: 0~1023(0~3.3V)
read_v
Output the acquired value as a voltage.Return value: 0~3.3
ch(channel)
Specify the port to usechannel:0~7
I2C
write(sl_addr, addr, data1, data2,,,,)
i2c writesl_addr:slave address
addr:address to write to
data:data to write
read(sl_addr, addr, size)
i2c readsl_addr:slave address
addr:address to read from
size:size of data to read
PWM
new
cycle(time,double)
Cycle settingtime:1~65535(1=0.1us)
double:magnification(0~7)
| integer | magnification |
|---|---|
| 0 | 1 |
| 1 | 2 |
| 2 | 4 |
| 3 | 8 |
| 4 | 16 |
| 5 | 32 |
| 6 | 64 |
| 7 | 256 |
rate(p,ch)
p:percentagech:used channel(1~5)
start(ch)
PWM startch:used channel(1~5)
stop(ch)
PWM stopch:used channel(1~5)
pin(pin)
Specify the PWM pin to usepin(2,12,16,18)
| ch | pin |
|---|---|
| 1 | 12 |
| 2 | 16 |
| 3 | |
| 4 | 18 |
| 5 | 2 |
Timer
start
stop
set(time,double)
time:1~65535(1=0.1us)double:integer(magnification)
| integer | magnification |
|---|---|
| 0 | 1 |
| 1 | 2 |
| 2 | 4 |
| 3 | 8 |
| 4 | 16 |
| 5 | 32 |
| 6 | 64 |
| 7 | 256 |
count_clear
count_get
Return value: 0~255UART
new(baud)
Since the baseline is 19200, setting a value higher than this will result in significant data loss.baud:baud rate value (e.g., 19200)
gets
String receptionputs(text)
String transmissiontext:string
clear_buffer
Initialize the receive buffer (mruby/c2.0)Math
https://github.com/YoshihiroOgura/pic32mx170_mrubyc/blob/a0542f4fb76b2f3e1ba6e5078c9e3fc3a7164865/src/c_math.c#L240Others
leds_write(bit)
LED controlbit : integer
| led | Decimal | Binary |
|---|---|---|
| 1 | 1 | 0b0001 |
| 2 | 2 | 0b0010 |
| 3 | 4 | 0b0100 |
| 4 | 8 | 0b1000 |
sw()
Switch state readingReturn value: 0 or 1
pinMode(pin,mode)
pin:0~20mode:0(OUTPUT) or 1(INPUT)
pinPull(pin,mode)
Internal resistance selection(mruby/c2.0)pin:0~20
mode:-1(pull down) or 0(no pull) or 1(pull up)
pinInit
Reset all pin settings to their default state.digitalWrite(pin,mode)
pin:0~20mode:0(OFF) or 1(ON)
digitalRead(pin)
Specify the pin to read the statepin:0~20
Return value: 0(OFF) or 1(ON)
puts(txt)
String outputFor terminal software settings, please refer to here txt:string