This content is for the initial lot (mruby/c1.4).
- 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 Start

stop

ADC Stop

read

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 use
channel:0~7

I2C

write(sl_addr, addr, data1, data2,,,,)

i2c write
sl_addr:slave address
addr:address to write to
data:data to write

read(sl_addr, addr, size)

i2c read
sl_addr:slave address
addr:address to read from
size:size of data to read

PWM

new


cycle(time,double)

Cycle setting
time:1~65535‬(1=0.1us)
1(s)÷ (Hz)×10000000= 0
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:percentage
ch:used channel(1~5)

start(ch)

PWM start
ch:used channel(1~5)

stop(ch)

PWM stop
ch:used channel(1~5)

pin(pin)

Specify the PWM pin to use
pin(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~255

UART

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 reception

puts(text)

String transmission
text:string

clear_buffer

Initialize the receive buffer (mruby/c2.0)

Math

https://github.com/YoshihiroOgura/pic32mx170_mrubyc/blob/a0542f4fb76b2f3e1ba6e5078c9e3fc3a7164865/src/c_math.c#L240

Others

leds_write(bit)

LED control
bit : integer
led Decimal Binary
1 1 0b0001
2 2 0b0010
3 4 0b0100
4 8 0b1000

sw()

Switch state reading
Return value: 0 or 1

pinMode(pin,mode)

pin:0~20
mode: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~20
mode:0(OFF) or 1(ON)

digitalRead(pin)

Specify the pin to read the state
pin:0~20
Return value: 0(OFF) or 1(ON)

puts(txt)

String output
For terminal software settings, please refer to here txt:string