forked from in4lio/ev3dev-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ev3.yu-i
152 lines (119 loc) · 4.63 KB
/
ev3.yu-i
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
($import "app.yu")
($TITLE,,SWIG interface file.)
%module ev3
%include "cstring.i"
%include "stdint.i"
%include "typemaps.i"
%{
#include "../source/ev3/ev3.h"
#include "../source/ev3/ev3_led.h"
#include "../source/ev3/ev3_light.h"
#include "../source/ev3/ev3_port.h"
#include "../source/ev3/ev3_sensor.h"
#include "../source/ev3/ev3_tacho.h"
#include "../source/ev3/ev3_dc.h"
#include "../source/ev3/ev3_servo.h"
#include "../source/ev3/brick.h"
%}
%define ALLOC_OUTPUT_BUFFER(TYPEMAP,MAX)
%typemap(in,noblock=1,numinputs=0) TYPEMAP (char temp[MAX+1]) {
$1 = ($1_ltype) temp;
}
%enddef
/* String buffer without size is passed only for getting a port name */
ALLOC_OUTPUT_BUFFER( char *buf, 64 );
/* Unfortunately incompatible with %typemap( default ) size_t sz { $1 = DEFAULT_BUF_SIZE; } */
%cstring_output_maxsize( char *buf, size_t sz );
%include "./platform.h"
#ifdef SWIGPERL
/* because of the problem with SWIG_From_bool on the brick... */
#define bool int
#endif
%apply uint8_t *OUTPUT { uint8_t *sn };
%apply bool *OUTPUT { bool *buf };
%apply int *OUTPUT { int *buf };
%apply uint8_t *OUTPUT { uint8_t *buf };
%apply uint8_t *OUTPUT { byte *buf };
%apply uint32_t *OUTPUT { uint32_t *buf };
%apply uint32_t *OUTPUT { dword *buf };
%apply float *OUTPUT { float *buf };
%apply uint8_t *OUTPUT { FLAGS_T *flags };
%apply uint32_t { dword };
%apply uint8_t { byte };
%apply uint8_t { INX_T };
%apply uint8_t { FLAGS_T };
%apply uint8_t { POOL_T };
#ifdef SWIGRUBY
%typemap( out ) size_t, bool { $result = $1 ? Qtrue : Qfalse; };
%typemap( in ) bool { $1 = $input == Qtrue ? 1 : 0; };
#endif
%typemap( default ) uint8_t from { $1 = 0; };
%typemap( default ) dword defval { $1 = 0; };
%typemap( default ) float defval { $1 = 0.0; };
%typemap( default ) int defval { $1 = 0; };
($import stdlib)
($macro extern-c-begin ())
($macro extern-c-end ())
($macro var ( dec )extern ($dec);)
($macro var-init ( dec init )extern ($dec);)
/*
* ev3
*/
($extern-c-begin)
// CLIENT ////////////////////////////////////////
#if EV3_BRICK == 0
%rename( brick_addr ) ev3_brick_addr;
extern char *ev3_brick_addr;
%rename( brick_port ) ev3_brick_port;
extern uint16_t ev3_brick_port;
//////////////////////////////////////////////////
#endif
extern int ev3_init( void );
extern void ev3_uninit( void );
extern size_t ev3_write_binary( const char *fn, char *STRING, size_t LENGTH );
extern size_t ev3_write( const char *fn, char *value );
extern size_t ev3_write_bool( const char *fn, bool value );
extern size_t ev3_write_int( const char *fn, int value );
extern size_t ev3_write_dword( const char *fn, uint32_t value );
extern size_t ev3_write_byte( const char *fn, uint8_t value );
extern size_t ev3_write_float( const char *fn, float value );
extern size_t ev3_multi_write_binary( uint8_t *sn, uint16_t pos, const char *fn, char *STRING, size_t LENGTH );
extern size_t ev3_multi_write( uint8_t *sn, uint16_t pos, const char *fn, char *value );
extern size_t ev3_multi_write_bool( uint8_t *sn, uint16_t pos, const char *fn, bool value );
extern size_t ev3_multi_write_int( uint8_t *sn, uint16_t pos, const char *fn, int value );
extern size_t ev3_multi_write_dword( uint8_t *sn, uint16_t pos, const char *fn, uint32_t value );
extern size_t ev3_multi_write_byte( uint8_t *sn, uint16_t pos, const char *fn, uint8_t value );
extern size_t ev3_multi_write_float( uint8_t *sn, uint16_t pos, const char *fn, float value );
extern size_t ev3_read_binary( const char *fn, char *buf, size_t sz );
extern size_t ev3_read( const char *fn, char *buf, size_t sz );
#ifndef SWIGRUBY
extern size_t ev3_read_bool( const char *fn, bool *buf );
#endif
extern size_t ev3_read_int( const char *fn, int *buf );
extern size_t ev3_read_dword( const char *fn, uint32_t *buf );
extern size_t ev3_read_byte( const char *fn, uint8_t *buf );
extern size_t ev3_read_float( const char *fn, float *buf );
extern size_t ev3_listdir( const char *fn, char *buf, size_t sz );
extern size_t ev3_read_keys( uint8_t *buf );
extern bool ev3_poweroff( void );
enum {
EV3_KEY__NONE_ = 0,
EV3_KEY_UP = 0x01L,
EV3_KEY_DOWN = 0x02L,
EV3_KEY_LEFT = 0x04L,
EV3_KEY_RIGHT = 0x08L,
EV3_KEY_CENTER = 0x10L,
EV3_KEY_BACK = 0x20L,
};
#define DESC_LIMIT 64
#define DESC_VEC_LEN 4
($extern-c-end)
($import "tools.py")
($import { clip_h( "../source/ev3/ev3_led.yu-h" ) })
($import { clip_h( "../source/ev3/ev3_light.yu-h" ) })
($import { clip_h( "../source/ev3/ev3_port.yu-h" ) })
($import { clip_h( "../source/ev3/ev3_sensor.yu-h" ) })
($import { clip_h( "../source/ev3/ev3_tacho.yu-h" ) })
($import { clip_h( "../source/ev3/ev3_dc.yu-h" ) })
($import { clip_h( "../source/ev3/ev3_servo.yu-h" ) })
($import { clip_h( "../source/ev3/brick.yu-h" ) })