Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Μ
µnit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teckids
Projekt Hack-n-Fun
Libs
µnit
Commits
a4923a86
Verified
Commit
a4923a86
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
[WIP] Turn device list into buttons
parent
e50ec570
No related branches found
No related tags found
No related merge requests found
Pipeline
#76475
passed
3 years ago
Stage: prepare
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
companion/app.py
+22
-3
22 additions, 3 deletions
companion/app.py
companion/bluetooth.py
+3
-2
3 additions, 2 deletions
companion/bluetooth.py
companion/mynitcompanion.kv
+8
-3
8 additions, 3 deletions
companion/mynitcompanion.kv
with
33 additions
and
8 deletions
companion/app.py
+
22
−
3
View file @
a4923a86
from
kivy.app
import
App
from
kivy.logger
import
Logger
from
kivy.properties
import
ObjectProperty
from
kivy.uix.button
import
Button
from
kivy.uix.widget
import
Widget
from
bluetooth
import
MynitBluetooth
class
DeviceListWidget
(
Widget
):
app
=
ObjectProperty
()
device_buttons
=
None
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
_devices_buttons_map
=
{}
def
update_device_buttons
(
self
,
devices
):
Logger
.
debug
(
"
Updating device buttons
"
)
self
.
_devices_buttons_map
=
devices
self
.
device_buttons
.
clear_widgets
()
for
label
,
device
in
self
.
_devices_buttons_map
.
items
():
Logger
.
debug
(
"
Adding button for %s
"
%
label
)
btn
=
Button
(
text
=
label
)
self
.
device_buttons
.
add_widget
(
btn
)
class
MynitCompanionApp
(
App
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -14,7 +32,8 @@ class MynitCompanionApp(App):
self
.
_bluetooth
=
MynitBluetooth
(
self
)
def
update_device_list
(
self
,
devices
):
pass
self
.
widget
.
update_device_buttons
({
device
.
getAddress
():
device
for
device
in
devices
})
def
build
(
self
):
return
DeviceListWidget
(
app
=
self
)
self
.
widget
=
DeviceListWidget
()
return
self
.
widget
This diff is collapsed.
Click to expand it.
companion/bluetooth.py
+
3
−
2
View file @
a4923a86
...
...
@@ -20,11 +20,12 @@ class MynitBluetooth(BluetoothDispatcher):
self
.
_characteristics
=
None
,
None
Logger
.
info
(
"
Starting BLE scanning
"
)
self
.
start_scan
(
filters
=
[
ServiceUUIDFilter
(
_UART_SERVICE_UUID
)])
# self.start_scan(filters=[ServiceUUIDFilter(_UART_SERVICE_UUID)])
self
.
start_scan
()
def
on_device
(
self
,
device
,
rssi
,
advertisement
):
Logger
.
debug
(
"
BLE device discovered: %s
"
%
device
.
getAddress
())
self
.
stop_scan
()
if
device
not
in
self
.
_available_devices
:
Logger
.
info
(
"
New BLE device discovered: %s
"
%
device
.
getAddress
())
self
.
_available_devices
.
add
(
device
)
...
...
This diff is collapsed.
Click to expand it.
companion/mynitcompanion.kv
+
8
−
3
View file @
a4923a86
#:kivy 1.0.9
<DeviceListWidget>:
cols: 1
device_buttons: device_buttons
BoxLayout:
Label:
text: "Device List"
BoxLayout:
id: device_buttons
Label:
text: str(root.app._bluetooth._available_devices)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment