ipodnerd3019 / mira-js

Utility for Boox Mira
GNU General Public License v3.0
54 stars 2 forks source link

Persistence? #7

Open natejlong opened 1 year ago

natejlong commented 1 year ago

It seems that my settings do not perfectly persist. When my pc goes to sleep, or shuts off, the behavior of the monitor seems slightly different upon waking until I re-run the settings. Specifically, the input delay is slower until I re-run the settings command, which makes me think it's something to do with the refresh mode defaulting to something else and not persisting. Perhaps because the built-in settings has 4 hard-coded refresh/dither mode combinations to choose from, so upon waking it's loading the saved mode from that thus overwriting the refresh/dither settings from mira-js?

Is this behavior known/expected? Are commands supposed to save settings that persist between restarts? I wasn't sure whether this tool was meant to persist settings or just be a one-shot thing. I can set up some udev rule or something to auto-run the command if persistence isn't possible.

Diagnostics:

The command I am using:

npx mira settings --refresh-mode direct --contrast 7 --speed 5 --dither-mode 0 --white-filter 0 --black-filter 0

The monitor: Onyx Boox Mira Pro (25.3")

mira-js version: 0.2.5

shemeshg commented 1 year ago

Also (I think it is related)

Is it planned to have a way to query settings?

Looking at the reverse engineered prettified javascript seems the device returns json we might use...

async getAllSettings() {
...
...
                    sendCmd(e, t) {
                        if (!this.device) return;
                        let s = Buffer.alloc(64);
                        s.writeUInt8(e), t && (e === Q.refreshTime ? s.writeUInt16BE(t, 1) : e === Q.colorFilter ? (s.writeUInt8(t[0], 1), s.writeUInt8(t[1], 2)) : e === Q.autoDither ? (s.writeUInt8(t[0], 1), s.writeUInt8(t[1], 2), s.writeUInt8(t[2], 3), s.writeUInt8(t[3], 4)) : s.writeUInt8(t, 1));
                        **const i = s.toJSON().data;**
                        i.unshift(0);
                        try {
                            this.device.write(i)
                        } catch (o) {
                            console.error(o)
                        }
                    },
ipodnerd3019 commented 1 year ago

I think this is a "bug" in the Mira firmware.

Perhaps because the built-in settings has 4 hard-coded refresh/dither mode combinations to choose from, so upon waking it's loading the saved mode from that thus overwriting the refresh/dither settings from mira-js?

That sounds like a reasonable theory to me.

Is it planned to have a way to query settings?

Nothing is planned, but I too would like to have a subcommand that queries settings. It does look possible. Maybe we could have an "always running" mode that fixes the settings if the firmware forgets them.