WebUSB Sept 2021

Moving this conversation to it’s own thread.

Cool. I went to check it out, but the page is 1/2 working on Chrome for me.
I get control, can do on, off, clash and those ok.
Tracks load after a long while, but I haven’t seen presets show up yet. Stuck on "waiting to list presets.
Also, Edit is stuck at “Getting options”

On a side note, I see EVENT: Stab millis=394294 volts. under the volume bar.
Is this going to be showing messages as serial monitor would report?
That would be awesome, and more cool if there was a mini-console up in the corner.

Sounds like there are some communication issues.
Are you using WebUSB or BLE?

Is the saber ignited?
Is the SD card mounted on the computer?

Also, in the javascript console there’s this FYI:

Uncaught (in promise) TypeError: Cannot read property 'replace' of undefined
    at UpdatePresets (app.html:977)
    at Run2 (app.html:1055)

Refreshing the page, I get

Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'.

Then is says failed to load presets.inim but then proceeds to show the contents.
But presets don’t appear in the page like tracks do eventually.

Run2 @ app.html:1057
async function (async)
Run2 @ app.html:1036
Run @ app.html:1024
async function (async)
Run @ app.html:1014
onclick @ app.html:1245


app.html:363 > Failed to open: presets.ini
Failed to open: presets.tmp
FONT=a_DARKSABER/DarkV3;common
TRACK=
STYLE1=builtin 0 1
STYLE2=builtin 0 2
STYLE3=builtin 0 3
STYLE4=builtin 0 4
STYLE5=builtin 0 5
NAME= dark\n v3
VARIATION=0
Failed to open: presets.ini
Failed to open: presets.tmp

FONT=a_DARKSABER/Darkstar;common
TRACK=
STYLE1=builtin 1 1
STYLE2=builtin 1 2
STYLE3=builtin 1 3
STYLE4=builtin 1 4
STYLE5=builtin 1 5
NAME= darkstar
VARIATION=0
Failed to open: presets.ini
Failed to open: presets.tmp

FONT=aa_Greyscale/Analog_Greyscale;common
TRACK=
STYLE1=builtin 2 1
STYLE2=builtin 2 2
STYLE3=builtin 2 3
STYLE4=builtin 2 4
STYLE5=builtin 2 5
NAME=analog
VARIATION=0
Failed to open: presets.ini
Failed to open: presets.tmp

FONT=aa_Greyscale/Assassin_Greyscale;common
TRACK=
STYLE1=builtin 3 1
STYLE2=builtin 3 2
STYLE3=builtin 3 3
STYLE4=builtin 3 4
STYLE5=builtin 3 5
NAME=assassin
VARIATION=0```

BLE from my computer to the saber.

Not ignited, although it can be as controls on the page work.
Sd card is in the saber on the bench.

Just refreshed and it’s good now. Am I beating you to a reply saying try it now?
:slight_smile:

Actually, I did a colorchange manually on the saber, writing something to presets.ini. Wonder if that helped.

I think BLE is ending up dropping some of the data.
Although, it could be a problem on the web app I suppose.
I might have to build a more robust protocol.

This is under edit menu. What should be where Undefined is?
Screen Shot 2021-09-02 at 12.47.51 AM

You’ll need to reflash your board.
I’m not sure if you have the last version of the app either.

Updated to Git latest.
Force refreshed browser page.
With bluetooth I can confirm prests.ini can’t be read until I do a manual write to it on the saber then it’s ok.

USB connection is fine.
Some notes about edit page:
Still seeing UNDEFINED as some option.
Extension “time” shows as a color choice.
Blast color shows as a value.
Things don’t fit in their boxes even resizing the page with zoom. The layout just auto snaps to fit.
Vid to accompany notes:

Also, how do we save the edited changes? They revert back toggling edit.
(this is zoom at normal 100% BTW)

Hmm, I must admit that I didn’t check that things got saved properly.
I’ll have to look into that.
Do you have arguments in your code that aren’t checked into github yet?
(If so, you may need to add some words in the style description string in style_parser.h as well.)

No custom arguments, just choosing from the drop down menu of named styles.

When changing style, console reports

app.html:583 Uncaught TypeError: Cannot read property 'value' of null
    at SaveStyle (app.html:583)
    at OnStyleSelect (app.html:573)
    at HTMLSelectElement.onchange (app.html:1)

As far as UNDEFINED descriptor goes, using built in Fire style for example, it’s weird because it looks like it loaded it ok

Sending describe_named_style fire           app.html:366
 > Fire blade, warm color, hot color
Style size = 48
COLOR 65535,0,0
COLOR 65535,65535,0                         app.html:1210
(4) ["Fire blade, warm color, hot color", "Style size = 48", "COLOR 65535,0,0", "COLOR 65535,65535,0"]
0: "Fire blade, warm color, hot color"
1: "Style size = 48"
2: "COLOR 65535,0,0"
3: "COLOR 65535,65535,0"length: 
4[[Prototype]]: Array(0)

Fire blade, warm color, hot color           app.html:1211 

so it seems it didn’t parse “warm color” for some reason.

These just look like they need some reordering:

The UNDEFINED looks like maybe it’s an offset issue, as it’s got a place holder for the base color in the definition, but no base color in the editor?
Standard lists as “Standard blade, color, clash color, extension time, retraction time”
But starts with CLASH COLOR in the editor.

Looking closer, the Advanced example above is missing COLOR AT HILT, and turns out all the graphicals are missing at least the first argument. (I think I just invented a word.)

Strobe is missing “standby color.”
Unstable is missing “warm.”
Cycle is missing the first “start color” and the last “lockup color”, so it’s offset by 2 and has 2 UNDEFINEDs at the bottom.
and Rainbow is missing “extension time.”

Are builtins going to everything graphically editable like the others as per the addition of all the options to style_parser.h @line 100?

    // TODO: Support multiple argument templates.
    "builtin preset styles, "
    "preset number, blade number, "
    "base color, alt color, style option, "
    "ignition option, ignition time, ignition delay, ignition color, ignition power up argument, "
    "blast color, clash color, lockup color, lockup position, drag color, drag size, lb color "
    "stab color, melt size, swing color, swing option, emitter color, emitter size, "
    "preon color, preon option, preon size, "
    "retraction option, retraction time, retraction delay, retraction color, retraction cool down, "
    "postoff color, off color, off option"

Yes, builtins are going to editable too.
For now we assume that the use Fett263s argument ordering, but the intention is that in the future we can support multiple different argument order templates.

Would you like an issue reported on Github so it’s on a reminder list of sorts?
Although, while there are several here that are similar but different, I don’t think you want 3 or 4 or 5 issues.
Or, is this thread enough for now?
Summary:
Not saving changes made under Edit.
Advanced style arguments need re-order.
Graphic layouts of styles are missing at least the first argument, causing UNDEFINEDs.

I got a little sidetracked on building a packet protocol for communication between the app the board. This would make the communication work properly even if bytes gets lost or something, but it’s a little more involved than I first thought.

Ok, so I’ve done some testing, however, I have not been able to reproduce most of these bugs.

I found a bug that adds a nonexistant undefined parameter in some cases (in ProffieOS, not in the webusb app) but that was it for bugs so far.

I should point out that saving doesn’t happen when you exit edit mode, it happens every time you change anything.

What URL are you using for the WebUSB app?