Skip to content

The CONFIG_TOP section

Fredrik Hubinette edited this page Nov 2, 2019 · 25 revisions

The CONFIG_TOP section is primarily used to set up defines which enable and disable features in the code. However, it is also used to include a board specific config file. Let's start with the required parts:

First, we must include a board config file, basically, we have to pick one of these lines:

#include "v1_config.h"   // TeensySaber V1
#include "v2_config.h"   // TeensySaber V2
#include "v3_config.h"   // TeensySaber V3
#include "proffieboard_v1_config.h"  // Proffieboard V1
#include "proffieboard_v2_config.h"  // Proffieboard V2

Next we must defines how many blades there are. Note that accent leds, crystal chambers and light-up buttons also counts as blades.

#define NUM_BLADES 1

And we must also specify how many buttons we have. Note that this is just used to change how some of the buttons behave, and nothing will actually break if you specify a number different from your actual number of buttons.

#define NUM_BUTTONS 2

Then we specify the volumes. Generally values between 0 and 3000 are useful, but it may depend on what kind of board you have.

#define VOLUME 1000

I don't remember why, but this next number is a constant instead of a define. It specifies how many pixels we can have in a single strip. Note that if you use RGBW pixels, this number needs to be 25% bigger than your actual number of pixels. There is no need to make this smaller if your strips are not 144 pixels long, but you do need to make it bigger if they are more than 144 pixels long.

const unsigned int maxLedsPerStrip = 144;

Next, we have the clash threshold. When two consecutive accelerometer readings differ by this much, a clash is triggered. The unit is in Gs. (About 9.81 newtons.) Larger values will make clashes harder to trigger, smaller values will make clashes easier to trigger.

#define CLASH_THRESHOLD_G 1.0

Finally, we have a set of defines that enable standard features. It's on my TODO list to make these not required:

#define ENABLE_AUDIO
#define ENABLE_MOTION
#define ENABLE_WS2811
#define ENABLE_SD

OPTIONAL defines

This define enables the OLED display code.

#define ENABLE_SSD1306

This code makes it possible to use the same power pins for multiple blades. Note that this is currently EXPERIMENTAL code and may not work properly.

#define SHARED_POWER_PINS

If your board is installed in a different orientation than normal, you may need to add one of the following lines to make ProffieOS behave properly:

#define ORIENTATION ORIENTATION_NORMAL
#define ORIENTATION ORIENTATION_FETS_TOWARDS_BLADE
#define ORIENTATION ORIENTATION_USB_TOWARDS_BLADE
#define ORIENTATION ORIENTATION_SDA_TOWARDS_BLADE
#define ORIENTATION ORIENTATION_SERIAL_TOWARDS_BLADE
#define ORIENTATION ORIENTATION_TOP_TOWARDS_BLADE
#define ORIENTATION ORIENTATION_BOTTOM_TOWARDS_BLADE

Note that SERIAL/SDA towards blade was meant for TeensySabers, so I really should make up new names for them.

This one means that clicking the AUX will also turn the saber on. If not defined, AUX will go to next preset when off.

#define DUAL_POWER_BUTTONS

This enables the serial port, which can be used to talk to a BLE chip.

#define ENABLE_SERIAL

If you have a redbear BLE nano bluetooth chip, you'll need the following three defines to configure it:

#define BLE_PASSWORD "password"
#define BLE_NAME "saber"
#define BLE_SHORTNAME "saber"

The BLE_PASSWORD must be 20 characters or less. BLE_SHORTNAME must be 8 characters or less.

This is only for TeensySaber V1 and enables the serialflash chip on the PJRC prop board

#define ENABLE_SERIALFLASH

This enables the Fastled blade driver, which can be used to drive dotstar blades. This is experimental and may not work properly.

#define ENABLE_FASTLED

To use blade ID in a 3-pin connector, the GND leg of the resistor has to be hooked up to the part that is controlled by FETs. That means that those FETs has to be powered on in order for blade ID to work. This define lets you do that by specifying which FETs needs to be powered while the blade is identified.

#define ENABLE_POWER_FOR_ID PowerPINS<bladePowerPin1,bladePowerPin2,bladePowerPin3>

The following defines are available in ProffieOS 3.x and higher:

By default, some commands which are only useful for developers are normally not compiled into the final binary to save memory, if you want them, add this define to enable them.

#define ENABLE_DEVELOPER_COMMANDS

To save even more memory, you can disable some diagnostic commands like "monitor", "top" and "sdtest" using this define:

#define DISABLE_DIAGNOSTIC_COMMANDS

Proffieboards have some challenges when it comes to BladeID, but it's possible to work around them by adding a bridge to another pin, or by adding a pullup resistor. However, when you do so, you have to use the BLADE_ID_CLASS to specify how the OS should calculate the Blade ID. Chose one of:

#define BLADE_ID_CLASS BridgedPullupBladeID<bladeIdentifyPin, BRIDGED_PIN>
#define BLADE_ID_CLASS ExternalPullupBladeID<bladeIdentifyPin, PULLUP_RESISTANCE>

On-the-fly color changing is new in 3.x. If you want it to save the color change state, add this define to your config file:

#define SAVE_COLOR_CHANGE

ProffieOS has pretty good standby idle time, but if you have accent leds that glow even when the saber is off, that will make your saber run out of batteries pretty fast. This define lets you specify a timeout for such accent leds (in milliseconds), this example would set it to 10 minutes:

 #define IDLE_OFF_TIME 60 * 10 * 1000

If you think color change is annoying, or you just need to save some memory, you can disable the color change feature with this define:

#define DISABLE_COLOR_CHANGE

This define lets you use a pin to detect when a blade is present or not. The pin will work kind of like a latching button which is pressed when there is a blade in the saber. When there is no blade in the saber, NO_BLADE (one billion) will be added to the blade ID.

#define BLADE_DETECT_PIN PIN

With this define, ProffieOS will change which preset your're on and what volume setting you're currently using.

#define SAVE_STATE
Clone this wiki locally