Skip to content

Commit 08293b5

Browse files
committed
Constants under ESP32 instead of GPIO module
1 parent ecd0ed1 commit 08293b5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

mrblib/gpio.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module ESP32
2+
include Constants
3+
24
module GPIO
3-
include Constants
4-
55
class << self
66
alias :digital_write :digitalWrite
77
alias :digital_read :digitalRead
@@ -12,11 +12,11 @@ class << self
1212

1313
class Pin
1414
PIN_MODE = {
15-
pullup: ESP32::GPIO::INPUT_PULLUP,
16-
pulldown: ESP32::GPIO::INPUT_PULLDOWN,
17-
input: ESP32::GPIO::INPUT,
18-
output: ESP32::GPIO::OUTPUT,
19-
inout: ESP32::GPIO::INPUT_OUTPUT
15+
pullup: ESP32::GPIO_MODE_INPUT_PULLUP,
16+
pulldown: ESP32::GPIO_MODE_INPUT_PULLDOWN,
17+
input: ESP32::GPIO_MODE_INPUT,
18+
output: ESP32::GPIO_MODE_OUTPUT,
19+
inout: ESP32::GPIO_MODE_INPUT_OUTPUT
2020
}
2121

2222
attr_reader :pin

src/gpio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mrb_mruby_esp32_gpio_gem_init(mrb_state* mrb)
110110

111111
adc1_config_width(ADC_BITWIDTH_12);
112112

113-
constants = mrb_define_module_under(mrb, gpio, "Constants");
113+
constants = mrb_define_module_under(mrb, esp32, "Constants");
114114

115115
#define define_const(SYM) \
116116
do { \
@@ -172,11 +172,11 @@ mrb_mruby_esp32_gpio_gem_init(mrb_state* mrb)
172172
mrb_define_const(mrb, constants, "LOW", mrb_fixnum_value(0));
173173
mrb_define_const(mrb, constants, "HIGH", mrb_fixnum_value(1));
174174

175-
mrb_define_const(mrb, constants, "INPUT", mrb_fixnum_value(GPIO_MODE_INPUT));
176-
mrb_define_const(mrb, constants, "INPUT_OUTPUT", mrb_fixnum_value(GPIO_MODE_INPUT_OUTPUT));
177-
mrb_define_const(mrb, constants, "OUTPUT", mrb_fixnum_value(GPIO_MODE_OUTPUT));
178-
mrb_define_const(mrb, constants, "INPUT_PULLUP", mrb_fixnum_value(GPIO_MODE_INPUT_PULLUP));
179-
mrb_define_const(mrb, constants, "INPUT_PULLDOWN", mrb_fixnum_value(GPIO_MODE_INPUT_PULLDOWN));
175+
mrb_define_const(mrb, constants, "GPIO_MODE_INPUT", mrb_fixnum_value(GPIO_MODE_INPUT));
176+
mrb_define_const(mrb, constants, "GPIO_MODE_INPUT_OUTPUT", mrb_fixnum_value(GPIO_MODE_INPUT_OUTPUT));
177+
mrb_define_const(mrb, constants, "GPIO_MODE_OUTPUT", mrb_fixnum_value(GPIO_MODE_OUTPUT));
178+
mrb_define_const(mrb, constants, "GPIO_MODE_INPUT_PULLUP", mrb_fixnum_value(GPIO_MODE_INPUT_PULLUP));
179+
mrb_define_const(mrb, constants, "GPIO_MODE_INPUT_PULLDOWN", mrb_fixnum_value(GPIO_MODE_INPUT_PULLDOWN));
180180

181181
}
182182

0 commit comments

Comments
 (0)