diff --git a/examples/meshtastic/lisp/group.lisp b/examples/meshtastic/lisp/group.lisp index 00842dc..f2138f5 100644 --- a/examples/meshtastic/lisp/group.lisp +++ b/examples/meshtastic/lisp/group.lisp @@ -13,6 +13,14 @@ "Adds passed PERSON (a PLIST) to QML item model. The model keys are: :radio-name :custom-name :node-num :unread :current" + (when (zerop (q< |count| ui:*group*)) + ;; special item 'Broadcast' + (qjs |addPerson| ui:*group* + (list :radio-name lora:*broadcast-name* + :custom-name (tr "Broadcast") + :node-num lora:+broadcast-id+ + :current (equal (app:setting :latest-receiver) + lora:*broadcast-name*)))) (qjs |addPerson| ui:*group* person)) (defun clear () @@ -31,18 +39,20 @@ (q> |visible| ui:*unread-messages* state)) (defun set-unread (name n) - (qjs |setUnread| ui:*group* - name n) - (when (plusp n) - (set-unread-state t))) + (unless (string= lora:*broadcast-name* name) + (qjs |setUnread| ui:*group* + name n) + (when (plusp n) + (set-unread-state t)))) (defun receiver-changed () (let ((curr-name (app:setting :latest-receiver))) - (app:change-setting curr-name 0 :sub-key :unread-messages) - (set-unread curr-name 0) - (dolist (name (radio-names)) - (x:when-it (app:setting name :unread-messages) - (unless (zerop x:it) - (return-from receiver-changed)))) - (set-unread-state nil))) + (unless (string= lora:*broadcast-name* curr-name) + (app:change-setting curr-name 0 :sub-key :unread-messages) + (set-unread curr-name 0) + (dolist (name (radio-names)) + (x:when-it (app:setting name :unread-messages) + (unless (zerop x:it) + (return-from receiver-changed)))) + (set-unread-state nil)))) diff --git a/examples/meshtastic/lisp/lora.lisp b/examples/meshtastic/lisp/lora.lisp index 85b83f8..99698e2 100644 --- a/examples/meshtastic/lisp/lora.lisp +++ b/examples/meshtastic/lisp/lora.lisp @@ -28,6 +28,9 @@ ;;; ini/send/receive +(defconstant +broadcast-id+ #xffffffff) +(defparameter *broadcast-name* "ffff") + (defvar *config-id* 0) (defvar *config-complete* nil) (defvar *notify-id* nil) @@ -162,9 +165,11 @@ (values)) (defun node-to-name (num) - (dolist (info *node-infos*) - (when (= num (me:num info)) - (return (me:short-name (me:user info)))))) + (if (= +broadcast-id+ num) + *broadcast-name* + (dolist (info *node-infos*) + (when (= num (me:num info)) + (return (me:short-name (me:user info))))))) (defun name-to-node (name) (dolist (info *node-infos*) diff --git a/examples/meshtastic/lisp/package.lisp b/examples/meshtastic/lisp/package.lisp index 52066fa..2914059 100644 --- a/examples/meshtastic/lisp/package.lisp +++ b/examples/meshtastic/lisp/package.lisp @@ -26,6 +26,8 @@ (:local-nicknames (:pr :cl-protobufs) (:me :cl-protobufs.meshtastic)) (:export + #:+broadcast-id+ + #:*broadcast-name* #:*channel* #:*channels* #:*config-complete* diff --git a/examples/meshtastic/qml/ext/Group.qml b/examples/meshtastic/qml/ext/Group.qml index f79afeb..f5ba51e 100644 --- a/examples/meshtastic/qml/ext/Group.qml +++ b/examples/meshtastic/qml/ext/Group.qml @@ -54,27 +54,28 @@ Rectangle { function addPerson(person) { // insert sorted - var i = 0; + var i = 1; // 0 is broadcast + var broadcast = (count === 0) for (; i < count; i++) { if (person.customName < get(i).customName) { insert(i, person) break } } - if (i === count) { + if (broadcast || (i === count)) { append(person) } if (person.current) { - view.currentIndex = i + view.currentIndex = broadcast ? 0 : i view.positionViewAtIndex(view.currentIndex, ListView.Contain) } } function sortRenamed(name, index) { var to = -1 - if (name < get(0).customName) { - to = 0 + if (name < get(1).customName) { // 0 is broadcast + to = 1 } else if (name >= get(count - 1).customName) { to = count - 1 } else { @@ -124,13 +125,21 @@ Rectangle { Rectangle { id: rectRadio - x: 10 - width: 42 - height: 15 + x: (index === 0) ? 18 : 10 + width: (index === 0) ? 28 : 42 + height: (index === 0) ? width : 15 anchors.verticalCenter: parent.verticalCenter color: "#f0f0f0" radius: height / 2 + Image { + anchors.centerIn: parent + width: 20 + height: width + source: "../img/broadcast.png" + visible: (index === 0) + } + Text { anchors.centerIn: parent font.pixelSize: 12 @@ -138,6 +147,7 @@ Rectangle { font.weight: Font.DemiBold color: "black" text: model.radioName + visible: (index !== 0) } } @@ -178,9 +188,11 @@ Rectangle { } onPressAndHold: { - readOnly = false - selectAll() - forceActiveFocus() + if (index !== 0) { + readOnly = false + selectAll() + forceActiveFocus() + } } onEditingFinished: { diff --git a/examples/meshtastic/qml/ext/MainView.qml b/examples/meshtastic/qml/ext/MainView.qml index 00a23e1..c366ce0 100644 --- a/examples/meshtastic/qml/ext/MainView.qml +++ b/examples/meshtastic/qml/ext/MainView.qml @@ -5,6 +5,8 @@ import "." as Ext Item { anchors.fill: parent + property alias currentIndex: swipeView.currentIndex + Rectangle { id: header width: parent.width diff --git a/examples/meshtastic/qml/img/broadcast.png b/examples/meshtastic/qml/img/broadcast.png new file mode 100644 index 0000000..251b97f Binary files /dev/null and b/examples/meshtastic/qml/img/broadcast.png differ