markcellis / X-KeyPad

2 stars 0 forks source link

Stream Deck Plus: Subtring handling for space characters #117

Open GladYouAsked opened 3 months ago

GladYouAsked commented 3 months ago

Hello Mark,

Short summary of the issue: There may be an issue with the substring handling for space characters. It seems space characters are ignored (not displayed) if being located at the beginning or the end of a substring. It seems the space character is considered by X-KeyPad (at least in the User Interface of X-KeyPad), but it does not get considered on the SD+.

SD Software: 6.6.1 (20596) X-KeyPad: 1.6.1 beta 5

(sorry for this detailed description below, maybe we do a discord session again)

What I want to do:

This is the cockpit display that I want to recreate on the Stream Deck Plus (SD+): image [Figure 1: Display Screenshot]

This display consists of three columns with messages. I am now focusing on the central column and the following text: BATT DISCH XMSN OIL PRES BUS TIE

What I have so far:

I have succeeded create the display on the SD+, but the issue mentioned above remains: image [Figure 2: SD+ Indication]

As you know the SD+ has 4x segments. The string in the central display is located at the border of two segments and has to be separated into substrings. In this case TouchSegment#3 and TouchSegment#4 (TS#3 and TS#4) are involved.

Issue / Expected behavior:

Even though there should be trailing space character at the end of "BATT", there is none. This results in an indication of "BATTDISCH" instead of "BATT DISCH" on the SD+.

Same applies for "XMSNOIL PRES", which should be "XMSN OIL PRES".

Note: Please ignore the differences between the SD+-text in Figure 2 and the display screenshot in Figure 1: Colors are not represented and the indication/sorting of the messages in the left and right column are not correct. Also some strings are clipped due to length. This is not relevant for the issue mentioned above.

How did I implement this?

1.) There is a string including the display messages, CAS_text: image

ADC1|ADC 1 FAIL|AHRS 1|AHRS 1 FAIL|AP AHRS 1 FAIL|1 AP OFF|2 AP OFF|ATT OFF|BATT DISCH|BUS TIE|#1 DC GEN|#2 DC GEN|EMER UTIL PRES|FLTA INHBT|FUEL PUMP 1|FUEL PUMP 2|GPS 1 FAIL|MAIN UTIL PRES|SERVO 1|SERVO 2|XMSN OIL PRES|

2.) With some additional information you can extract the substrings and allocate them to left/center/right column later The extracted substrings are here, including the space characters between words: image SRS/X-KeyPad/custom_string_26 BATT DISCH <--- Let's focus on this string SRS/X-KeyPad/custom_string_27 XMSN OIL PRES SRS/X-KeyPad/custom_string_28 BUS TIE

3.) Line Definitions for TS#3 image Please note the Substring Index ranging from 0..4, so it should include the trailing space character for "BATT ".

4.) Line Definitions for TS#4 image

5.) Layouts for TS#3 "line3" is relevant here.

{
    "id": "AW109SP.EDU.xkeypad.layout",
    "items": [
        {
            "key": "icon",
            "type": "pixmap",
            "rect": [0, 0, 200, 100],
            "zOrder": 1
        },

        {
            "key": "line0",
            "type": "text",
            "rect": [5, 0, 128, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "left",
            "text-overflow": "clip",
            "zOrder": 2
        },
        {
            "key": "line1",
            "type": "text",
            "rect": [5, 26, 128, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "left",
            "text-overflow": "clip",
            "zOrder": 3
        },
        {
            "key": "line2",
            "type": "text",
            "rect": [5, 52, 128, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "left",
            "text-overflow": "clip",
            "zOrder": 4
        },

        {
            "key": "line3",
            "type": "text",
            "rect": [137, 0, 63, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "right",
            "text-overflow": "clip",
            "zOrder": 2
        },
        {
            "key": "line4",
            "type": "text",
            "rect": [137, 26, 63, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "right",
            "text-overflow": "clip",
            "zOrder": 3
        },
        {
            "key": "line5",
            "type": "text",
            "rect": [137, 52, 63, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "right",
            "text-overflow": "clip",
            "zOrder": 4
        }
    ]
}

5.) Layouts for TS#4 "line0" is relevant here.

{
    "id": "AW109SP.EDU.xkeypad.layout",
    "items": [
        {
            "key": "icon",
            "type": "pixmap",
            "rect": [0, 0, 200, 100],
            "zOrder": 1
        },

        {
            "key": "line0",
            "type": "text",
            "rect": [0, 0, 64, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "left",
            "text-overflow": "clip",
            "zOrder": 2
        },
        {
            "key": "line1",
            "type": "text",
            "rect": [0, 26, 64, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "left",
            "text-overflow": "clip",
            "zOrder": 3
        },
        {
            "key": "line2",
            "type": "text",
            "rect": [0, 52, 64, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "left",
            "text-overflow": "clip",
            "zOrder": 4
        },

        {
            "key": "line3",
            "type": "text",
            "rect": [70, 0, 130, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "left",
            "text-overflow": "clip",
            "zOrder": 2
        },
        {
            "key": "line4",
            "type": "text",
            "rect": [70, 26, 130, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "left",
            "text-overflow": "clip",
            "zOrder": 3
        },
        {
            "key": "line5",
            "type": "text",
            "rect": [70, 52, 130, 26],
            "font": {"size": 20, "weight": 350 },
            "color": "#ffff00",
            "alignment": "left",
            "text-overflow": "clip",
            "zOrder": 4
        }
    ]
}

What else have I tried?

1.) TS#3: Adapting the Substring Index from "0..4" to "0..3" image This does have no effect (as expected): image

2.) TS#3: Adapting the Substring Index from "0..4" to "0..5" image Now the "D" from "BATT D" is considered as well, including the space character between "T" and "D" (as expected): image

3.) TS#4: Adapting the Substring Index from "05..15" to "04..15" It is hard to see, but the leading space character is considered in the X-KeyPad ("DISCH" is slightly moved to the right): image But this does not have an impact in the indication on the SD+ (still no space character): image

4.) TS#4: Adapting the Substring Index from "05..15" to "03..15" image Now "T DISCH" is displayed also on TS#4 on the SD+ (as expected) image

markcellis commented 3 months ago

I'll have to try and reproduce this. I notice that you are using left and right justification with just a few pixels between the rectangles. I'm wondering if the SD+ SDK trims the text of white space when using justification. Maybe you could try leaving more space between the rectangles on the same line.