rabbit-slide-hasumikin-RubyConfPoland2019 2019.05.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rabbit +1 -0
- data/README.rd +32 -0
- data/Rakefile +17 -0
- data/config.yaml +22 -0
- data/images/IDE.png +0 -0
- data/images/bytecode.png +0 -0
- data/images/co2_demo.png +0 -0
- data/images/collage01.jpg +0 -0
- data/images/esp32.jpg +0 -0
- data/images/hasumi.jpg +0 -0
- data/images/how-mrubyc-test-works.png +0 -0
- data/images/juji-asahi.jpg +0 -0
- data/images/kamos.jpg +0 -0
- data/images/krkrb-main.png +0 -0
- data/images/krkrb-main.svg +1 -0
- data/images/krkrb-main.svg.png +0 -0
- data/images/m1.png +0 -0
- data/images/m2.png +0 -0
- data/images/mark32.png +0 -0
- data/images/mark48.png +0 -0
- data/images/mark64.png +0 -0
- data/images/monstarlab.png +0 -0
- data/images/monstarlab_global.png +0 -0
- data/images/mruby_and_mrubyc-mruby.png +0 -0
- data/images/mruby_and_mrubyc-mrubyc.png +0 -0
- data/images/mruby_and_mrubyc.png +0 -0
- data/images/psoc5lp_chip.jpg +0 -0
- data/images/raspberrypi.jpg +0 -0
- data/images/slide-background.png +0 -0
- data/images/unsoldered-2.png +0 -0
- data/images/unsoldered.jpg +0 -0
- data/images//346/235/276/346/261/237/345/237/216_Matsue.rb.16x9.jpg +0 -0
- data/images//346/235/276/346/261/237/345/237/216_Matsue.rb.jpg +0 -0
- data/mrubyc---The-smallest-Ruby-implementation-for-microcontrollers.rab +866 -0
- data/pdf/RubyConfPoland2019-mrubyc---The-smallest-Ruby-implementation-for-microcontrollers.pdf +0 -0
- data/theme.rb +99 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: aabacc738ae6ef77dc1319002d5920b0713853e98bc7020f8618e90e4fc96cc8
|
4
|
+
data.tar.gz: 737e9ff3a69327f462c0d8c88830249172ef0605e4ac988d0c671ae6ce925bba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 122bfd7a79327479d2997b3a7795e280672fe541f009fd75f59137e17ec619ec53ac8fcd90bece8799055d7537bdb52be0e2748d8f8b024fde65fd0746aaad53
|
7
|
+
data.tar.gz: acdafb2d5fc2498e3b2755bb0723702c5e2faad56a22cbac2087e02e83ddef9e3bf457f0649d67ab9d0f58a243a99ab97544cb07893da542b1a820a547089f53
|
data/.rabbit
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
mrubyc---The-smallest-Ruby-implementation-for-microcontrollers.rab
|
data/README.rd
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
= mrubyc - The smallest Ruby implementation for microcontrollers
|
2
|
+
|
3
|
+
The slide for [THE RUBY CONFERENCE OF CRACOW 2019](https://krk-rb.pl/) by [hasumkin](https://github.com/hasumikin)
|
4
|
+
|
5
|
+
It will cover:
|
6
|
+
|
7
|
+
- Introducing Ruby for microcontrollers and microcontrollers themselves
|
8
|
+
- Things in common and difference between mruby and mruby/c
|
9
|
+
- How mruby/c works
|
10
|
+
- Development sorroundings
|
11
|
+
- Some actual source code of firmware application
|
12
|
+
|
13
|
+
== for author
|
14
|
+
|
15
|
+
=== presentation
|
16
|
+
|
17
|
+
rake
|
18
|
+
|
19
|
+
=== publishment
|
20
|
+
|
21
|
+
rake publish
|
22
|
+
|
23
|
+
== for readers
|
24
|
+
|
25
|
+
=== install
|
26
|
+
|
27
|
+
gem install rabbit-slide-hasumikin-RubyConfPoland2019
|
28
|
+
|
29
|
+
=== browse
|
30
|
+
|
31
|
+
rabbit rabbit-slide-hasumikin-RubyConfPoland2019.gem
|
32
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rabbit/task/slide"
|
2
|
+
|
3
|
+
# Edit ./config.yaml to customize meta data
|
4
|
+
|
5
|
+
spec = nil
|
6
|
+
Rabbit::Task::Slide.new do |task|
|
7
|
+
spec = task.spec
|
8
|
+
# spec.files += Dir.glob("doc/**/*.*")
|
9
|
+
# spec.files -= Dir.glob("private/**/*.*")
|
10
|
+
# spec.add_runtime_dependency("YOUR THEME")
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Tag #{spec.version}"
|
14
|
+
task :tag do
|
15
|
+
sh("git", "tag", "-a", spec.version.to_s, "-m", "Publish #{spec.version}")
|
16
|
+
sh("git", "push", "--tags")
|
17
|
+
end
|
data/config.yaml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
id: RubyConfPoland2019
|
3
|
+
base_name: mrubyc---The-smallest-Ruby-implementation-for-microcontrollers
|
4
|
+
tags:
|
5
|
+
- mruby
|
6
|
+
- mruby/c
|
7
|
+
- IoT
|
8
|
+
presentation_date: 2019/05/14
|
9
|
+
version: 2019.05.14
|
10
|
+
licenses: []
|
11
|
+
slideshare_id:
|
12
|
+
speaker_deck_id:
|
13
|
+
ustream_id:
|
14
|
+
vimeo_id:
|
15
|
+
youtube_id:
|
16
|
+
author:
|
17
|
+
markup_language: :rd
|
18
|
+
name: HASUMI Hitoshi
|
19
|
+
email: hasumikin@gmail.com
|
20
|
+
rubygems_user: hasumikin
|
21
|
+
slideshare_user:
|
22
|
+
speaker_deck_user:
|
data/images/IDE.png
ADDED
Binary file
|
data/images/bytecode.png
ADDED
Binary file
|
data/images/co2_demo.png
ADDED
Binary file
|
Binary file
|
data/images/esp32.jpg
ADDED
Binary file
|
data/images/hasumi.jpg
ADDED
Binary file
|
Binary file
|
Binary file
|
data/images/kamos.jpg
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 739.03 574.87"><defs><style>.cls-1{fill:#182943;}.cls-2{fill:#afbdff;}.cls-3{fill:#c2cdff;}.cls-4{fill:#dde4ff;}.cls-5{fill:#8b9fff;}.cls-6{fill:#f34611;}.cls-7{fill:#c9260a;}.cls-8,.cls-9{fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;}.cls-8{stroke:#f34611;}.cls-9{stroke:#c9260a;}</style></defs><title>Asset 3</title><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path class="cls-1" d="M553.41,239.39C529.24,97.89,346.38-5.49,259.59,36.18c-33,15.85-61.9,57.39-59.86,97.32,3.77,73.68,110.92,105,101.07,148-8.39,36.62-88.24,23.2-114.43,70.13C155.52,406.92,210.12,526.21,283,545.11,388.1,572.38,581.44,403.48,553.41,239.39Z"/><polygon class="cls-2" points="375.5 364.35 503.93 315.42 415.42 485.23 333.16 543.39 243.71 532.32 290.59 479.56 375.5 364.35"/><path class="cls-2" d="M739,288.92s-168.15-61.28-238.51-52.2S336,310.48,307.05,326.93s-105.26,54.64-105.26,54.64,21,27.49,55.37,13.38,66.06-28,86.48-24.07,51.63,17.33,104.68-17.28S739,288.92,739,288.92Z"/><path class="cls-2" d="M375.5,364.35S260.81,483.81,248,492s-99.57,1.7-112.91,3.4-27.51,7.66-31.2,13.62,127.66,18.72,145.25,13.62,56.73-37.45,56.73-37.45Z"/><path class="cls-2" d="M120.52,513.76c-16.67.55-36.48,1.19-34.18,10.09,10.4,8.47,51.8,16.17,49.17,15.47l96.5,4.07s78.73-14.47,96.6-34.33-22.7-23.83-22.7-23.83-46.86,32.61-56.17,33.66S137.19,513.22,120.52,513.76Z"/><path class="cls-3" d="M319,558.61s-56.45,16.26-86.81,16.26-120.28-26.38-120.28-32.34,20.71-16.21,37.45-16.21S239,541.39,239,541.39Z"/><path class="cls-4" d="M719.53,418.28S688.89,363,628.75,382.71,432.44,513.6,397.26,545.37s-162.77,7.14-170.5-6c0,0,9.11-17.12,34.05-16.22s63.81,3.72,83.1-.84,55.27-36.45,68.6-60.38S472.15,266.22,565.2,259.41,739,288.92,739,288.92Z"/><path class="cls-5" d="M185,117.74v21l-1.63,1.63L166.7,128.11a17.84,17.84,0,0,1-8.89-15.44V111.6c-2.12-1.85,4.57-6.88,8.24-4.77Z"/><path class="cls-3" d="M183.39,119.37v21l-18.32-10.65a17.84,17.84,0,0,1-8.89-15.44v-1.08a5.5,5.5,0,0,1,8.24-4.76Z"/><path class="cls-5" d="M185,160.93v21l-1.63,1.63L166.7,171.31a17.85,17.85,0,0,1-8.89-15.44v-1.08c-2.12-1.84,4.57-6.87,8.24-4.76Z"/><path class="cls-3" d="M183.39,162.56v21l-18.32-10.64a17.85,17.85,0,0,1-8.89-15.44v-1.08a5.5,5.5,0,0,1,8.24-4.77Z"/><path class="cls-5" d="M185,204.13v21l-1.63,1.63L166.7,214.51a17.85,17.85,0,0,1-8.89-15.44V198c-2.12-1.85,4.57-6.87,8.24-4.77Z"/><path class="cls-3" d="M183.39,205.76v21l-18.32-10.64a17.85,17.85,0,0,1-8.89-15.44v-1.08a5.5,5.5,0,0,1,8.24-4.77Z"/><path class="cls-5" d="M185,247.33v21L183.39,270,166.7,257.7a17.82,17.82,0,0,1-8.89-15.44v-1.07c-2.12-1.85,4.57-6.88,8.24-4.77Z"/><path class="cls-3" d="M183.39,249v21l-18.32-10.65a17.84,17.84,0,0,1-8.89-15.44v-1.08a5.5,5.5,0,0,1,8.24-4.76Z"/><path class="cls-5" d="M201.23,309.7l18.08,10.12,0,19c-3.26,8.87-6,9-10.8,6.23h0a14.58,14.58,0,0,1-7.28-12.63l-1.61-21.08Z"/><path class="cls-3" d="M199.59,311.34l18.08,10.1v19a7.2,7.2,0,0,1-10.79,6.24h0A14.59,14.59,0,0,1,199.59,334Z"/><path class="cls-5" d="M231.66,327.08l18.07,10.11v19c-3.27,8.88-6,9-10.8,6.23h0a14.56,14.56,0,0,1-7.28-12.63L230,328.7Z"/><path class="cls-3" d="M230,328.71l18.09,10.11v19A7.2,7.2,0,0,1,237.3,364h0A14.56,14.56,0,0,1,230,351.42Z"/><path class="cls-5" d="M264.48,345.54l18.08,10.12v19c-3.27,8.87-6,9-10.81,6.22h0a14.59,14.59,0,0,1-7.28-12.62l-1.61-21.08Z"/><path class="cls-3" d="M262.84,347.18l18.09,10.1v19a7.2,7.2,0,0,1-10.8,6.23h0a14.56,14.56,0,0,1-7.29-12.62Z"/><path class="cls-5" d="M294.91,362.91,313,373l0,19c-3.27,8.87-6,9-10.8,6.23h0a14.56,14.56,0,0,1-7.28-12.63l-1.61-21.08Z"/><path class="cls-3" d="M293.26,364.55l18.09,10.1v19a7.21,7.21,0,0,1-10.8,6.24h0a14.58,14.58,0,0,1-7.29-12.62Z"/><path class="cls-5" d="M190.15,287.84,185,74.57c8.64-7,12.46-12.83,18.37-9.47l128.53,73.12a21.81,21.81,0,0,1,11,18.94V372.21c0,6.79-10,13.34-13.77,17.12l-128-82.55A21.78,21.78,0,0,1,190.15,287.84Z"/><path class="cls-3" d="M179.89,297.56v-215a8.86,8.86,0,0,1,13.24-7.7l128.54,73.13a21.79,21.79,0,0,1,11,18.94V381.93a8.86,8.86,0,0,1-13.24,7.7L190.91,316.5A21.78,21.78,0,0,1,179.89,297.56Z"/><path class="cls-5" d="M195,279.53l-4.11-170.85c6.92-5.62,10-10.28,14.71-7.59l103,58.58a17.46,17.46,0,0,1,8.82,15.17V347.11c0,5.44-8,10.69-11,13.71L203.79,294.7A17.46,17.46,0,0,1,195,279.53Z"/><path class="cls-3" d="M186.75,287.31V115.05a7.09,7.09,0,0,1,10.6-6.17l103,58.58a17.43,17.43,0,0,1,8.82,15.17V354.9a7.09,7.09,0,0,1-10.6,6.16l-103-58.57A17.48,17.48,0,0,1,186.75,287.31Z"/><path class="cls-5" d="M206.66,74.84l-1.58-18.59c0-4.58,6.53-9,10.5-6.67h0a17.12,17.12,0,0,1,8.56,14.83V84.92l-1.57,1.58Z"/><path class="cls-3" d="M205.08,76.42V56.31A6,6,0,0,1,214,51.16h0A17.1,17.1,0,0,1,222.57,66V86.5Z"/><path class="cls-5" d="M238.44,93.61,236.87,75c0-4.58,6.53-9,10.5-6.67h0a17.12,17.12,0,0,1,8.56,14.83v20.51l-1.58,1.58Z"/><path class="cls-3" d="M236.87,95.19V75.08a5.94,5.94,0,0,1,8.92-5.15h0a17.09,17.09,0,0,1,8.56,14.82v20.52Z"/><path class="cls-5" d="M271,110.45l-1.58-18.59c0-4.58,6.54-9,10.5-6.67h0A17.12,17.12,0,0,1,288.5,100v20.52l-1.58,1.58Z"/><path class="cls-3" d="M269.43,112V91.92a6,6,0,0,1,8.93-5.15h0a17.09,17.09,0,0,1,8.56,14.82v20.52Z"/><path class="cls-5" d="M302.8,129.22l-1.58-18.59c0-4.58,6.53-9,10.5-6.67h0a17.11,17.11,0,0,1,8.56,14.82V139.3l-1.57,1.58Z"/><path class="cls-3" d="M301.22,130.79v-20.1a6,6,0,0,1,8.92-5.15h0a17.1,17.1,0,0,1,8.57,14.82v20.52Z"/><path class="cls-5" d="M339.14,192.19l-1.62,1.63,1.62,19.39,16,11.57c4.73,1.46,11.25-2.74,11.25-8.21h0a15.11,15.11,0,0,0-7.58-13.1Z"/><path class="cls-3" d="M337.52,193.82v21l16.56,9.52a7.11,7.11,0,0,0,10.65-6.16h0a15.11,15.11,0,0,0-7.58-13.1Z"/><path class="cls-5" d="M339.14,238.29l-1.62,1.63,1.62,19.39,16,11.57c4.73,1.46,11.25-2.74,11.25-8.21h0a15.12,15.12,0,0,0-7.58-13.1Z"/><path class="cls-3" d="M337.52,239.92v21l16.56,9.52a7.11,7.11,0,0,0,10.65-6.16h0a15.11,15.11,0,0,0-7.58-13.1Z"/><path class="cls-5" d="M339.14,284.39,337.52,286l1.62,19.39,16,11.57c4.73,1.46,11.25-2.74,11.25-8.2h0a15.13,15.13,0,0,0-7.58-13.11Z"/><path class="cls-3" d="M337.52,286v21l16.56,9.52a7.11,7.11,0,0,0,10.65-6.16h0a15.12,15.12,0,0,0-7.58-13.1Z"/><path class="cls-5" d="M339.14,330.49l-1.62,1.63,1.62,19.39,16,11.57c4.73,1.46,11.25-2.74,11.25-8.2h0a15.13,15.13,0,0,0-7.58-13.11Z"/><path class="cls-3" d="M337.52,332.12v21l16.56,9.52a7.11,7.11,0,0,0,10.65-6.15h0a15.13,15.13,0,0,0-7.58-13.11Z"/><path class="cls-6" d="M105.2,322.75,83.34,308.43h0a4.76,4.76,0,0,0-.49-.28l-.29-.14-.22-.1-.34-.12-.19-.06-.33-.08-.22-.05-.29,0-.27,0H79.9l-.34,0-.28,0-.27.05a5.09,5.09,0,0,0-.56.14h0l-31.54,10a5.75,5.75,0,0,0-3.62,3.36L33.6,345.34a5.77,5.77,0,0,0,2.41,7.1L78.7,377.81h0l.4.21.15.08h0a4.87,4.87,0,0,0,.53.21l.21.06c.12,0,.23.07.35.09l.22,0,.35.05.22,0,.35,0h.58l.19,0,.41-.06.15,0a5.36,5.36,0,0,0,.54-.14h0a5.55,5.55,0,0,0,.52-.2l.14-.06.37-.18.16-.1.32-.2.16-.12a3.15,3.15,0,0,0,.29-.22l.16-.14.26-.25.15-.16.24-.28.13-.17a5.72,5.72,0,0,0,.32-.48h0l.08-.15c.07-.14.15-.27.21-.4v0l20.39-45.28A5.75,5.75,0,0,0,105.2,322.75Z"/><path class="cls-7" d="M430.39,38.27l-9.47-24.36h0a4.9,4.9,0,0,0-.24-.52c0-.09-.1-.18-.15-.27l-.12-.21-.21-.3-.12-.16-.22-.26-.15-.17-.21-.2-.2-.19-.2-.15a2.43,2.43,0,0,0-.25-.2l-.19-.12-.29-.18-.25-.12-.25-.13a4.81,4.81,0,0,0-.53-.2h0L385.88.28A5.79,5.79,0,0,0,381,.92L359,15a5.76,5.76,0,0,0-2.16,7.18l20,45.45v0l.2.4s.05.11.08.16h0a4.9,4.9,0,0,0,.31.48l.13.17.23.28.16.17.25.24.16.15.28.22.17.12.32.2.16.1.36.19.14.06a5.55,5.55,0,0,0,.52.2h0a5.44,5.44,0,0,0,.54.15l.15,0,.4.06.19,0,.38,0h.56l.22,0,.35-.06.22,0a3.58,3.58,0,0,0,.35-.09l.21-.06.53-.2h0a.8.8,0,0,1,.16-.08c.13-.07.27-.13.39-.21h0l42.9-25A5.76,5.76,0,0,0,430.39,38.27Z"/><path class="cls-8" d="M343,449C156.55,435.26,109,407.64,105.26,382.64c-4.18-27.82,45.32-55.65,35.5-88-6.6-21.74-35.94-32-57.1-37"/><path class="cls-8" d="M31.87,409.74s53-32.13,72,19.67,229.31,35,229.31,35"/><path class="cls-8" d="M145.06,365.33s53.68-61.4,0-95.35"/><line class="cls-8" x1="124.48" y1="258.56" x2="103.85" y2="252.94"/><line class="cls-8" x1="320.28" y1="485.23" x2="248.04" y2="492.04"/><line class="cls-8" x1="230.03" y1="495.6" x2="196.51" y2="495.6"/><path class="cls-8" d="M20.24,416.21S4.77,424.93,1,437.55"/><path class="cls-8" d="M145.06,437.55s26.16,15.31,51.45,11.45"/><path class="cls-9" d="M402.3,240.9s-71.06-75.55-30.87-100,43.16-37.09,30.87-46.61"/><path class="cls-9" d="M383.91,182.25c-16.15-26,0-32.73,0-32.73"/><line class="cls-9" x1="389.3" y1="192.19" x2="398.22" y2="205.54"/><path class="cls-9" d="M376.73,87.2S391,88,389.3,100.31"/></g></g></svg>
|
Binary file
|
data/images/m1.png
ADDED
Binary file
|
data/images/m2.png
ADDED
Binary file
|
data/images/mark32.png
ADDED
Binary file
|
data/images/mark48.png
ADDED
Binary file
|
data/images/mark64.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,866 @@
|
|
1
|
+
= mruby/c\nThe smallest Ruby implementation for microcontrollers
|
2
|
+
|
3
|
+
# : subtitle
|
4
|
+
# サブタイトル
|
5
|
+
: author
|
6
|
+
HASUMI Hitoshi @hasumikin
|
7
|
+
# : institution
|
8
|
+
# 所属
|
9
|
+
# : content-source
|
10
|
+
# イベント名
|
11
|
+
: date
|
12
|
+
May 6, 2019 in Warszawa
|
13
|
+
: date
|
14
|
+
May 14, 2019 in Kraków
|
15
|
+
: allotted-time
|
16
|
+
47m
|
17
|
+
: theme
|
18
|
+
theme
|
19
|
+
|
20
|
+
= hide-title
|
21
|
+
(('tag:center'))\n\n\n\n((*(('tag:xx-large:Cześć!'))*))
|
22
|
+
== プロパティ
|
23
|
+
: hide-title
|
24
|
+
true
|
25
|
+
|
26
|
+
= about me
|
27
|
+
* HASUMI Hitoshi\n@hasumikin
|
28
|
+
* live in Matsue city,\na holy place of Ruby
|
29
|
+
* Sake 🍶\nSoba 🍜\nCoffee ☕
|
30
|
+
# image
|
31
|
+
# src = images/hasumi.jpg
|
32
|
+
# align = right
|
33
|
+
# relative-height = 80
|
34
|
+
|
35
|
+
= about me
|
36
|
+
# image
|
37
|
+
# src = images/monstarlab.png
|
38
|
+
# relative_width = 120
|
39
|
+
# relative_margin_top = -1
|
40
|
+
|
41
|
+
= about me
|
42
|
+
# image
|
43
|
+
# src = images/m2.png
|
44
|
+
# relative_width = 106
|
45
|
+
# relative_margin_top = -1
|
46
|
+
|
47
|
+
= about me
|
48
|
+
# image
|
49
|
+
# src = images/松江城_Matsue.rb.jpg
|
50
|
+
# relative_width = 106
|
51
|
+
# relative_margin_top = -3
|
52
|
+
== prop
|
53
|
+
: hide-title
|
54
|
+
true
|
55
|
+
|
56
|
+
= message from Matz
|
57
|
+
# # video
|
58
|
+
# # src = images/video.mp4
|
59
|
+
|
60
|
+
= agenda
|
61
|
+
* terminology
|
62
|
+
* about my IoT project
|
63
|
+
* mruby and mruby/c
|
64
|
+
* how does mruby/c work
|
65
|
+
* actual source code of my project
|
66
|
+
* development environment
|
67
|
+
|
68
|
+
= terminology
|
69
|
+
|
70
|
+
= terminology
|
71
|
+
* mruby/c
|
72
|
+
* tha language I will talk about today
|
73
|
+
* I say mrubyc as /c is hard to pronounce
|
74
|
+
* microcontroller
|
75
|
+
* small computer contains CPU, memory and programmable I/O peripherals
|
76
|
+
* in this talk, microcontroller is distinguished from single board computer like Raspberry Pi
|
77
|
+
|
78
|
+
= terminology
|
79
|
+
* RTOS
|
80
|
+
* Real-time OS. usually used for microcontroller
|
81
|
+
* task
|
82
|
+
* almost equivalent to `Thread` in linux. we say `task` in microcontroller world
|
83
|
+
|
84
|
+
= terminology
|
85
|
+
* 旭日酒造(Aasahi-shuzo)
|
86
|
+
* shuzo means Sake brewery
|
87
|
+
* one of the best Japanese Sake brewery
|
88
|
+
* Asahi-beer(famous for SUPER DRY) has no concern with Asahi-shuzo
|
89
|
+
* Aasahi-shuzo and I make IoT system using mruby/c
|
90
|
+
|
91
|
+
= why microcontroller?
|
92
|
+
* I never use single board computer like Raspberry Pi for production environment.
|
93
|
+
|
94
|
+
= why microcontroller?
|
95
|
+
* it starts immediately right after plugged in
|
96
|
+
* end users, brewery workers in my case, can use it simply like home electical things
|
97
|
+
* you can narrow security issue list
|
98
|
+
* many a malware aims at Linux or Windows platform as a target
|
99
|
+
* you don't need to consider unnecessary deamon
|
100
|
+
* you don't need to do `apt upgrade`
|
101
|
+
|
102
|
+
= why microcontroller?
|
103
|
+
* low energy
|
104
|
+
* rarely overheated
|
105
|
+
* many choices of power supply
|
106
|
+
* mass production
|
107
|
+
* you can choose appropriate chipset(number of GPIOs, memory size, etc.) for your application
|
108
|
+
* cost advantage for parts supply and subcontractor manufacturing
|
109
|
+
|
110
|
+
= which microcontroller?
|
111
|
+
|
112
|
+
= which microcontroller?
|
113
|
+
# image
|
114
|
+
# src = images/psoc5lp_chip.jpg
|
115
|
+
# align = right
|
116
|
+
# relative-height = 60
|
117
|
+
* CYPRESS PSoC5LP
|
118
|
+
* 32 bit Arm Cortex-M3 CPU
|
119
|
+
* Flash: 256KB
|
120
|
+
* SRAM: 64KB
|
121
|
+
* 64KB is the target size\nof mruby/c
|
122
|
+
|
123
|
+
= which microcontroller?
|
124
|
+
# image
|
125
|
+
# src = images/esp32.jpg
|
126
|
+
# align = center
|
127
|
+
# relative-height = 50
|
128
|
+
* Espressif ESP-WROOM-32 (ESP32)
|
129
|
+
* 32 bit dual core LX6 CPU
|
130
|
+
* Flash: 4MB
|
131
|
+
* SRAM: 520KB
|
132
|
+
|
133
|
+
= about my IoT project
|
134
|
+
|
135
|
+
= about my IoT project
|
136
|
+
* IoT system for Asahi-shuzo
|
137
|
+
* delivered to actual brew work in January 2018
|
138
|
+
* devices post temperature of Sake materials in brewing, surrounding temperature and humidity to server
|
139
|
+
* data is displayed on smartphone app
|
140
|
+
|
141
|
+
= about my IoT project
|
142
|
+
# image
|
143
|
+
# src = images/kamos.jpg
|
144
|
+
# align = center
|
145
|
+
# relative-height = 95
|
146
|
+
|
147
|
+
= about my IoT project
|
148
|
+
# image
|
149
|
+
# src = images/collage01.jpg
|
150
|
+
# align = center
|
151
|
+
# relative-height = 95
|
152
|
+
|
153
|
+
= about my IoT project
|
154
|
+
: what were difficult about mruby/c?
|
155
|
+
* we can neither do step execution nor look into appropriate memory address of mruby/c's variables
|
156
|
+
* so many troubles in IoT
|
157
|
+
* hard to find why the application doesn't work well
|
158
|
+
* mruby/c was growing
|
159
|
+
* bugs, lack of features, docs and examples
|
160
|
+
|
161
|
+
= about my IoT project
|
162
|
+
: so, was mruby/c bad?
|
163
|
+
|
164
|
+
= about my IoT project
|
165
|
+
: so, was mruby/c bad? - NO
|
166
|
+
* IoT at work makes you hurry
|
167
|
+
* you have to go back and forth between dark 10℃ storage cellar and humid 35℃ manufacturing room
|
168
|
+
* brewery workers run around
|
169
|
+
* you have to amend your firmware with your small laptop in 10 minutes
|
170
|
+
* you will thank Ruby's descriptiveness and agility
|
171
|
+
|
172
|
+
= today's demo
|
173
|
+
* CO(('sub:2')) concentration
|
174
|
+
* 400ppm : atmospheric
|
175
|
+
* 1000ppm : your programming speed decreases
|
176
|
+
* 1500ppm : tomatoes ((*🍅*)) may grow well
|
177
|
+
* > 2000ppm : sleepy, headache
|
178
|
+
* > 40000ppm : 💀
|
179
|
+
|
180
|
+
= today's demo
|
181
|
+
* my device keeps taking CO(('sub:2')) concentration
|
182
|
+
* I will prove that it is due to CO(('sub:2')) if someone slept while I speaking
|
183
|
+
|
184
|
+
= so many troubles in IoT
|
185
|
+
|
186
|
+
= so many troubles in IoT
|
187
|
+
* peripheral equipments (☆)
|
188
|
+
* circuit and wiring design
|
189
|
+
* printed circuit board = PCB
|
190
|
+
* soldering (☆)
|
191
|
+
* C, mruby and mruby/c (☆)
|
192
|
+
* network
|
193
|
+
☆...I will explain these topics today
|
194
|
+
|
195
|
+
= peripheral equipments
|
196
|
+
|
197
|
+
= peripheral equipments
|
198
|
+
* it is very important to check the following before writing application code
|
199
|
+
* equipment like sensor or communication module works as its spec sheet
|
200
|
+
* whether the equipment is not broken (sometimes broken by soldering 😭)
|
201
|
+
* unless you will regret
|
202
|
+
* so...
|
203
|
+
|
204
|
+
= peripheral equipments
|
205
|
+
# image
|
206
|
+
# src = images/raspberrypi.jpg
|
207
|
+
# relative-height = 55
|
208
|
+
|
209
|
+
* Raspberry Pi & CRuby are great for pre-prototyping
|
210
|
+
* use breadboard or make PCB for test like this photo
|
211
|
+
|
212
|
+
= peripheral equipments
|
213
|
+
ex) CRuby for serial communication test
|
214
|
+
# enscript ruby
|
215
|
+
# notice this is CRuby for RasPi
|
216
|
+
require 'rubyserial'
|
217
|
+
require 'timeout'
|
218
|
+
BAUDRATE = 9600 # match with your instrument
|
219
|
+
sp = Serial.new '/dev/serial0', BAUDRATE, 8
|
220
|
+
loop do
|
221
|
+
puts '[command]'
|
222
|
+
command = gets
|
223
|
+
sp.write command.sub("\n", "\r") # replace LF if needed
|
224
|
+
sleep 0.1
|
225
|
+
result = ''
|
226
|
+
begin
|
227
|
+
Timeout.timeout(10) do
|
228
|
+
loop do
|
229
|
+
line = sp.read(128)
|
230
|
+
break if line == '' && result != ''
|
231
|
+
result << line
|
232
|
+
sleep 0.1
|
233
|
+
puts '=> ' + result
|
234
|
+
rescue Timeout::Error
|
235
|
+
puts 'timeout!'
|
236
|
+
|
237
|
+
= peripheral equipments
|
238
|
+
ex) CRuby for serial communication test
|
239
|
+
# enscript bash
|
240
|
+
$ serial_communication_test.rb
|
241
|
+
[command]
|
242
|
+
AT # command
|
243
|
+
=> OK # response
|
244
|
+
[command]
|
245
|
+
AT+CIMI # command
|
246
|
+
=> 123456789012 # response
|
247
|
+
[command]
|
248
|
+
AT+XXX # command
|
249
|
+
=> error # response
|
250
|
+
|
251
|
+
= soldering
|
252
|
+
|
253
|
+
= soldering
|
254
|
+
# image
|
255
|
+
# src = images/unsoldered.jpg
|
256
|
+
# relative-width = 35
|
257
|
+
|
258
|
+
* it may work even if you leave a pin unsoldered on surface mounting
|
259
|
+
* because the pin touches circuit's surface
|
260
|
+
* then, it will not work one day
|
261
|
+
|
262
|
+
= soldering
|
263
|
+
# image
|
264
|
+
# src = images/unsoldered-2.png
|
265
|
+
# relative-width = 35
|
266
|
+
|
267
|
+
* discovering this kind of bug is much more difficult than software bug
|
268
|
+
* my teacher said\n"all the cause of failure, it is ((*impatience*))"
|
269
|
+
|
270
|
+
= what is mruby?
|
271
|
+
|
272
|
+
= what is mruby?
|
273
|
+
* github.com/mruby/mruby
|
274
|
+
* another implemantation of Ruby for embedded usage
|
275
|
+
* easily being called from C/C++
|
276
|
+
* ngx_mruby is a popular one
|
277
|
+
* good for command line tools as one-binary executable
|
278
|
+
|
279
|
+
= what is mruby/c?
|
280
|
+
|
281
|
+
= what is mruby/c?
|
282
|
+
* github.com/mrubyc/mrubyc
|
283
|
+
* yet another implementation of mruby
|
284
|
+
* `/c` symbolizes compact, concurrent and capability
|
285
|
+
* especially dedicated to one-chip microcontroller
|
286
|
+
|
287
|
+
= mruby and mruby/c
|
288
|
+
# RT
|
289
|
+
|
290
|
+
mruby, mruby/c
|
291
|
+
|
292
|
+
v1.0.0 in Jan 2014, v1.0 in Jan 2017
|
293
|
+
for general embedded software, for one-chip microcontroller
|
294
|
+
RAM < 400KB, RAM < 40KB
|
295
|
+
|
296
|
+
* sometimes mruby is still too big to run on microcontroller
|
297
|
+
|
298
|
+
= ((*both*)) mruby and mruby/c
|
299
|
+
* bytecodes are compiled by `mrbc` and VM executes the bytecode
|
300
|
+
# image
|
301
|
+
# src = images/mruby_and_mrubyc.png
|
302
|
+
# align = center
|
303
|
+
# relative-height = 100
|
304
|
+
|
305
|
+
= bytecode
|
306
|
+
* a kind of intermediate representation
|
307
|
+
* virtual machine dynamically interprets the bytecode and processes the program
|
308
|
+
# image
|
309
|
+
# src = images/bytecode.png
|
310
|
+
# align = center
|
311
|
+
# relative-width = 100
|
312
|
+
|
313
|
+
= mruby on microcontroller
|
314
|
+
* RTOS (Real-Time OS) manages mruby VMs. RTOS has features like multi tasking
|
315
|
+
# image
|
316
|
+
# src = images/mruby_and_mrubyc-mruby.png
|
317
|
+
# align = center
|
318
|
+
# relative-height = 100
|
319
|
+
|
320
|
+
= mruby/c on microcontroller
|
321
|
+
* mruby/c has its own mechanism to manage the runtime: ((*rrt0*))
|
322
|
+
# image
|
323
|
+
# src = images/mruby_and_mrubyc-mrubyc.png
|
324
|
+
# align = center
|
325
|
+
# relative-height = 100
|
326
|
+
|
327
|
+
= mruby/c - virtual machine (VM)
|
328
|
+
* much smaller than mruby's one
|
329
|
+
* that's why mruby/c runs on smaller RAM
|
330
|
+
* accordingly, mruby/c has ((*less*)) functionality than mruby
|
331
|
+
|
332
|
+
= how ((*less*))?
|
333
|
+
|
334
|
+
= how ((*less*))? - for example
|
335
|
+
* mruby/c doesn't have module, hence there is no Kernel module
|
336
|
+
* then you must wonder how can you `#puts`?
|
337
|
+
* in mruby/c, `#puts` is implemented in Object class
|
338
|
+
|
339
|
+
= how ((*less*))? - for example
|
340
|
+
* mruby/c doesn't have #send, #eval, nor #method_missing
|
341
|
+
* moreover, mruby/c neither have your favorite features like TracePoint nor RubyVM::AST 😞
|
342
|
+
|
343
|
+
= how ((*less*))? - actually
|
344
|
+
* the full list of mruby/c's classes
|
345
|
+
* Array, FalseClass, Fixnum, Float, Hash, Math, Mutex, NilClass, Numeric, Object, Proc, Range, String, Symbol, TrueClass, VM
|
346
|
+
|
347
|
+
= despite the fact,
|
348
|
+
* no problem in practical use of microcontroller
|
349
|
+
* as far as IoT go, mruby/c is enough Ruby as I expect
|
350
|
+
* we can fully develop firmwares with features of mruby/c
|
351
|
+
|
352
|
+
= how does mruby/c work
|
353
|
+
|
354
|
+
= how does mruby/c work
|
355
|
+
# enscript bash
|
356
|
+
~/sample_project
|
357
|
+
├── main.c
|
358
|
+
├── mrblib
|
359
|
+
│ ├── task_1.rb
|
360
|
+
│ └── task_2.rb
|
361
|
+
└── src
|
362
|
+
├── task_1.c
|
363
|
+
└── task_2.c
|
364
|
+
* task_*.c are compliled code from task_*.rb
|
365
|
+
|
366
|
+
= how does mruby/c work
|
367
|
+
# enscript c
|
368
|
+
/* main.c */
|
369
|
+
#include "src/task_1.c"
|
370
|
+
#include "src/task_2.c"
|
371
|
+
// use 30KB RAM for VMs in this case
|
372
|
+
#define MEMORY_SIZE (1024*30)
|
373
|
+
static uint8_t memory_pool[MEMORY_SIZE];
|
374
|
+
int main(void) {
|
375
|
+
mrbc_init(memory_pool, MEMORY_SIZE);
|
376
|
+
mrbc_create_task(task_1, 0);
|
377
|
+
mrbc_create_task(task_2, 0);
|
378
|
+
mrbc_run(); // 2 tasks run concurrently!
|
379
|
+
return 0;
|
380
|
+
// we will not write `main loop` in main.c
|
381
|
+
}
|
382
|
+
|
383
|
+
= how does mruby/c work
|
384
|
+
* we can run easily multiple VMs with ((*concurrency*)) due to ((*rrt0*))
|
385
|
+
* you might be disappointed to know you have to write C
|
386
|
+
* yes, we have to write ((*main.c*))
|
387
|
+
* don't worry, it's almost boilerplate code
|
388
|
+
|
389
|
+
= how does mruby/c work
|
390
|
+
# enscript bash
|
391
|
+
~/mrubyc $ tree src -P *.h
|
392
|
+
src
|
393
|
+
├── alloc.h
|
394
|
+
├── c_array.h
|
395
|
+
...
|
396
|
+
├── console.h
|
397
|
+
├── errorcode.h
|
398
|
+
├── global.h
|
399
|
+
├── hal_posix
|
400
|
+
│ └── hal.h
|
401
|
+
├── hal_psoc5lp
|
402
|
+
│ └── hal.h
|
403
|
+
├── hal_esp32
|
404
|
+
│ └── hal.h
|
405
|
+
├── load.h
|
406
|
+
├── mrubyc.h
|
407
|
+
├── opcode.h
|
408
|
+
├── rrt0.h
|
409
|
+
├── static.h
|
410
|
+
├── symbol.h
|
411
|
+
├── value.h
|
412
|
+
├── vm.h
|
413
|
+
└── vm_config.h
|
414
|
+
|
415
|
+
= how does mruby/c work
|
416
|
+
# enscript bash
|
417
|
+
~/mrubyc $ tree src -P *.h
|
418
|
+
src
|
419
|
+
├── alloc.h
|
420
|
+
├── c_array.h
|
421
|
+
...
|
422
|
+
├── console.h
|
423
|
+
├── errorcode.h
|
424
|
+
├── global.h
|
425
|
+
├── hal_posix
|
426
|
+
│ └── hal.h # hal for POSIX
|
427
|
+
├── hal_psoc5lp
|
428
|
+
│ └── hal.h # hal for PSoC5LP
|
429
|
+
├── hal_esp32
|
430
|
+
│ └── hal.h # hal for ESP32
|
431
|
+
├── load.h
|
432
|
+
├── mrubyc.h
|
433
|
+
├── opcode.h
|
434
|
+
├── rrt0.h
|
435
|
+
├── static.h
|
436
|
+
├── symbol.h
|
437
|
+
├── value.h
|
438
|
+
├── vm.h
|
439
|
+
└── vm_config.h
|
440
|
+
|
441
|
+
= how does mruby/c work
|
442
|
+
# enscript bash
|
443
|
+
~/mrubyc $ tree src -P *.h
|
444
|
+
src
|
445
|
+
├── alloc.h
|
446
|
+
├── c_array.h
|
447
|
+
...
|
448
|
+
├── console.h
|
449
|
+
├── errorcode.h
|
450
|
+
├── global.h
|
451
|
+
├── hal_posix
|
452
|
+
│ └── hal.h
|
453
|
+
├── hal_psoc5lp
|
454
|
+
│ └── hal.h
|
455
|
+
├── hal_esp32
|
456
|
+
│ └── hal.h
|
457
|
+
├── load.h
|
458
|
+
├── mrubyc.h
|
459
|
+
├── opcode.h
|
460
|
+
├── rrt0.h # runtime scheduler
|
461
|
+
├── static.h
|
462
|
+
├── symbol.h
|
463
|
+
├── value.h
|
464
|
+
├── vm.h
|
465
|
+
└── vm_config.h
|
466
|
+
|
467
|
+
= how does mruby/c work
|
468
|
+
# enscript bash
|
469
|
+
~/mrubyc $ tree src -P *.h
|
470
|
+
src
|
471
|
+
├── alloc.h
|
472
|
+
├── c_array.h
|
473
|
+
...
|
474
|
+
├── console.h
|
475
|
+
├── errorcode.h
|
476
|
+
├── global.h
|
477
|
+
├── hal_posix
|
478
|
+
│ └── hal.h
|
479
|
+
├── hal_psoc5lp
|
480
|
+
│ └── hal.h
|
481
|
+
├── hal_esp32
|
482
|
+
│ └── hal.h
|
483
|
+
├── load.h
|
484
|
+
├── mrubyc.h
|
485
|
+
├── opcode.h
|
486
|
+
├── rrt0.h
|
487
|
+
├── static.h
|
488
|
+
├── symbol.h
|
489
|
+
├── value.h # this gives you hints about variable
|
490
|
+
├── vm.h
|
491
|
+
└── vm_config.h
|
492
|
+
|
493
|
+
= how does mruby/c work
|
494
|
+
# enscript bash
|
495
|
+
~/mrubyc $ tree src -P *.h
|
496
|
+
src
|
497
|
+
├── alloc.h
|
498
|
+
├── c_array.h
|
499
|
+
...
|
500
|
+
├── console.h
|
501
|
+
├── errorcode.h
|
502
|
+
├── global.h
|
503
|
+
├── hal_posix
|
504
|
+
│ └── hal.h
|
505
|
+
├── hal_psoc5lp
|
506
|
+
│ └── hal.h
|
507
|
+
├── hal_esp32
|
508
|
+
│ └── hal.h
|
509
|
+
├── load.h
|
510
|
+
├── mrubyc.h
|
511
|
+
├── opcode.h
|
512
|
+
├── rrt0.h
|
513
|
+
├── static.h
|
514
|
+
├── symbol.h
|
515
|
+
├── value.h
|
516
|
+
├── vm.h
|
517
|
+
└── vm_config.h # edit this if needed
|
518
|
+
|
519
|
+
= debugging
|
520
|
+
|
521
|
+
= debugging
|
522
|
+
* we can neither do step execution nor look into memory to see variables when we use mruby/c in general
|
523
|
+
* we should prepare a way of debugging before writing app code
|
524
|
+
* let's go with ((*old-fashioned 'print debug'*)). it'll be almost enough
|
525
|
+
|
526
|
+
= debugging
|
527
|
+
# enscript c
|
528
|
+
/* a part of main.c */
|
529
|
+
// create serial console with UART for debug print
|
530
|
+
static void c_debugprint(mrb_vm *vm, mrb_value *v, int argc){
|
531
|
+
int total, used, free, fragment;
|
532
|
+
mrbc_alloc_statistics(&total, &used, &free, &fragment);
|
533
|
+
console_printf(
|
534
|
+
"Memory total:%d, used:%d, free:%d, fragment:%d\n",
|
535
|
+
total, used, free, fragment);
|
536
|
+
unsigned char *key = GET_STRING_ARG(1);
|
537
|
+
unsigned char *value = GET_STRING_ARG(2);
|
538
|
+
console_printf("%s:%s\n", key, value);
|
539
|
+
}
|
540
|
+
int main(void) {
|
541
|
+
...
|
542
|
+
mrbc_define_method(0, mrbc_class_object, "debugprint", c_debugprint);
|
543
|
+
...
|
544
|
+
}
|
545
|
+
|
546
|
+
= debugging
|
547
|
+
# enscript ruby
|
548
|
+
# mruby
|
549
|
+
pi = 3.14
|
550
|
+
debugprint('Pi', pi.to_s)
|
551
|
+
|
552
|
+
=> # print in serial console like 'PuTTY' connecting USB
|
553
|
+
Memory total:30000, used:20000, free:10000, fragment:3
|
554
|
+
Pi:3.14
|
555
|
+
|
556
|
+
= actual source code
|
557
|
+
|
558
|
+
= actual source code
|
559
|
+
(('tag:center'))\n\n\n\n
|
560
|
+
github.com/hasumikin/co2-demo
|
561
|
+
|
562
|
+
= actual source code
|
563
|
+
# enscript bash
|
564
|
+
~/co2-demo
|
565
|
+
├── main.c
|
566
|
+
└── mrblib
|
567
|
+
├── loops
|
568
|
+
│ ├── master.rb
|
569
|
+
│ └── slave.rb
|
570
|
+
└── models
|
571
|
+
├── co2.rb
|
572
|
+
├── led.rb
|
573
|
+
└── thermistor.rb
|
574
|
+
|
575
|
+
= actual source code
|
576
|
+
# enscript ruby
|
577
|
+
# loops/master.rb
|
578
|
+
$co2 = Co2.new # Makes it global so that another task
|
579
|
+
# can use it
|
580
|
+
led = Led.new(19) # 19 is a pin number which LED connects
|
581
|
+
while true
|
582
|
+
co2 = $co2.concentrate
|
583
|
+
if co2 > 2000 # When CO2 reaches fatal level
|
584
|
+
5.times do # Turning LED on and off
|
585
|
+
led.turn_on
|
586
|
+
sleep 0.1
|
587
|
+
led.turn_off
|
588
|
+
sleep 0.1
|
589
|
+
end
|
590
|
+
elsif co2 > 1500 # CO2 reaches warning level
|
591
|
+
led.turn_on # Just keeps turn it on
|
592
|
+
sleep 1
|
593
|
+
else # Safe level
|
594
|
+
led.turn_off # Turns off
|
595
|
+
sleep 1
|
596
|
+
end
|
597
|
+
end
|
598
|
+
|
599
|
+
= actual source code
|
600
|
+
(('tag:center'))\n\n\n\n
|
601
|
+
how does ((*Led#trun_on*)) work?
|
602
|
+
|
603
|
+
= actual source code
|
604
|
+
# enscript ruby
|
605
|
+
# models/led.rb
|
606
|
+
class Led
|
607
|
+
def initialize(pin)
|
608
|
+
@pin = pin
|
609
|
+
gpio_init_output(@pin)
|
610
|
+
turn_off
|
611
|
+
end
|
612
|
+
def turn_on
|
613
|
+
gpio_set_level(@pin, 1)
|
614
|
+
end
|
615
|
+
|
616
|
+
= actual source code
|
617
|
+
# enscript c
|
618
|
+
/* a part of main.c */
|
619
|
+
#include "models/led.c"
|
620
|
+
static void c_gpio_init_output(mrb_vm *vm, mrb_value *v,
|
621
|
+
int argc) {
|
622
|
+
int pin = GET_INT_ARG(1);
|
623
|
+
gpio_set_direction(pin, GPIO_MODE_OUTPUT);
|
624
|
+
}
|
625
|
+
static void c_gpio_set_level(mrb_vm *vm, mrb_value *v,
|
626
|
+
int argc){
|
627
|
+
int pin = GET_INT_ARG(1);
|
628
|
+
int level = GET_INT_ARG(2);
|
629
|
+
gpio_set_level(pin, level);
|
630
|
+
}
|
631
|
+
int main(void){
|
632
|
+
...
|
633
|
+
mrbc_define_method(0, mrbc_class_object, "gpio_init_output",
|
634
|
+
c_gpio_init_output);
|
635
|
+
mrbc_define_method(0, mrbc_class_object, "gpio_set_level",
|
636
|
+
c_gpio_set_level);
|
637
|
+
...
|
638
|
+
}
|
639
|
+
|
640
|
+
= actual source code
|
641
|
+
# enscript c
|
642
|
+
/* a part of main.c */
|
643
|
+
#include "models/co2.c"
|
644
|
+
static void c_get_co2(struct VM *vm, mrbc_value v[], int argc){
|
645
|
+
uint8_t command[] = { // Command to take CO2
|
646
|
+
0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79
|
647
|
+
};
|
648
|
+
uart_write_bytes(uart_num, (const char*)command, 9);
|
649
|
+
// ↑Write then ↓Read data
|
650
|
+
uint8_t data[10];
|
651
|
+
int length = 0;
|
652
|
+
ESP_ERROR_CHECK(uart_get_buffered_data_len(uart_num, (size_t*)&length));
|
653
|
+
length = uart_read_bytes(uart_num, data, length, 10);
|
654
|
+
int i;
|
655
|
+
mrb_value array = mrbc_array_new( vm, 9 ); // mrubyc's variable
|
656
|
+
for( i = 0; i < 9; i++ ) {
|
657
|
+
mrb_value value = mrb_fixnum_value(data[i]);
|
658
|
+
mrbc_array_set( &array, i, &value ); // Adding a value to array
|
659
|
+
}
|
660
|
+
SET_RETURN(array); // Returning the array to mruby
|
661
|
+
}
|
662
|
+
int main(void){
|
663
|
+
...
|
664
|
+
mrbc_define_method(0, mrbc_class_object, "get_co2", c_get_co2);
|
665
|
+
...
|
666
|
+
}
|
667
|
+
|
668
|
+
= actual source code
|
669
|
+
# enscript ruby
|
670
|
+
# models/co2.rb
|
671
|
+
class Co2
|
672
|
+
def concentrate
|
673
|
+
res = get_co2
|
674
|
+
# checks if the sensor works
|
675
|
+
if res[0] == 255 && res[1] == 134
|
676
|
+
res[2] * 256 + res[3]
|
677
|
+
else
|
678
|
+
0
|
679
|
+
end
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
= actual source code
|
684
|
+
* by the way,
|
685
|
+
* C function can return String instead of mruby/c Array
|
686
|
+
* `mrbc_array_new` will allocate larger memory than `mrbc_string_new`
|
687
|
+
* so, you can use String instead of Array if memory becomes short
|
688
|
+
|
689
|
+
= actual source code
|
690
|
+
# enscript ruby
|
691
|
+
# loops/slave.rb
|
692
|
+
while true
|
693
|
+
co2 = $co2.concentrate
|
694
|
+
temperature = $thermistor.temperature
|
695
|
+
if co2 > 0
|
696
|
+
data = "co2=#{co2}&temperature=#{temperature}"
|
697
|
+
puts "DATASEND:#{data}"
|
698
|
+
sleep 300
|
699
|
+
else
|
700
|
+
sleep 3
|
701
|
+
end
|
702
|
+
end
|
703
|
+
|
704
|
+
= development environment
|
705
|
+
|
706
|
+
= development environment
|
707
|
+
* PSoC Creator for PSoC5LP
|
708
|
+
# image
|
709
|
+
# src = images/IDE.png
|
710
|
+
# align = center
|
711
|
+
# relative-width = 100
|
712
|
+
|
713
|
+
= development environment
|
714
|
+
* the env depends on microcontroller
|
715
|
+
* IDE is your env if you use ((*PSoC5LP*))
|
716
|
+
* you can code mruby on any text editor
|
717
|
+
* IDE is almost mandatory to configure hardware
|
718
|
+
* terminal based work is the one if you use ((*ESP32*))
|
719
|
+
|
720
|
+
= dev tools for mruby/c
|
721
|
+
|
722
|
+
= dev tools for mruby/c
|
723
|
+
* mrubyc-utils
|
724
|
+
* mrubyc-test
|
725
|
+
* mrubyc-debugger
|
726
|
+
|
727
|
+
= mrubyc-utils
|
728
|
+
* github.com/hasumikin/mrubyc-utils
|
729
|
+
* one-binary tool made with mruby
|
730
|
+
* helps to install boilerplate of application
|
731
|
+
* shows mruby/c's classes and methods
|
732
|
+
|
733
|
+
= mrubyc-utils
|
734
|
+
your_project $ mrubyc-utils --help
|
735
|
+
Usage: mrubyc-utils COMMAND [ARGS]
|
736
|
+
|
737
|
+
install Install mruby/c repo into your local and setup templates.
|
738
|
+
Please run this command at the top directory
|
739
|
+
of your firmware project.
|
740
|
+
update Update mruby/c repo to the newest **master** branch.
|
741
|
+
checkout Checkout specified tag or commit of mruby/c repo.
|
742
|
+
-t | --tag [required] You can specify anything that
|
743
|
+
`git checkout` will accept.
|
744
|
+
tag Show all tags of mruby/c repogitory that you installed.
|
745
|
+
classes Show all the classes that are defined in
|
746
|
+
mruby/c's virtual machine.
|
747
|
+
methods Show all the methods that are available
|
748
|
+
in a class of mruby/c.
|
749
|
+
-c | --class [required] You have to specify class name
|
750
|
+
compile Compile your mruby source into C byte code.
|
751
|
+
This command is for PSoC Creator project. Use make command instead
|
752
|
+
if your project is dedicated to ESP32 or POSIX
|
753
|
+
-w | --watch [optional] Monitoring loop runs and will
|
754
|
+
compile mruby source every time you touched it.
|
755
|
+
|
756
|
+
-v | --version Show version.
|
757
|
+
-h | --help Show usage. (this message)
|
758
|
+
|
759
|
+
Dependencies:
|
760
|
+
git
|
761
|
+
mrbc (mruby compiler)
|
762
|
+
|
763
|
+
= mrubyc-utils
|
764
|
+
your_project $ mrubyc-utils classes
|
765
|
+
- Array
|
766
|
+
- FalseClass
|
767
|
+
- Fixnum
|
768
|
+
- Float
|
769
|
+
- Hash
|
770
|
+
- Math
|
771
|
+
- Mutex
|
772
|
+
- NilClass
|
773
|
+
- Numeric
|
774
|
+
- Object
|
775
|
+
- Proc
|
776
|
+
- Range
|
777
|
+
- String
|
778
|
+
- Symbol
|
779
|
+
- TrueClass
|
780
|
+
- VM
|
781
|
+
|
782
|
+
= mrubyc-utils
|
783
|
+
your_project $ mrubyc-utils methods --class=array
|
784
|
+
Array
|
785
|
+
- + - inspect
|
786
|
+
- << - join
|
787
|
+
- [] - last
|
788
|
+
- []= - length
|
789
|
+
- at - max
|
790
|
+
- clear - min
|
791
|
+
- collect - minmax
|
792
|
+
- collect! - new
|
793
|
+
- count - pop
|
794
|
+
- delete_at - push
|
795
|
+
- dup - shift
|
796
|
+
- each - size
|
797
|
+
- each_index - to_s
|
798
|
+
- each_with_index - unshift
|
799
|
+
- empty? < Object
|
800
|
+
- first - !
|
801
|
+
- index ...
|
802
|
+
|
803
|
+
= mrubyc-test
|
804
|
+
* github.com/mrubyc/mrubyc-test
|
805
|
+
* unit testing framework
|
806
|
+
* RubyGem implemented with CRuby instead of mruby
|
807
|
+
* supports stub and mock
|
808
|
+
* official tool of mruby/c dev team
|
809
|
+
|
810
|
+
= mrubyc-test
|
811
|
+
* gathers information of test cases by CRuby metaprogramming power
|
812
|
+
* generates stub and mock methods
|
813
|
+
* makes all-in-one script: ((*test.rb*))
|
814
|
+
# image
|
815
|
+
# src = images/how-mrubyc-test-works.png
|
816
|
+
# align = center
|
817
|
+
# relative-width = 100
|
818
|
+
|
819
|
+
= mrubyc-debugger
|
820
|
+
* github.com/hasumikin/mrubyc-debugger
|
821
|
+
* RubyGem
|
822
|
+
* debugger for infinite loop
|
823
|
+
|
824
|
+
= (anime gif DEMO)
|
825
|
+
(('tag:center'))\n\n\n\n
|
826
|
+
github.com/hasumikin/\nmrubyc-debugger
|
827
|
+
|
828
|
+
= summary
|
829
|
+
|
830
|
+
= summary
|
831
|
+
* mruby/c is the smallest implementation of Ruby
|
832
|
+
|
833
|
+
= summary
|
834
|
+
* mruby/c is the smallest implementation of Ruby
|
835
|
+
* we can write firmwares for microcontrollers with mruby/c
|
836
|
+
|
837
|
+
= summary
|
838
|
+
* mruby/c is the smallest implementation of Ruby
|
839
|
+
* we can write firmwares for microcontrollers with mruby/c
|
840
|
+
* it has a short history though, it's ready for production with the Rubyish ecosystem like testing tool
|
841
|
+
|
842
|
+
= (DEMO)
|
843
|
+
(('tag:center'))\n\n\n\n
|
844
|
+
CO(('sub:2'))
|
845
|
+
|
846
|
+
= (added after conference)
|
847
|
+
# image
|
848
|
+
# src = images/co2_demo.png
|
849
|
+
# align = center
|
850
|
+
# relative-height = 95
|
851
|
+
|
852
|
+
= (added after conference)
|
853
|
+
(('tag:center'))\n\n\n\n
|
854
|
+
the ventilation facility\nof Browar Lubicz is pretty good 👍
|
855
|
+
|
856
|
+
= conclusion
|
857
|
+
|
858
|
+
= conclusion
|
859
|
+
(('tag:center'))\n\n\n\n
|
860
|
+
(('tag:x-large:You should refresh air'))
|
861
|
+
|
862
|
+
= thank you!
|
863
|
+
# image
|
864
|
+
# src = images/juji-asahi.jpg
|
865
|
+
# align = center
|
866
|
+
# relative-height = 95
|
data/pdf/RubyConfPoland2019-mrubyc---The-smallest-Ruby-implementation-for-microcontrollers.pdf
ADDED
Binary file
|
data/theme.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# puts font_families.sort
|
2
|
+
@xx_large_font_size = screen_size(10 * Pango::SCALE)
|
3
|
+
@x_large_font_size = screen_size(7.5 * Pango::SCALE)
|
4
|
+
@large_font_size = screen_size(6 * Pango::SCALE)
|
5
|
+
@normal_font_size = screen_size(4.5 * Pango::SCALE)
|
6
|
+
@small_font_size = screen_size(4 * Pango::SCALE)
|
7
|
+
@x_small_font_size = screen_size(3.5 * Pango::SCALE)
|
8
|
+
@xx_small_font_size = screen_size(2.8 * Pango::SCALE)
|
9
|
+
|
10
|
+
@default_headline_line_color = '#888888'
|
11
|
+
@font_family = find_font_family('Rockwell')
|
12
|
+
@foreground = "#d9333f" # タイトルスライドの文字色
|
13
|
+
#@background = "#000000"
|
14
|
+
|
15
|
+
@table_frame_color = "#ffffff"
|
16
|
+
@table_fill_color = "#0f0428"
|
17
|
+
@table_body_frame_color = "#ffffff"
|
18
|
+
@table_body_fill_color = "#3f3468"
|
19
|
+
@table_head_frame_color = "#ffffff"
|
20
|
+
@table_head_fill_color = "#rf0428"
|
21
|
+
|
22
|
+
@monospace_font_family = 'Ricty Discord'
|
23
|
+
@preformatted_fill_color = '#000000'
|
24
|
+
# @preformatted_centering = true
|
25
|
+
@space = screen_y(1)
|
26
|
+
|
27
|
+
include_theme('default')
|
28
|
+
|
29
|
+
match(Slide, HeadLine) do |heads|
|
30
|
+
heads.prop_set("size", @large_font_size)
|
31
|
+
heads.prop_set("weight", "normal")
|
32
|
+
set_font_family(heads)
|
33
|
+
end
|
34
|
+
|
35
|
+
match Slide do |slides|
|
36
|
+
slides.each do |slide|
|
37
|
+
# スライドの文字色
|
38
|
+
slide.prop_set("foreground", "#fef263")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
#@title_background_color = "red"
|
43
|
+
#include_theme("title-background-color")
|
44
|
+
@title_slide_background_image = 'images/krkrb-main.png'
|
45
|
+
include_theme("title-slide-background-image")
|
46
|
+
|
47
|
+
#@slide_logo_image = 'images/NEW_ML_LOGO.png'
|
48
|
+
#include_theme('slide-logo')
|
49
|
+
|
50
|
+
@slide_background_image = 'images/slide-background.png'
|
51
|
+
include_theme("slide-background-image")
|
52
|
+
|
53
|
+
@item_image = 'images/mark32.png'
|
54
|
+
|
55
|
+
include_theme("default-item-mark")
|
56
|
+
|
57
|
+
add_image_path("rabbit-images")
|
58
|
+
|
59
|
+
slide_body = [Slide, Body]
|
60
|
+
item_list_item = [ItemList, ItemListItem]
|
61
|
+
|
62
|
+
indent = 30
|
63
|
+
|
64
|
+
match(*(slide_body + (item_list_item * 1))) do |items|
|
65
|
+
name = "item1"
|
66
|
+
items.delete_pre_draw_proc_by_name(name)
|
67
|
+
items.delete_post_draw_proc_by_name(name)
|
68
|
+
draw_image_mark(items, @item_image, name, indent: indent)
|
69
|
+
end
|
70
|
+
|
71
|
+
match(*(slide_body + (item_list_item * 2))) do |items|
|
72
|
+
name = "item2"
|
73
|
+
items.delete_pre_draw_proc_by_name(name)
|
74
|
+
items.delete_post_draw_proc_by_name(name)
|
75
|
+
draw_image_mark(items, @item_image, name, indent: indent)
|
76
|
+
end
|
77
|
+
|
78
|
+
match(*(slide_body + (item_list_item * 3))) do |items|
|
79
|
+
name = "item3"
|
80
|
+
items.delete_pre_draw_proc_by_name(name)
|
81
|
+
items.delete_post_draw_proc_by_name(name)
|
82
|
+
draw_image_mark(items, @item_image, name, indent: indent)
|
83
|
+
end
|
84
|
+
|
85
|
+
enum_list_item = [EnumList, EnumListItem]
|
86
|
+
|
87
|
+
match(*(slide_body + enum_list_item + item_list_item)) do |items|
|
88
|
+
name = "enum-item1"
|
89
|
+
items.delete_pre_draw_proc_by_name(name)
|
90
|
+
items.delete_post_draw_proc_by_name(name)
|
91
|
+
draw_image_mark(items, @item_image, name, indent: indent)
|
92
|
+
end
|
93
|
+
|
94
|
+
match(*(slide_body + enum_list_item + (item_list_item * 2))) do |items|
|
95
|
+
name = "enum-item2"
|
96
|
+
items.delete_pre_draw_proc_by_name(name)
|
97
|
+
items.delete_post_draw_proc_by_name(name)
|
98
|
+
draw_image_mark(items, @item_image, name, indent: indent)
|
99
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rabbit-slide-hasumikin-RubyConfPoland2019
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2019.05.14
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- HASUMI Hitoshi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rabbit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.2
|
27
|
+
description: |-
|
28
|
+
The slide for [THE RUBY CONFERENCE OF CRACOW 2019](https://krk-rb.pl/) by [hasumkin](https://github.com/hasumikin)
|
29
|
+
|
30
|
+
It will cover:
|
31
|
+
|
32
|
+
- Introducing Ruby for microcontrollers and microcontrollers themselves
|
33
|
+
- Things in common and difference between mruby and mruby/c
|
34
|
+
- How mruby/c works
|
35
|
+
- Development sorroundings
|
36
|
+
- Some actual source code of firmware application
|
37
|
+
email:
|
38
|
+
- hasumikin@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- ".rabbit"
|
44
|
+
- README.rd
|
45
|
+
- Rakefile
|
46
|
+
- config.yaml
|
47
|
+
- images/IDE.png
|
48
|
+
- images/bytecode.png
|
49
|
+
- images/co2_demo.png
|
50
|
+
- images/collage01.jpg
|
51
|
+
- images/esp32.jpg
|
52
|
+
- images/hasumi.jpg
|
53
|
+
- images/how-mrubyc-test-works.png
|
54
|
+
- images/juji-asahi.jpg
|
55
|
+
- images/kamos.jpg
|
56
|
+
- images/krkrb-main.png
|
57
|
+
- images/krkrb-main.svg
|
58
|
+
- images/krkrb-main.svg.png
|
59
|
+
- images/m1.png
|
60
|
+
- images/m2.png
|
61
|
+
- images/mark32.png
|
62
|
+
- images/mark48.png
|
63
|
+
- images/mark64.png
|
64
|
+
- images/monstarlab.png
|
65
|
+
- images/monstarlab_global.png
|
66
|
+
- images/mruby_and_mrubyc-mruby.png
|
67
|
+
- images/mruby_and_mrubyc-mrubyc.png
|
68
|
+
- images/mruby_and_mrubyc.png
|
69
|
+
- images/psoc5lp_chip.jpg
|
70
|
+
- images/raspberrypi.jpg
|
71
|
+
- images/slide-background.png
|
72
|
+
- images/unsoldered-2.png
|
73
|
+
- images/unsoldered.jpg
|
74
|
+
- images/松江城_Matsue.rb.16x9.jpg
|
75
|
+
- images/松江城_Matsue.rb.jpg
|
76
|
+
- mrubyc---The-smallest-Ruby-implementation-for-microcontrollers.rab
|
77
|
+
- pdf/RubyConfPoland2019-mrubyc---The-smallest-Ruby-implementation-for-microcontrollers.pdf
|
78
|
+
- theme.rb
|
79
|
+
homepage: http://slide.rabbit-shocker.org/authors/hasumikin/RubyConfPoland2019/
|
80
|
+
licenses: []
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubygems_version: 3.0.3
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: mrubyc - The smallest Ruby implementation for microcontrollers
|
101
|
+
test_files: []
|