Skip to content

Commit 7da651a

Browse files
committed
Merge branch 'master' of https://github.com/profezzorn/ProffieOS
2 parents c8a8143 + fe4b652 commit 7da651a

File tree

10 files changed

+105
-98
lines changed

10 files changed

+105
-98
lines changed

common/events.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum BUTTON : uint32_t {
3232
BUTTON_TRIGGER_SIX = 32,
3333
BUTTON_TRIGGER_SEVEN = 64,
3434
BUTTON_TRIGGER_EIGHT = 128,
35-
35+
3636
MODE_ON = 1024,
3737
MODE_OFF = 0,
3838
};

config/crossguard_config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ const unsigned int maxLedsPerStrip = 144;
3131
// This defines how sensitive the clash detection is.
3232
#define CLASH_THRESHOLD_G 1.0
3333

34-
// Define this if your power button is a touch button.
35-
// #define POWER_TOUCHBUTTON_SENSITIVITY 1700
36-
// #define AUX_TOUCHBUTTON_SENSITIVITY 1700
37-
// #define AUX2_TOUCHBUTTON_SENSITIVITY 1700
38-
3934
// If your electonics inverts the bladePin for some reason, define this.
4035
// #define INVERT_WS2811
4136

config/graflex_v1_config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ const unsigned int maxLedsPerStrip = 144;
3232
// This defines how sensitive the clash detection is.
3333
#define CLASH_THRESHOLD_G 1.0
3434

35-
// Define this if your power button is a touch button.
36-
#define POWER_TOUCHBUTTON_SENSITIVITY 1700
37-
// #define AUX_TOUCHBUTTON_SENSITIVITY 1700
38-
// #define AUX2_TOUCHBUTTON_SENSITIVITY 1700
39-
4035
// For V1 electronics, there is an external pullup resistor to measure
4136
// battery voltage. This specifies how many Ohms it is.
4237
#define BATTERY_PULLUP_OHMS 23000

config/owk_v2_config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ const unsigned int maxLedsPerStrip = 144;
3232
// This defines how sensitive the clash detection is.
3333
#define CLASH_THRESHOLD_G 1.5
3434

35-
// Define this if your power button is a touch button.
36-
// #define POWER_TOUCHBUTTON_SENSITIVITY 1700
37-
// #define AUX_TOUCHBUTTON_SENSITIVITY 1700
38-
// #define AUX2_TOUCHBUTTON_SENSITIVITY 1700
39-
4035
// If your electonics inverts the bladePin for some reason, define this.
4136
// #define INVERT_WS2811
4237

config/proffieboard_v1_graflex.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ const unsigned int maxLedsPerStrip = 144;
3232
// This defines how sensitive the clash detection is.
3333
#define CLASH_THRESHOLD_G 2.0
3434

35-
// Define this if your power button is a touch button.
36-
#define POWER_TOUCHBUTTON_SENSITIVITY 1700
37-
// #define AUX_TOUCHBUTTON_SENSITIVITY 1700
38-
// #define AUX2_TOUCHBUTTON_SENSITIVITY 1700
39-
4035
#define BLADE_ID_CLASS EnablePowerBladeID<PowerPINS<bladePowerPin1, bladePowerPin2, bladePowerPin3>, BridgedPullupBladeID<bladeIdentifyPin, blade2Pin>>
4136

4237
// Feature defines, these let you turn off large blocks of code

config/test_bench_config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ const unsigned int maxLedsPerStrip = 144;
3131
// This defines how sensitive the clash detection is.
3232
#define CLASH_THRESHOLD_G 1.0
3333

34-
// Define this if your power button is a touch button.
35-
// #define POWER_TOUCHBUTTON_SENSITIVITY 1700
36-
// #define AUX_TOUCHBUTTON_SENSITIVITY 1700
37-
// #define AUX2_TOUCHBUTTON_SENSITIVITY 1700
38-
3934
// If your electonics inverts the bladePin for some reason, define this.
4035
// #define INVERT_WS2811
4136

config/toy_saber_config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ const unsigned int maxLedsPerStrip = 144;
3131
// This defines how sensitive the clash detection is.
3232
#define CLASH_THRESHOLD_G 1.0
3333

