-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo2.c
67 lines (52 loc) · 903 Bytes
/
demo2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "mruby.h"
#include "mruby/proc.h"
#include "mruby/data.h"
#include "mruby/compile.h"
#include "mruby/string.h"
#include "mruby/numeric.h"
#include <math.h>
#include <stdlib.h>
mrb_state *mrb;
void TIM2_IRQHandler ( void )
{
/* <ruby->
checked = @rs_timer.check
case @flg2
when 0
@green.toggle
@flg2 = 1
when 1
@orange.toggle
@flg2 = 2
when 2
@red.toggle
@flg2 = 3
when 3
@blue.toggle
@flg2 = 0
end
GC.start
<-ruby> */
}
int main( void )
{
mrb = mrb_open();
if (mrb == NULL) {
return 0;
}
/* <ruby->
GC.interval_ratio = 20
GC.step_ratio = 200
@red = Led.new(Led::RED)
@blue = Led.new(Led::BLUE)
@green = Led.new(Led::GREEN)
@orange = Led.new(Led::ORANGE)
@rs_timer = RsTimer.new
@rs_timer.interval(1000)
@rs_timer.enable
@flg2 = 0
<-ruby> */
while(1) continue;
mrb_close(mrb);
return(0);
}