Change the default settings

Important tips

  • This is the command to edit the configuration file with a default text editor as defined in your system:

    $ start_dv -e cfg
    

    Or with a specific text editor:

    $ start_dv -e cfg -a APP_NAME
    

    where APP_NAME is the name of a text editor, e.g. TextEdit

  • To end the start_dv script, press ctrl + c

  • When adding audio files, don’t use mp3 as the file format. Instead, use ogg (compressed) or wav (uncompressed). The reason is that mp3 won’t work well with pygame’s simultaneous playback capability.

    Reference: stackoverflow

Add Darth Vader quotes

If you want to add more Darth Vader quotes, you have to edit the setting quotes in the configuration file. Open the configuration file with:

$ start_dv -e cfg

Each quote is represented in the configuration file as objects having the following properties:

  • id: unique identifier

  • name: it will be displayed in the terminal

  • filename: it is relative to the directory sounds_directory

  • audio_channel_id: all quotes should be played in channel 1 as explained in audio_channels

Add your quote object to the list in quotes, like in the following example:

Example: adding a new quote
"quotes": [
  {
    "id": "there_is_no_escape",
    "name": "There is no escape",
    "filename": "quote_there_is_no_escape.ogg",
    "audio_channel_id": 1
  },

Change channel volume

To change the volume for an audio channel, open the configuration file and edit the channel’s volume found in the setting audio_channels:

$ start_dv -e cfg
Audio channels and their default volume
"audio_channels": [
  {
    "channel_id": 0,
    "channel_name": "breathing_sound",
    "volume": 0.2
  },
  {
    "channel_id": 1,
    "name": "song_and_quotes",
    "volume": 1.0
  },
  {
    "channel_id": 2,
    "name": "lightsaber_and_closing_sounds",
    "volume": 1.0
  }
],

What each channel controls:

  • Channel 0 controls Darth Vader’s breathing sound

  • Channel 1 controls the Imperial March song and all Darth Vader quotes

  • Channel 2 controls the lighsaber sound effects and the closing sound

Note

Volume takes values in the range 0.0 to 1.0 (inclusive). As per the pygame documentation.

See also

The setting audio_channels

Change closing sound

When the start_dv script is exiting after the user presses ctrl + c, a sound is produced. By default, no closing sound is produced and if it were to play, it would be the “Nooooo” quote.

To change the default closing sound, edit the setting sound_effects in the configuration file which can be opened with:

$ start_dv -e cfg

At the end of the list in sound_effects, you will find the closing_sound object. These are the properties you can modify for this object:

  • name: it is the name of the sound which will be displayed in the terminal

  • filename: it is relative to sounds_directory

  • mute: if true, nothing will be played at the end of the script. Otherwise, the closing sound will be played when the script is terminating.

Example: choosing another closing sound by changing filename
"sound_effects": [
  {
    "id": "closing_sound",
    "name": "Bye [Closing]",
    "filename": "bye.ogg",
    "audio_channel_id": 2,
    "mute": false
  },

Note

By default, the closing sound is not played at the end of the start_dv script. Set its property mute to true in order to play the closing sound when the script exits.

Change GPIO channel name and number

The GPIO channels are identified in the terminal by their channel_name along with their LED symbols. If channel_name is not available, then its channel_number is shown.

The channel_number is the GPIO channel number of a pin used for connecting an I/O device (e.g. LED) and is defined based on the numbering system you have specified (BOARD or BCM).

To change a GPIO channel’s channel_name and channel_number, open the configuration file with:

$ start_dv -e cfg

And edit its properties channel_name and channel_number, like in the following example.

Example: changing the channel_name and channel_number for the bottom LED
"gpio_channels": [
  {
    "channel_id": "bottom_led",
    "channel_name": "Bottom LED",
    "channel_number": 15
  },

Important

Don’t change the property channel_id since it is used to uniquely identify the GPIO channels.

See also

The setting gpio_channels

Change keymap

If you want to change the default keymap used for the three push buttons, edit the setting gpio_channels in the configuration file which can be opened with:

$ start_dv -e cfg
Default keymap used for the three push buttons
"gpio_channels": [
  {
    "channel_id": "lightsaber_button",
    "channel_name": "lightsaber_button",
    "channel_number": 23,
    "key": "cmd"
  },
  {
    "channel_id": "song_button",
    "channel_name": "song_button",
    "channel_number": 24,
    "key": "alt"
  },
  {
    "channel_id": "quotes_button",
    "channel_name": "quotes_button",
    "channel_number": 25,
    "key": "alt_r"
  },

In order to change the default keymap, you will need to change the value for key which refers to the name of the keyboard key associated with a given push button.

The names of keyboard keys that you can use are those specified in the SimulRPi’s documentation, e.g. media_play_pause, shift, and shift_r.

Example: choosing shift_r for the Quotes button
{
  "channel_id": "quotes_button",
  "channel_name": "quotes_button",
  "channel_number": 25,
  "key": "shift_r"
},

Note

On mac, I recommend using the following keyboard keys because they don’t require running the start_dv script with sudo: alt, alt_r, cmd, cmd_r, ctrl, ctrl_r, media_play_pause, media_volume_down, media_volume_mute, media_volume_up, shift, and shift_r.

Ref.: Platform limitations

See also

The setting gpio_channels

Change LED symbols

You can either:

  1. change the default LED symbols used by all output channels, or

  2. change the LED symbols for specific output channels

Case 1: change default_led_symbols

To change the default LED symbols used by all output channels, edit the setting default_led_symbols by opening the configuration file:

$ start_dv -e cfg

Add your LED symbols for each output state:

"default_led_symbols": {
  "ON": "🔵",
  "OFF": "⚪ "
},

Case 2: change gpio_channels

To change the LED symbols for specific output channels, edit the setting gpio_channels by opening the configuration file:

$ start_dv -e cfg

You need to modify the property led_symbols for a given LED object defined in gpio_channels.

Example: changing the symbols for the lightsaber LED
 "gpio_channels": [
   {
      "channel_id": "lightsaber_led",
      "channel_name": "lightsaber",
      "channel_number": 22,
      "led_symbols": {
        "ON": "\\033[1;31;48m(0)\\033[1;37;0m",
        "OFF": "(0)"      }
    }
 ]

Note

If you omit led_symbols as a property for a LED object, the default LED symbols will be used instead.

Important

If you are having problems displaying the default LED symbols when running the start_dv script, such as this error:

ERROR    UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f6d1' in position 2: ordinal not in range(128)

Then, you are might have your locale settings set incorrectly. Check Display problems for more info about how to change them properly or other solutions.

Change paths to audio files

The setting sounds_directory in the configuration file defines the directory where all audio files (e.g. quotes) are saved.

Each audio object defined in the settings quotes, songs and sound_effects have a filename property that you can modify. The filename for each audio file is defined with respect to the directory sounds_directory.

Example: filename for the closing sound
"sound_effects": [
  {
    "id": "closing_sound",
    "filename": "quote_nooooo.ogg",
    "audio_channel_id": 2,
    "mute": false
  },

Important

Don’t change the id property for songs and sound_effects objects because it is used to uniquely identify them.

See also

Change slot LEDs sequence

The setting slot_leds in the configuration file controls the blinking pattern of the three slot LEDs in Darth Vader’s control box.

To change the default sequence, open the configuration file:

$ start_dv -e cfg

The slot_leds object defines the property sequence which can take a string value (‘action’ or ‘calm’) or a custom sequence.

The custom sequence consists of a list of LED labels {‘top’, ‘middle’, ‘bottom’} arranged in a sequence specifying the order the slot LEDs should turn ON/OFF.

Example: a slot_leds object with the calm sequence
   "slot_leds":{
     "delay_between_steps": 0.5,
     "time_per_step": 1,
     "sequence": "calm"
   },
Example: a slot_leds object with a custom sequence
   "slot_leds":{
     "delay_between_steps": 0.5,
     "time_per_step": 1,
     "sequence":[
       ["top", "bottom"],
       [],
       ["middle"],
       []
     ]
   },

This simple custom sequence will turn ON/OFF the slot LEDs in this order:

1. top + bottom LEDs turned ON
2. All LEDs turned OFF
3. middle LED turned ON
4. All LEDs turned OFF

Each step in the sequence will lasts for time_per_step seconds and there will be a delay of delay_between_steps seconds between each step in the sequence. And the whole sequence will keep on repeating until the script exits by pressing ctrl + c.

See also

The setting slot_leds

Mute breathing sound

To mute Darth Vader’s breathing sound which plays almost as soon as the start_dv script runs, edit the setting sound_effects in the configuration file which can be opened with:

$ start_dv -e cfg

Set the breathing_sound object’s mute to false.

Example: Mute the breathing sound
   "sound_effects": [
     {
       "id": "breathing_sound",
       "name": "Breathing sound",
       "filename": "darth_vader_breathing.ogg",
       "audio_channel_id": 0,
       "mute": false,
       "loops": -1
     }
   ]

See also

Run the script as quiet or verbose

To run the start_dv script as quiet or verbose, open the configuration file with:

$ start_dv -e cfg

And set the setting quiet or verbose to true.

When running the start_dv script as verbose, the logging level is set to DEBUG. Thus, all messages will be displayed and when there is an exception, the traceback will be shown.

On the other hand, when running the start_dv script as quiet, nothing will be printed to the terminal, not even error messages. However, you will still be able to hear sounds and interact with the push buttons or keyboard.

Important

if quiet and verbose are both activated at the same time, only quiet will have an effect.

See also