34-
// Define this if your power button is a touch button.
35-
// #define POWER_TOUCHBUTTON_SENSITIVITY 1700
36-
// #define AUX_TOUCHBUTTON_SENSITIVITY 1700
37-
// #define AUX2_TOUCHBUTTON_SENSITIVITY 1700
38-
3934
// If your electonics inverts the bladePin for some reason, define this.
4035
// #define INVERT_WS2811
4136

props/detonator.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Detonator : public PROP_INHERIT_PREFIX PropBase {
2929
NextAction next_action_ = NEXT_ACTION_NOTHING;
3030
uint32_t time_base_;
3131
uint32_t next_event_time_;
32-
32+
3333
void SetNextAction(NextAction what, uint32_t when) {
3434
time_base_ = millis();
3535
next_event_time_ = when;
@@ -60,19 +60,19 @@ class Detonator : public PROP_INHERIT_PREFIX PropBase {
6060
void beginArm() {
6161
SaberBase::SetLockup(SaberBase::LOCKUP_ARMED);
6262
SaberBase::DoBeginLockup();
63-
#ifdef ENABLE_AUDIO
63+
#ifdef ENABLE_AUDIO
6464
float len = hybrid_font.GetCurrentEffectLength();
65-
#else
65+
#else
6666
float len = 1.6;
6767
#endif
6868
SetNextActionF(NEXT_ACTION_ARM, len);
6969
}
7070

7171
void blast() {
7272
SaberBase::DoEndLockup();
73-
#ifdef ENABLE_AUDIO
73+
#ifdef ENABLE_AUDIO
7474
float len = hybrid_font.GetCurrentEffectLength();
75-
#else
75+
#else
7676
float len = 0.0;
7777
#endif
7878
SaberBase::SetLockup(SaberBase::LOCKUP_NONE);

props/saber_sabersense_buttons.h

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,22 @@ COLOUR CHANGE FUNCTIONS WITH BLADE ON
260260
but makes accidental blasts more likely when double-
261261
clicking POWER for Quotes or Force Effect.
262262
263+
#define SABERSENSE_HOT_SKIP_DOWN 23
264+
#define SABERSENSE_HOT_SKIP_LEVEL 9
265+
Hot Skipping is distinct from Font Skipping in that
266+
it skips directly to a given preset, rather than
267+
skipping forwards or backwards x number of presets.
268+
These defines override the Skip-to-Last/Middle
269+
Preset feature, so system skips to user-defined
270+
preset. Note that Skip-to-First preset is fixed
271+
and not user-definable.
272+
273+
#define SABERSENSE_DISABLE_FONT_SKIPPING
274+
Completely disables all preset skipping, meaning
275+
presets may only be cycled through one at a time.
276+
Suitable for installs with small numbers of fonts
277+
and presets.
278+
263279
#define SABERSENSE_BUTTON_CLICKER
264280
Button Clicker to play press/release wav files when
265281
buttons are pressed. Intended for Scavenger hilt
@@ -368,8 +384,13 @@ class SaveArrayStateFile : public ConfigFile {
368384
#define BUTTON_HELD_MEDIUM_TIMEOUT 1000
369385
#endif
370386

371-
#ifndef BUTTON_HELD_LONG_TIMEOUT
372-
#define BUTTON_HELD_LONG_TIMEOUT 2000
387+
// Hot Skip values are placeholders only.
388+
#ifndef SABERSENSE_HOT_SKIP_DOWN
389+
#define SABERSENSE_HOT_SKIP_DOWN 0
390+
#endif
391+
392+
#ifndef SABERSENSE_HOT_SKIP_LEVEL
393+
#define SABERSENSE_HOT_SKIP_LEVEL 0
373394
#endif
374395

375396
EFFECT(dim); // for EFFECT_POWERSAVE
@@ -829,29 +850,44 @@ bool Event2(enum BUTTON button, EVENT event, uint32_t modifiers) override {
829850
return true;
830851
#endif
831852

832-
// Skips to first preset (up) or last preset (down)
833-
// or middle preset if horizontal:
853+
// Skips to first preset (up), last or user-defined preset (down),
854+
// or middle or user-defined preset (horizontal [level]):
834855
#if NUM_BUTTONS == 2
835856
case EVENTID(BUTTON_AUX, EVENT_FIRST_HELD_LONG, MODE_OFF):
836857
#endif
837-
case EVENTID(BUTTON_POWER, EVENT_FIRST_HELD_LONG, MODE_OFF):
838-
#define DEGREES_TO_RADIANS (M_PI / 180)
839-
if (fusor.angle1() > 45 * DEGREES_TO_RADIANS) {
840-
// If pointing up
841-
SetPreset(0, true);
842-
} else if (fusor.angle1() < -45 * DEGREES_TO_RADIANS) {
843-
// If pointing down
844-
SetPreset(-1, true);
858+
case EVENTID(BUTTON_POWER, EVENT_FIRST_HELD_LONG, MODE_OFF): {
859+
CurrentPreset tmp;
860+
tmp.SetPreset(-1);
861+
int num_presets = tmp.preset_num + 1;
862+
863+
int target_preset;
864+
float angle = fusor.angle1();
865+
866+
if (angle > M_PI / 6) {
867+
target_preset = 0;
868+
} else if (angle < -M_PI / 6) {
869+
// Get and check user values. Clamp to last preset if invalid.
870+
int hot_skip_down = (SABERSENSE_HOT_SKIP_DOWN > 0) ? (SABERSENSE_HOT_SKIP_DOWN - 1) : -1;
871+
if (hot_skip_down >= num_presets || hot_skip_down < 0) {
872+
hot_skip_down = num_presets - 1;
873+
}
874+
875+
target_preset = hot_skip_down;
845876
} else {
846-
// If horizontal
847-
CurrentPreset tmp;
848-
tmp.SetPreset(-1);
849-
SetPreset(tmp.preset_num / 2, true);
877+
int hot_skip_level = (SABERSENSE_HOT_SKIP_LEVEL > 0) ? (SABERSENSE_HOT_SKIP_LEVEL - 1) : -1;
878+
if (hot_skip_level >= num_presets || hot_skip_level < 0) {
879+
hot_skip_level = num_presets / 2;
880+
}
881+
882+
target_preset = hot_skip_level;
850883
}
884+
851885
#ifdef SAVE_PRESET
852-
SaveState(current_preset_.preset_num);
886+
SaveState(target_preset);
853887
#endif
854-
return true;
888+
SetPreset(target_preset, true);
889+
break;
890+
}
855891

856892
// BLADE ID OPTIONS AND ARRAY NAVIGATION
857893
// Blade ID on-demand scanning with BladeID audio idents.

sound/playwav.h

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,52 @@
1111
#define UPSCALE_C2 -8191
1212

1313
#if 1
14-
#define UPSAMPLE_FUNC(NAME, EMIT) \
15-
void NAME(int16_t sample) { \
16-
upsample_buf_##NAME##_a_ = upsample_buf_##NAME##_b_; \
17-
upsample_buf_##NAME##_b_ = upsample_buf_##NAME##_c_; \
18-
upsample_buf_##NAME##_c_ = upsample_buf_##NAME##_d_; \
19-
upsample_buf_##NAME##_d_ = sample; \
20-
EMIT(clamptoi16((upsample_buf_##NAME##_a_ * UPSCALE_C2 + \
21-
upsample_buf_##NAME##_b_ * UPSCALE_C1 + \
22-
upsample_buf_##NAME##_c_ * UPSCALE_C1 + \
23-
upsample_buf_##NAME##_d_ * UPSCALE_C2) >> 15)); \
24-
EMIT(upsample_buf_##NAME##_c_); \
25-
} \
26-
void clear_##NAME() { \
27-
upsample_buf_##NAME##_a_ = 0; \
28-
upsample_buf_##NAME##_b_ = 0; \
29-
upsample_buf_##NAME##_c_ = 0; \
30-
upsample_buf_##NAME##_d_ = 0; \
31-
} \
32-
int16_t upsample_buf_##NAME##_a_ = 0; \
33-
int16_t upsample_buf_##NAME##_b_ = 0; \
34-
int16_t upsample_buf_##NAME##_c_ = 0; \
14+
#define UPSAMPLE_FUNC(NAME, EMIT) \
15+
void NAME(int16_t sample) { \
16+
upsample_buf_##NAME##_a_ = upsample_buf_##NAME##_b_; \
17+
upsample_buf_##NAME##_b_ = upsample_buf_##NAME##_c_; \
18+
upsample_buf_##NAME##_c_ = upsample_buf_##NAME##_d_; \
19+
upsample_buf_##NAME##_d_ = sample; \
20+
EMIT(clamptoi16((upsample_buf_##NAME##_a_ * UPSCALE_C2 + \
21+
upsample_buf_##NAME##_b_ * UPSCALE_C1 + \
22+
upsample_buf_##NAME##_c_ * UPSCALE_C1 + \
23+
upsample_buf_##NAME##_d_ * UPSCALE_C2) >> 15)); \
24+
EMIT(upsample_buf_##NAME##_c_); \
25+
} \
26+
void clear_##NAME() { \
27+
upsample_buf_##NAME##_a_ = 0; \
28+
upsample_buf_##NAME##_b_ = 0; \
29+
upsample_buf_##NAME##_c_ = 0; \
30+
upsample_buf_##NAME##_d_ = 0; \
31+
} \
32+
int16_t upsample_buf_##NAME##_a_ = 0; \
33+
int16_t upsample_buf_##NAME##_b_ = 0; \
34+
int16_t upsample_buf_##NAME##_c_ = 0; \
3535
int16_t upsample_buf_##NAME##_d_ = 0
3636
#else
37-
#define UPSAMPLE_FUNC(NAME, EMIT) \
38-
void NAME(int16_t sample) { \
39-
EMIT(sample); EMIT(sample); \
40-
} \
41-
void clear_##NAME() { \
37+
#define UPSAMPLE_FUNC(NAME, EMIT) \
38+
void NAME(int16_t sample) { \
39+
EMIT(sample); EMIT(sample); \
40+
} \
41+
void clear_##NAME() { \
4242
}
4343
#endif
4444

45-
#define DOWNSAMPLE_FUNC(NAME, EMIT) \
46-
void NAME(int16_t sample) { \
47-
if (downsample_flag_##NAME##_) { \
48-
EMIT((downsample_buf_##NAME##_ + sample) >> 1); \
49-
downsample_flag_##NAME##_ = false; \
50-
} else { \
51-
downsample_buf_##NAME##_ = sample; \
52-
downsample_flag_##NAME##_ = true; \
53-
} \
54-
} \
55-
void clear_##NAME() { \
56-
downsample_buf_##NAME##_ = 0; \
57-
downsample_flag_##NAME##_ = false; \
58-
} \
59-
int16_t downsample_buf_##NAME##_ = 0; \
45+
#define DOWNSAMPLE_FUNC(NAME, EMIT) \
46+
void NAME(int16_t sample) { \
47+
if (downsample_flag_##NAME##_) { \
48+
EMIT((downsample_buf_##NAME##_ + sample) >> 1); \
49+
downsample_flag_##NAME##_ = false; \
50+
} else { \
51+
downsample_buf_##NAME##_ = sample; \
52+
downsample_flag_##NAME##_ = true; \
53+
} \
54+
} \
55+
void clear_##NAME() { \
56+
downsample_buf_##NAME##_ = 0; \
57+
downsample_flag_##NAME##_ = false; \
58+
} \
59+
int16_t downsample_buf_##NAME##_ = 0; \
6060
bool downsample_flag_##NAME##_ = false
6161

6262
// PlayWav reads a file from serialflash or SD and converts
@@ -89,6 +89,7 @@ class PlayWav : StateMachine, public ProffieOSAudioStream {
8989
}
9090
PlayLoop(file_id.GetEffect()->GetFollowing());
9191
}
92+
9293
void PlayLoop(Effect* effect) {
9394
effect_.set(effect);
9495
}
@@ -258,7 +259,7 @@ class PlayWav : StateMachine, public ProffieOSAudioStream {
258259
}
259260
break;
260261
}
261-
262+
262263
if (16 != ReadFile(16)) {
263264
default_output->println("Read failed.");
264265
goto fail;
@@ -285,7 +286,7 @@ class PlayWav : StateMachine, public ProffieOSAudioStream {
285286

286287
ptr_ = buffer + 8;
287288
end_ = buffer + 8;
288-
289+
289290
while (true) {
290291
if (wav_) {
291292
if (ReadFile(8) != 8) break;
@@ -428,7 +429,7 @@ class PlayWav : StateMachine, public ProffieOSAudioStream {
428429
// Number of samples_ in samples that has been
429430
// sent out already.
430431
int written_ = 0;
431-
432+
432433
// Number of samples in samples_
433434
int num_samples_ = 0;
434435
int16_t samples_[32];

0 commit comments

Comments
 (0)