summaryrefslogtreecommitdiff
path: root/python-smartphone-connector.spec
blob: 9b95fab8c4ffb3c4c6c9e85241bd6ee61313dec4 (plain)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
%global _empty_manifest_terminate_build 0
Name:		python-smartphone-connector
Version:	0.0.115
Release:	1
Summary:	Talk to a socketio server
License:	MIT License
URL:		https://github.com/lebalz/smartphone-connector
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/98/d6/96115de4911fc7c10caf0d969779562a80b85f78417f4437927a03d98dcf/smartphone_connector-0.0.115.tar.gz
BuildArch:	noarch

Requires:	python3-socketio[client]

%description
# Smartphone Connector

This simple package exposes methods to interact with smartphones connected to a [socket.io server](https://github.com/lebalz/socketio_server) instance.

## Examples

[All examples and scripts on GitHub](https://github.com/lebalz/smartphone-connector/blob/master/examples/)

### Draw 3x3 checker board

```py
from smartphone_connector import Connector
phone = Connector('https://io.lebalz.ch', 'FooBar')

# draw a 3x3 checker board
phone.set_grid([
    ['black','white','black'],
    ['white','black','white'],
    ['black','white','black']
], broadcast=True)

# print the letter A
phone.set_grid([
  [9,9,9,9],
  [9,0,0,9],
  [9,9,9,9],
  [9,0,0,9],
  [9,0,0,9],
])
```

results on all devices in the following screen.

When `broadcast` is set to `False` (default), only the `FooBar` devices display the checker board.

![checker board](checker_demo.png)

### Stream & display gyroscope data

```py
from smartphone_connector import Connector, GyroMsg
import matplotlib.pyplot as plt
phone = Connector('https://io.lebalz.ch', 'FooBar')
MAX_SAMPLES = 300

y = []
x = []
plt.show()


def on_gyro(data: GyroMsg):
    if len(x) > MAX_SAMPLES:
        x.pop(0)
        y.pop(0)

    x.append(data.time_stamp)
    y.append([data.alpha, data.beta, data.gamma])


def on_intervall():
    plt.clf()
    plt.plot(x, y)
    plt.pause(0.01)


phone.on_gyro = on_gyro
phone.subscribe(on_intervall, interval=0)
```

Displays gyroscope data from the smartphone on a Matplotlib-Plot.
![Gyroscope-Plot](assets/gyroscope.png)

## Package and upload to pip

@see [this tutorial](https://packaging.python.org/tutorials/packaging-projects/)

```sh
rm -rf build/ dist/ smartphone_connector.egg-info/ && \
python3 setup.py sdist bdist_wheel && \
python3 -m twine upload dist/*
```

## Changelog

- 0.0.115: fix audio path checking
- 0.0.113: fix reporting of `pos_x` and `pos_y` on collisions
- 0.0.111: support `timer` events from socketio_server
- 0.0.110: add method `report(value: int | float, report_type: str, to: '__GAME_RUNNER__')`
- 0.0.109: fix typo in `update_ellipse`
- 0.0.108: introduce `clean_playground` method to remove all sprites and lines from the current playground, but keep the playground config as is. And minor bug fixes.
- 0.0.107: can mix absolute and relative movements with `apply_movements` and `apply_movement`
- 0.0.106: add possibility to control movement distances
- 0.0.105: control repeats of movement sequences
- 0.0.104: add methods to apply movements to objects:
  ```py
  # single movement
  device.apply_movement(id='circle', direction=[1, 1], time_span=1, speed=3)
  # movement sequence
  with device.apply_movements(id='circle') as movement:
      movement(direction=[1, 0], time_span=1, speed=2)
      movement(direction=[-1, 0], time_span=1, speed=2)
  ```
  - adding example [playground_flappy.py](examples/playground_flappy.py)
- 0.0.103: change function annotation of `set_timeout(callback, time, repeat=1)` instead of `set_timeout(callback, interval, iteration_count=inf)`
- 0.0.102: add alias methods for `subscribe_async`: `set_timeout`, `schedule`, `execute_in`
- 0.0.101: introduce `move_to(id: str, pos: [x, y], via: [x, y])` method to make jumps easyier. Event `auto_movement_pos` is triggered when an auto movement within a sequence finished.
- 0.0.100: support image formats `.gif`, `.bmp`, `.webp`
- 0.0.99: introduce method `add_svg_to_playground(name: str, raw_svg: str)` to upload plain svg source text
- 0.0.98 fix iteration count
- 0.0.97: introduce sound - provide a `audio_tracks` source directory in `configure_playground` and start/stop sounds with `play_sound(name: str, id: Optional[str])` / `stop_sound(name: Optional[str], id: Optional[str])`
- 0.0.96 register multiple callback functions with `on(event, clbk)`
- 0.0.95 support `border_style` and `border_width` for sprites




%package -n python3-smartphone-connector
Summary:	Talk to a socketio server
Provides:	python-smartphone-connector
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-smartphone-connector
# Smartphone Connector

This simple package exposes methods to interact with smartphones connected to a [socket.io server](https://github.com/lebalz/socketio_server) instance.

## Examples

[All examples and scripts on GitHub](https://github.com/lebalz/smartphone-connector/blob/master/examples/)

### Draw 3x3 checker board

```py
from smartphone_connector import Connector
phone = Connector('https://io.lebalz.ch', 'FooBar')

# draw a 3x3 checker board
phone.set_grid([
    ['black','white','black'],
    ['white','black','white'],
    ['black','white','black']
], broadcast=True)

# print the letter A
phone.set_grid([
  [9,9,9,9],
  [9,0,0,9],
  [9,9,9,9],
  [9,0,0,9],
  [9,0,0,9],
])
```

results on all devices in the following screen.

When `broadcast` is set to `False` (default), only the `FooBar` devices display the checker board.

![checker board](checker_demo.png)

### Stream & display gyroscope data

```py
from smartphone_connector import Connector, GyroMsg
import matplotlib.pyplot as plt
phone = Connector('https://io.lebalz.ch', 'FooBar')
MAX_SAMPLES = 300

y = []
x = []
plt.show()


def on_gyro(data: GyroMsg):
    if len(x) > MAX_SAMPLES:
        x.pop(0)
        y.pop(0)

    x.append(data.time_stamp)
    y.append([data.alpha, data.beta, data.gamma])


def on_intervall():
    plt.clf()
    plt.plot(x, y)
    plt.pause(0.01)


phone.on_gyro = on_gyro
phone.subscribe(on_intervall, interval=0)
```

Displays gyroscope data from the smartphone on a Matplotlib-Plot.
![Gyroscope-Plot](assets/gyroscope.png)

## Package and upload to pip

@see [this tutorial](https://packaging.python.org/tutorials/packaging-projects/)

```sh
rm -rf build/ dist/ smartphone_connector.egg-info/ && \
python3 setup.py sdist bdist_wheel && \
python3 -m twine upload dist/*
```

## Changelog

- 0.0.115: fix audio path checking
- 0.0.113: fix reporting of `pos_x` and `pos_y` on collisions
- 0.0.111: support `timer` events from socketio_server
- 0.0.110: add method `report(value: int | float, report_type: str, to: '__GAME_RUNNER__')`
- 0.0.109: fix typo in `update_ellipse`
- 0.0.108: introduce `clean_playground` method to remove all sprites and lines from the current playground, but keep the playground config as is. And minor bug fixes.
- 0.0.107: can mix absolute and relative movements with `apply_movements` and `apply_movement`
- 0.0.106: add possibility to control movement distances
- 0.0.105: control repeats of movement sequences
- 0.0.104: add methods to apply movements to objects:
  ```py
  # single movement
  device.apply_movement(id='circle', direction=[1, 1], time_span=1, speed=3)
  # movement sequence
  with device.apply_movements(id='circle') as movement:
      movement(direction=[1, 0], time_span=1, speed=2)
      movement(direction=[-1, 0], time_span=1, speed=2)
  ```
  - adding example [playground_flappy.py](examples/playground_flappy.py)
- 0.0.103: change function annotation of `set_timeout(callback, time, repeat=1)` instead of `set_timeout(callback, interval, iteration_count=inf)`
- 0.0.102: add alias methods for `subscribe_async`: `set_timeout`, `schedule`, `execute_in`
- 0.0.101: introduce `move_to(id: str, pos: [x, y], via: [x, y])` method to make jumps easyier. Event `auto_movement_pos` is triggered when an auto movement within a sequence finished.
- 0.0.100: support image formats `.gif`, `.bmp`, `.webp`
- 0.0.99: introduce method `add_svg_to_playground(name: str, raw_svg: str)` to upload plain svg source text
- 0.0.98 fix iteration count
- 0.0.97: introduce sound - provide a `audio_tracks` source directory in `configure_playground` and start/stop sounds with `play_sound(name: str, id: Optional[str])` / `stop_sound(name: Optional[str], id: Optional[str])`
- 0.0.96 register multiple callback functions with `on(event, clbk)`
- 0.0.95 support `border_style` and `border_width` for sprites




%package help
Summary:	Development documents and examples for smartphone-connector
Provides:	python3-smartphone-connector-doc
%description help
# Smartphone Connector

This simple package exposes methods to interact with smartphones connected to a [socket.io server](https://github.com/lebalz/socketio_server) instance.

## Examples

[All examples and scripts on GitHub](https://github.com/lebalz/smartphone-connector/blob/master/examples/)

### Draw 3x3 checker board

```py
from smartphone_connector import Connector
phone = Connector('https://io.lebalz.ch', 'FooBar')

# draw a 3x3 checker board
phone.set_grid([
    ['black','white','black'],
    ['white','black','white'],
    ['black','white','black']
], broadcast=True)

# print the letter A
phone.set_grid([
  [9,9,9,9],
  [9,0,0,9],
  [9,9,9,9],
  [9,0,0,9],
  [9,0,0,9],
])
```

results on all devices in the following screen.

When `broadcast` is set to `False` (default), only the `FooBar` devices display the checker board.

![checker board](checker_demo.png)

### Stream & display gyroscope data

```py
from smartphone_connector import Connector, GyroMsg
import matplotlib.pyplot as plt
phone = Connector('https://io.lebalz.ch', 'FooBar')
MAX_SAMPLES = 300

y = []
x = []
plt.show()


def on_gyro(data: GyroMsg):
    if len(x) > MAX_SAMPLES:
        x.pop(0)
        y.pop(0)

    x.append(data.time_stamp)
    y.append([data.alpha, data.beta, data.gamma])


def on_intervall():
    plt.clf()
    plt.plot(x, y)
    plt.pause(0.01)


phone.on_gyro = on_gyro
phone.subscribe(on_intervall, interval=0)
```

Displays gyroscope data from the smartphone on a Matplotlib-Plot.
![Gyroscope-Plot](assets/gyroscope.png)

## Package and upload to pip

@see [this tutorial](https://packaging.python.org/tutorials/packaging-projects/)

```sh
rm -rf build/ dist/ smartphone_connector.egg-info/ && \
python3 setup.py sdist bdist_wheel && \
python3 -m twine upload dist/*
```

## Changelog

- 0.0.115: fix audio path checking
- 0.0.113: fix reporting of `pos_x` and `pos_y` on collisions
- 0.0.111: support `timer` events from socketio_server
- 0.0.110: add method `report(value: int | float, report_type: str, to: '__GAME_RUNNER__')`
- 0.0.109: fix typo in `update_ellipse`
- 0.0.108: introduce `clean_playground` method to remove all sprites and lines from the current playground, but keep the playground config as is. And minor bug fixes.
- 0.0.107: can mix absolute and relative movements with `apply_movements` and `apply_movement`
- 0.0.106: add possibility to control movement distances
- 0.0.105: control repeats of movement sequences
- 0.0.104: add methods to apply movements to objects:
  ```py
  # single movement
  device.apply_movement(id='circle', direction=[1, 1], time_span=1, speed=3)
  # movement sequence
  with device.apply_movements(id='circle') as movement:
      movement(direction=[1, 0], time_span=1, speed=2)
      movement(direction=[-1, 0], time_span=1, speed=2)
  ```
  - adding example [playground_flappy.py](examples/playground_flappy.py)
- 0.0.103: change function annotation of `set_timeout(callback, time, repeat=1)` instead of `set_timeout(callback, interval, iteration_count=inf)`
- 0.0.102: add alias methods for `subscribe_async`: `set_timeout`, `schedule`, `execute_in`
- 0.0.101: introduce `move_to(id: str, pos: [x, y], via: [x, y])` method to make jumps easyier. Event `auto_movement_pos` is triggered when an auto movement within a sequence finished.
- 0.0.100: support image formats `.gif`, `.bmp`, `.webp`
- 0.0.99: introduce method `add_svg_to_playground(name: str, raw_svg: str)` to upload plain svg source text
- 0.0.98 fix iteration count
- 0.0.97: introduce sound - provide a `audio_tracks` source directory in `configure_playground` and start/stop sounds with `play_sound(name: str, id: Optional[str])` / `stop_sound(name: Optional[str], id: Optional[str])`
- 0.0.96 register multiple callback functions with `on(event, clbk)`
- 0.0.95 support `border_style` and `border_width` for sprites




%prep
%autosetup -n smartphone_connector-0.0.115

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-smartphone-connector -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Thu Jun 08 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.115-1
- Package Spec generated