Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement how to deal with default_color in segment_displays #529

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
19 changes: 14 additions & 5 deletions docs/code/introduction/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ By clicking on the line number you can set a breakpoint:

![open menu](images/debug_set_breakpoint.png)

## Attach to process
## Run in debug mode
You basically have two options to run mpf in debug mode. You can either start mpf normally and then attach the debugger to the running process. The other option is that you start mpf in debug mode from PyCharm directly. The latter has the advantage that you can as well catch code that executes while mpf initializes and not only during the game flow. Both options are being explained below.

### Attach to process

Now it is time to start mpf like you normally do. Keep in mind, that before you start mpf with e.g. `mpf -t -b`, that you need to [activate](../../install/virtual-environments.md) your Python virtual environment.

Expand All @@ -33,10 +36,16 @@ Afterwards a new pop-up window will open up

![open menu](images/debug_select_process.png)

from where you need to select your mpf process, depeding what other (Python) process you have running the list might be shorter or longer.
from where you need to select your mpf process, depeding what other (Python) process you have running the list might be shorter or longer. Run your game and wait until your game flow hits the debugger. Now you have the normal debugging options like stepping in or looking into variables.

## Start Debugging
![open menu](images/debug_code.png)

Run your game and wait until your game flow hits the debugger. Now you have the normal debugging options like stepping in or looking into variables.
### Start mpf in debug mode

![open menu](images/debug_code.png)
In this case you need to execute mpf not as an executable like you normally do, but as a python script. So you don't run it with `mpf -t -b` but with something like `python <path>/<script>.py`. First of all you need to know your python command, it could be simply `python` or it could include a version number like `python3.11`. Just try in a terminal what python command works for you if you don't know. Secondly you need to know the path and the script name which you want to execute. For mpf the script is named `__main__.py` the path depends on your virtual environment, look into your folder `<virtual_env>/lib64/python3.11/site-packages/mpf`, there you should be able to see the script `__main__.py`.

In PyCharm in the `run` menu open the debug configuration and configure it as following:

![debug script](images/debug_script.png)

The name in the first field is set automatically if you leave it empty, you can choose your own name as well. In the script enter the full path to your python script like explained above. In the script parameters field enter the parameters you would pass usually to mpf, e.g. `-b -t`. Last but not least make sure to set the field working directory to your machine folder. Now you can start mpf using the `run` menu select there `debug <name>`, where name is the name you have specified in the debug configuration screen above.
Binary file added docs/code/introduction/images/debug_script.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 17 additions & 7 deletions docs/config/neoseg_displays.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ title: "neoseg_displays:"
|[machine](instructions/machine_config.md) config files |**YES** :white_check_mark:|
|[mode](instructions/mode_config.md) config files|**NO** :no_entry_sign:|

The `neoseg_displays:` section of your config is where you...

--8<-- "todo.md"
The `neoseg_displays:` section of your config is where you set the hardware specific settings for this type of segment display. It is
only needed if you use a [Cobra serial segment display](../hardware/opp/cobrapin/cobrapin_serial_segment_displays.md). For any other
segment display hardware this setting is not needed.

## Required settings

Expand All @@ -24,9 +24,17 @@ your config:
### light_template:

Single value, type: [lights:](lights.md).
Defaults to empty.
Defaults to empty. Used to specify the light you have, though neoseg displays come in different
colors each segment is considered a single color segment, use color white in any case.

--8<-- "todo.md"
```
light_template:
type: w
subtype: led
color_correction_profile: NeoSeg_orange
```

See as well these examples in the [Cobra serial segment display](../hardware/opp/cobrapin/cobrapin_serial_segment_displays.md) section.

## Optional settings

Expand Down Expand Up @@ -56,13 +64,15 @@ Single value, type: string name of a [lights:](lights.md) device. Defaults to em
Single value, type: one of the following options: 2digit, 8digit.
Default: `8digit`

--8<-- "todo.md"
Make sure to set the right size depending on what hardware you have.

### start_channel:

Single value, type: `string`. Defaults to empty.

--8<-- "todo.md"
The start channel for the first display would be either `0-0-0` or `1-0-0`, depending what neo seg connection you use on your Cobra pin. The start channel of the next hardware is
easily computed, for each digit you need 15 channels (14 segments plus the integrated dot). If your first segment has 8 digits you need 120 channels from 0 to 119, thus the next
display would have as start channel either `0-0-120` or `1-0-120`.

### start_x:

Expand Down
14 changes: 10 additions & 4 deletions docs/config/segment_displays.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ of your config. (If you don't include them, the default will be used).
### default_color:

List of one (or more) values, each is a type: `color` (*color name*,
*hex*, or list of values *0*-*255*). Default: `white`
*hex*, or list of values *0*-*255*). Default: `white`.

You should specify for each digit of your segment display a default color. If you specify less
colors than the `size` of your display the other digitis will have `white` as default color. E.g. if you have 8 digits and specify `"blue, yellow"` then the other
6 digits will have `white` as default color.

--8<-- "todo.md"

### default_transition_update_hz:

Expand All @@ -55,7 +58,9 @@ Single value, type: `boolean` (`true`/`false`). Default: `false`
Determines whether or not the physical segment display has integrated
commas in each character rather than taking up an entire character. When
set to `true`, commas are collapsed with the preceding character when
calculating text transition effects.
calculating text transition effects. You need to check with your hardware vendor
if commas have an own segment, sometimes you can see a comma on the display but it
is not being used, e.g. [Cobra serial segment display](../hardware/opp/cobrapin/cobrapin_serial_segment_displays.md).

### integrated_dots:

Expand Down Expand Up @@ -120,7 +125,8 @@ persist player variables (e.g. score) without having to continually push updates

Single value, type: `boolean` (`true`/`false`). Default: `false`

--8<-- "todo.md"
If your segment display doesn't provide an own segment for a comma but has an own segment for period, then this setting will use
the period segment as a comma. Otherwise the comma will be display on an own segment (which doesn't look too nice usually).

### console_log:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ light number. An 8-digit NeoSeg display occupies 120 channels while the
display after neoSeg_0, its start_channel would be 0-0-0 plus 120...so
0-0-120.

Note, though these are 14 segment displays you need 15 channels per digit since the
period provided as an own segment needs on own channel. If you look at the hardware closely
you will see the period and underneath a comma. The comma cannot be addressed separately, in fact
the display shows a dot rather as a semicolon. For a neoseg display you probably would set [use_dots_for_commas](../../../config/segment_displays.md) to
true to show a comma as a dot.

We had to add a light template so that we could identify it as a single
channel LED.

Expand Down
6 changes: 5 additions & 1 deletion docs/shows/playing.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ looping.
Note that any shows which were started via a `show_player:` section in a
mode config file will automatically be stopped when that mode stops.

So check the [show_player:](../config/show_player.md)
!!! note

Please make sure to always stop your show when you don't need it anymore. For example you run a show (show 1) on segment display, that show displays the player number. After the game is over another show (show 2) kicks in and that new show writes something on that display (so no more showing the actual player). Now you want to start the next game, the old show (show 1) starts again. If the player number has not changed, and it doesn't for example in a 1-player game, mpf believes the old execution of show 1 is still valid since nothing has changed and won't update the display (which again you have overwritten in a different show).

Check the [show_player:](../config/show_player.md)
documentation for details.