Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/GoneUp/mask-go
Control your "shining" LED mask with Golang
https://github.com/GoneUp/mask-go
go golang ledtik shining-mask
Last synced: 6 days ago
JSON representation
Control your "shining" LED mask with Golang
- Host: GitHub
- URL: https://github.com/GoneUp/mask-go
- Owner: GoneUp
- License: mit
- Created: 2023-03-17T23:27:00.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-23T20:51:56.000Z (over 1 year ago)
- Last Synced: 2024-08-02T20:46:48.709Z (3 months ago)
- Topics: go, golang, ledtik, shining-mask
- Language: Go
- Homepage:
- Size: 2.15 MB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mask-go
A shining mask implementation written in Golang. It is intended to be used with masks controlled by the Shining mask app.It seems that there are several different vendor models avaialable, but they share the same app/protocol. E.g. `Lumen Couture LED Face Changing Mask`.
[Play store link of the control app](https://play.google.com/store/apps/details?id=cn.com.heaton.shiningmask)
Features:
- Connection with mask over BLE (using tinygo.org/x/bluetooth)
- Controlling the mask remotely (Brightness, Static image, Anmination, Text speed, Text color)
- Uploading/showing text on the mask![](image.png)
## Usage
Installation with
`go get github.com/GoneUp/mask-go`Simple usage example
```go
import "github.com/GoneUp/mask-go/mask"mask.InitAndConnect(true)
mask.SetText("Hello world")
```A demo application is included in the [main.go](main.go) file.
GoDoc can be found [here](https://pkg.go.dev/github.com/GoneUp/mask-go)
## Protocol
The mask commuicates over Bluetooth LE with the mask. The protocol iself is fairly simply, however there is a AES ECB encryption.Please review this reddit post, it contains all basic protocol details and the AES key used: https://www.reddit.com/r/ReverseEngineering/comments/lr9xxr/comment/h14nm39/?utm_source=reddit&utm_medium=web2x&context=3
The most complicated bit of the mask-go is the text upload. The mask just accepts a bitmap/colors in a very custom format.
So to upload text, we have to draw it to a bitmap, convert it accordingly to the protcol and send it in custom manner to the app.The protocol is implemented in [mask.go](mask/mask.go) and [draw.go](mask/draw.go).
Braindumping protocol details:
```
Methodsccroll mode:
05MODEnn
nn 01 = steady
nn 02 = blink
nn 03 = scroll left
nn 04 = scroll right
nn 05 = steadycustom text front color:
06FC<00/01>custom text back color:
06BC<00/01>speed:
06SPEEDnnset text color mode:
03M<00/01><00-07>00-03= text gradients
05-07= background animationsset light
06LIGHTnnset image
06IMAGnnset anmiation
06ANIMnnset diy image
06PLAY01nnText upload:
UPLOAD PROCESS:
DATS > Mask
Mask > DATSOKP
per packet
Upload ...
Mask > REOK
DATCP > Mask
Mask > DATCPOK09DATS - 2 byte total len - 2 byte bitmap len
Image data:
The display of the mask is 16 pixel high, the data is sent accordingly per pixel colum.
For each pixel in a pixel colum a bit is set (on/off). For each colum there is also a RGB value.In more formal form:
for each column:
column encoded in 2byte
b1: line 0-7, bit 0-7
b2: line 7-15, bit 0-7
for each colum
3 byte RGBexample: 8 colums, 12b pixels, 24b color = 36byte
FFFF0000 FFFF0000 FFFF0000 FFFF0000 FF0000 FF0000 00FF00 00FF00 FF0000 FF0000 00FF00 00FF00Implemented in draw.go
sending in the format of max 100b packets:
```## Credits
I was able to learn a lot from other open-source code:
All peeps in this reddit thread https://www.reddit.com/r/ReverseEngineering/comments/lr9xxr/help_me_figure_out_how_to_reverse_engineer_the/
beclaminde with this project https://github.com/beclamide/mask-controller
shawnrancatore with this hacky project https://github.com/shawnrancatore/shining-mask