sharpbrick / powered-up

.NET implementation of the LEGO PoweredUp Protocol
MIT License
98 stars 19 forks source link

Improve human readable formatting of port info #122

Closed tthiery closed 3 years ago

tthiery commented 3 years ago

Closes #113 non-breaking

tthiery commented 3 years ago

Awaiting #114

tthiery commented 3 years ago

Output after adjustment

- Hub: 0x00 / 0
  - Port: 0x32 / 50
    - Port Information
      IOTypeId: RgbLight / 0x0017 / 23
      Revision: SW: 1.0.0.0, HW: 1.0.0.0
      Capabilities: Output
      ModeCombinations: []
    - Mode 0: Name: COL O, Symbol: , Capability: Output
      - Port Mode Information
        DataSet: 1x SByte, TotalFigures: 1, Decimals: 0
        Output Mapping: SupportFunctionalMapping20 Discrete
        Raw Min:       0, Max:      10
        Pct Min:       0, Max:     100 (scaling)
        SI  Min:       0, Max:      10 (pass-through)
    - Mode 1: Name: RGB O, Symbol: , Capability: Output
      - Port Mode Information
        DataSet: 3x SByte, TotalFigures: 3, Decimals: 0
        Output Mapping: Absolute
        Raw Min:       0, Max:     255
        Pct Min:       0, Max:     100 (scaling)
        SI  Min:       0, Max:     255 (pass-through)
  - Port: 0x3B / 59
    - Port Information
      IOTypeId: Current / 0x0015 / 21
      Revision: SW: 1.0.0.0, HW: 1.0.0.0
      Capabilities: Input
      ModeCombinations: []
    - Mode 0: Name: CUR L, Symbol: mA, Capability: Input
      - Port Mode Information
        DataSet: 1x Int16, TotalFigures: 4, Decimals: 0
        Input Mapping: Absolute
        Raw Min:       0, Max:    4095
        Pct Min:       0, Max:     100 (scaling)
        SI  Min:       0, Max:    4175 (scaling)
    - Mode 1: Name: CUR S, Symbol: mA, Capability: Input
      - Port Mode Information
        DataSet: 1x Int16, TotalFigures: 4, Decimals: 0
        Input Mapping: Absolute
        Raw Min:       0, Max:    4095
        Pct Min:       0, Max:     100 (scaling)
        SI  Min:       0, Max:    4175 (scaling)
  - Port: 0x3C / 60
    - Port Information
      IOTypeId: Voltage / 0x0014 / 20
      Revision: SW: 1.0.0.0, HW: 1.0.0.0
      Capabilities: Input
      ModeCombinations: []
    - Mode 0: Name: VLT L, Symbol: mV, Capability: Input
      - Port Mode Information
        DataSet: 1x Int16, TotalFigures: 4, Decimals: 0
        Input Mapping: Absolute
        Raw Min:       0, Max:    4095
        Pct Min:       0, Max:     100 (scaling)
        SI  Min:       0, Max:    9615 (scaling)
    - Mode 1: Name: VLT S, Symbol: mV, Capability: Input
      - Port Mode Information
        DataSet: 1x Int16, TotalFigures: 4, Decimals: 0
        Input Mapping: Absolute
        Raw Min:       0, Max:    4095
        Pct Min:       0, Max:     100 (scaling)
        SI  Min:       0, Max:    9615 (scaling)
  - Port: 0x3D / 61
    - Port Information
      IOTypeId: TechnicMediumHubTemperatureSensor / 0x003C / 60
      Revision: SW: 1.0.0.0, HW: 1.0.0.0
      Capabilities: Input
      ModeCombinations: []
    - Mode 0: Name: TEMP, Symbol: DEG, Capability: Input
      - Port Mode Information
        DataSet: 1x Int16, TotalFigures: 5, Decimals: 1
        Input Mapping: SupportFunctionalMapping20 Absolute
        Raw Min:    -900, Max:     900
        Pct Min:    -100, Max:     100 (scaling)
        SI  Min:     -90, Max:      90 (scaling)
  - Port: 0x60 / 96
    - Port Information
      IOTypeId: TechnicMediumHubTemperatureSensor / 0x003C / 60
      Revision: SW: 0.0.0.1, HW: 0.0.0.1
      Capabilities: Input
      ModeCombinations: []
    - Mode 0: Name: TEMP, Symbol: DEG, Capability: Input
      - Port Mode Information
        DataSet: 1x Int16, TotalFigures: 5, Decimals: 1
        Input Mapping: SupportFunctionalMapping20 Absolute
        Raw Min:    -900, Max:     900
        Pct Min:    -100, Max:     100 (scaling)
        SI  Min:     -90, Max:      90 (scaling)
  - Port: 0x61 / 97
    - Port Information
      IOTypeId: TechnicMediumHubAccelerometer / 0x0039 / 57
      Revision: SW: 0.0.0.1, HW: 0.0.0.1
      Capabilities: Input
      ModeCombinations: []
    - Mode 0: Name: GRV, Symbol: mG, Capability: Input
      - Port Mode Information
        DataSet: 3x Int16, TotalFigures: 3, Decimals: 0
        Input Mapping: SupportFunctionalMapping20 Absolute
        Raw Min:  -32768, Max:   32768
        Pct Min:    -100, Max:     100 (scaling)
        SI  Min:   -8000, Max:    8000 (scaling)
    - Mode 1: Name: CAL, Symbol: , Capability: Input
      - Port Mode Information
        DataSet: 1x SByte, TotalFigures: 0, Decimals: 0
        Input Mapping: SupportFunctionalMapping20 Absolute
        Raw Min:       1, Max:       1
        Pct Min:    -100, Max:     100 (scaling)
        SI  Min:       1, Max:       1 (pass-through)
  - Port: 0x62 / 98
    - Port Information
      IOTypeId: TechnicMediumHubGyroSensor / 0x003A / 58
      Revision: SW: 0.0.0.1, HW: 0.0.0.1
      Capabilities: Input
      ModeCombinations: []
    - Mode 0: Name: ROT, Symbol: DPS, Capability: Input
      - Port Mode Information
        DataSet: 3x Int16, TotalFigures: 3, Decimals: 0
        Input Mapping: SupportFunctionalMapping20 Absolute
        Raw Min: -28571,42, Max: 28571,42
        Pct Min:    -100, Max:     100 (scaling)
        SI  Min:   -2000, Max:    2000 (scaling)
  - Port: 0x63 / 99
    - Port Information
      IOTypeId: TechnicMediumHubTiltSensor / 0x003B / 59
      Revision: SW: 0.0.0.1, HW: 0.0.0.1
      Capabilities: Output Input
      ModeCombinations: []
    - Mode 0: Name: POS, Symbol: DEG, Capability: Input
      - Port Mode Information
        DataSet: 3x Int16, TotalFigures: 3, Decimals: 0
        Input Mapping: SupportFunctionalMapping20 Absolute
        Raw Min:    -180, Max:     180
        Pct Min:    -100, Max:     100 (scaling)
        SI  Min:    -180, Max:     180 (pass-through)
    - Mode 1: Name: IMP, Symbol: CNT, Capability: Input
      - Port Mode Information
        DataSet: 1x Int32, TotalFigures: 3, Decimals: 0
        Input Mapping: Relative
        Raw Min:       0, Max:     100
        Pct Min:       0, Max:     100 (pass-through)
        SI  Min:       0, Max:     100 (pass-through)
    - Mode 2: Name: CFG, Symbol: , Capability: Output
      - Port Mode Information
        DataSet: 2x SByte, TotalFigures: 3, Decimals: 0
        Output Mapping: Absolute
        Raw Min:       0, Max:     255
        Pct Min:       0, Max:     100 (scaling)
        SI  Min:       0, Max:     255 (pass-through)
  - Port: 0x64 / 100
    - Port Information
      IOTypeId: TechnicMediumHubGestureSensor / 0x0036 / 54
      Revision: SW: 0.0.0.1, HW: 0.0.0.1
      Capabilities: Input
      ModeCombinations: []
    - Mode 0: Name: GEST, Symbol: , Capability: Input
      - Port Mode Information
        DataSet: 1x SByte, TotalFigures: 1, Decimals: 0
        Input Mapping: SupportFunctionalMapping20 Discrete
        Raw Min:       0, Max:       4
        Pct Min:       0, Max:     100 (scaling)
        SI  Min:       0, Max:       4 (pass-through)
tthiery commented 3 years ago

@vuurbeving Any thoughts on this. Does this help readability? Would you improve something?

rickjansen-dev commented 3 years ago

I like this, much more compact than before, really helps reading 👍

Only thing I can see that might improve this are the - Port Information and - Port Mode Information lines. Maybe simply remove them or merge them with the lines below? So no lines are wasted with lines without actual info. Ex:

 - Port: 0x64 / 100
    - IOTypeId: TechnicMediumHubGestureSensor / 0x0036 / 54
      Revision: SW: 0.0.0.1, HW: 0.0.0.1
      Capabilities: Input
      ModeCombinations: []
    - Mode 0: Name: GEST, Symbol: , Capability: Input
      - DataSet: 1x SByte, TotalFigures: 1, Decimals: 0
        Input Mapping: SupportFunctionalMapping20 Discrete
        Raw Min:       0, Max:       4
        Pct Min:       0, Max:     100 (scaling)
        SI  Min:       0, Max:       4 (pass-through)
tthiery commented 3 years ago

Yeah thought about that. There is flag involved dumping the actual Configuration applied in the protocol which would create a second enumeration - in the thing (see #113 ). But I think I can ignore that ... with configuration dump barely will be used i guess.