Skip to content

Commit ae4ecb1

Browse files
authored
Merge pull request #57 from nishiko-ji/m5display
Make m5stack display faster
2 parents 2d166b1 + 9dd6244 commit ae4ecb1

File tree

9 files changed

+482
-205
lines changed

9 files changed

+482
-205
lines changed

example/master.rb.m5display

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
speaker = GPIO.new(25, GPIO::OUT, -1, 0)
12
display = ILI934X.new(23, 18, 14, 27, 33, 32)
3+
display.draw_fillrectangle(20, 20, 300, 170, [0x69, 0xba, 0xf5])
4+
display.draw_fillrectangle(20, 170, 300, 180, [0x28, 0xad, 0x35])
5+
display.draw_fillrectangle(20, 180, 300, 220, [0x55, 0x42, 0x3d])
6+
display.drawString(52, 52, "mruby/cの\n 世界へ\n ようこそ!", 30, [0, 0, 0])
7+
display.drawString(50, 50, "mruby/cの\n 世界へ\n ようこそ!", 30, [255, 255, 255])
28
sleep 10
3-
display.drawRectangle(20, 300, 20, 170, ILI934X.color(0x69, 0xba, 0xf5))
4-
display.drawRectangle(20, 300, 170, 180, ILI934X.color(0x28, 0xad, 0x35))
5-
display.drawRectangle(20, 300, 180, 220, ILI934X.color(0x55, 0x42, 0x3d))
6-
x = [200, 230, 170]
7-
y = [150, 200, 200]
8-
3.times do |i|
9-
drawLine(display, x[i], x[(i + 1) % 3], y[i], y[(i + 1) % 3], ILI934X.color(0x96, 0x56, 0xa1), 5)
10-
end
11-
display.writeString("12345:\n67890.", 50, 50, 20, 35, 30, ILI934X.color(0x27, 0x1c, 0x19), nil)
12-
display.writeString("12345:\n67890.", 45, 45, 20, 35, 30, ILI934X.color(0xff, 0xf3, 0xec), nil)
9+
i = 0
10+
while true do
11+
display.fill([i, i, i])
12+
5.times do |x|
13+
5.times do |y|
14+
display.draw_pixel(10 + x, 10 + y, [255, 0, 0])
15+
end
16+
end
17+
display.draw_line(20, 50, 240, 230, [0, 0, 255])
18+
display.draw_rectangle(30, 20, 310, 200, [0, 255, 0])
19+
display.draw_circle(160, 120, 20, [100, 50, 220])
20+
display.draw_fillcircle(160, 120, 10, [100, 50, 220])
21+
i += 1
22+
p "light: #{i}" if i % 10 == 0
23+
i = 0 if i == 256
24+
end

main/Kconfig.projbuild

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ menu "IoTeX ESP32 mrubyc Configuration"
99
help
1010
use GPIO function?
1111

12-
13-
config USE_ESP32_GPIO_PERIPHERALS_SHT75
12+
config USE_ESP32_GPIO_IRQHANDLER
13+
bool "USR ESP32 GPIO IRQ Handler"
14+
depends on USE_ESP32_GPIO
15+
default n
16+
help
17+
use IRQ handler with GPIO?
18+
19+
config USE_ESP32_GPIO_PERIPHERALS_SHT75
1420
bool "PERIPHERAL: Temperature/Humidity Sensor SENSIRION SHT75"
1521
depends on USE_ESP32_GPIO
1622
default n

main/font.h

Lines changed: 20 additions & 0 deletions
Large diffs are not rendered by default.

main/main.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
//*********************************************
6666
#ifdef CONFIG_USE_ESP32_GPIO
6767
#include "models/gpio.h"
68+
#endif
69+
#ifdef CONFIG_USE_ESP32_GPIO_ILQHANDLER
6870
#include "models/irq_handler.h"
6971
#endif
7072
#ifdef CONFIG_USE_ESP32_GPIO_PERIPHERALS_SHT75
@@ -315,8 +317,11 @@ void app_main(void) {
315317

316318
#ifdef CONFIG_USE_ESP32_GPIO
317319
printf("start GPIO (mruby/c class)\n");
318-
mrbc_create_task(gpio, 0);
319-
mrbc_create_task(irq_handler, 0);
320+
mrbc_create_task( gpio, 0 );
321+
#endif
322+
#ifdef CONFIG_USE_ESP32_GPIO_IRQHANDLER
323+
printf("start GPIO IRQHandler (mruby/c task)\n");
324+
mrbc_create_task( irq_handler, 0 );
320325
#endif
321326
#ifdef CONFIG_USE_ESP32_LEDC
322327
printf("start PWM (mruby/c class)\n");

main/mrbc_esp32_gpio.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ mrbc_nop(mrb_vm* vm, mrb_value* v, int argc)
3030
}
3131

3232

33+
/*! メソッド reset_pin(pin) 本体 : wrapper for gpio_reset_pin
34+
35+
@param pin GPIO ピン番号
36+
*/
37+
static void
38+
mrbc_esp32_gpio_reset_pin(mrb_vm* vm, mrb_value* v, int argc)
39+
{
40+
int pin = GET_INT_ARG(1);
41+
gpio_reset_pin(pin);
42+
}
43+
3344
/*! メソッド set_pullup(pin) 本体 : wrapper for gpio_set_pull_mode
3445
GPIO_PULLUP_ONLY 専用
3546
@@ -208,6 +219,7 @@ void
208219
mrbc_mruby_esp32_gpio_gem_init(struct VM* vm)
209220
{
210221
/*
222+
GPIO.reset_pin(pin)
211223
GPIO.set_pullup(pin)
212224
GPIO.set_pulldown(pin)
213225
GPIO.wakeup_enable(pin, level)
@@ -230,6 +242,7 @@ GPIO.isr_handler_add(pin, isr_handler, args)
230242
mrbc_class_esp32_gpio = mrbc_define_class(vm, "GPIO", mrbc_class_object);
231243

232244
// 各メソッド定義(mruby/c ではインスタンスメソッドをクラスメソッドとしても呼び出し可能)
245+
mrbc_define_method(vm, mrbc_class_esp32_gpio, "reset_pin", mrbc_esp32_gpio_reset_pin);
233246
mrbc_define_method(vm, mrbc_class_esp32_gpio, "set_pullup", mrbc_esp32_gpio_set_pullup);
234247
mrbc_define_method(vm, mrbc_class_esp32_gpio, "set_pulldown", mrbc_esp32_gpio_set_pulldown);
235248
mrbc_define_method(vm, mrbc_class_esp32_gpio, "wakeup_enable", mrbc_esp32_gpio_wakeup_enable);

0 commit comments

Comments
 (0)