Skip to content

Commit ca7a8c9

Browse files
Cosmetic (#851)
1 parent 1a27ca6 commit ca7a8c9

File tree

9 files changed

+411
-388
lines changed

9 files changed

+411
-388
lines changed

common/battery_monitor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ BatteryMonitor() : reader_(batteryLevelPin,
6969
last_voltage_read_time_ = now;
7070
last_voltage_ = last_voltage_ * mul + v * (1 - mul);
7171
if (IsLow()) {
72-
low_count_++;
72+
low_count_++;
7373
} else {
74-
low_count_ = 0;
74+
low_count_ = 0;
7575
}
7676
}
7777
STATE_MACHINE_END();
@@ -83,7 +83,7 @@ BatteryMonitor() : reader_(batteryLevelPin,
8383
#endif
8484
// Battery isn't low if it's not connected at all.
8585
if (battery() < 0.5) return false;
86-
86+
8787
return battery() < (loaded_ ? 2.6 : 3.0);
8888
}
8989

@@ -159,4 +159,4 @@ class BatteryMonitor {
159159

160160
BatteryMonitor battery_monitor;
161161

162-
#endif
162+
#endif // COMMON_BATTERY_MONITOR_H

common/errors.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ void ProffieOSErrors::font_directory_not_found() {
5252
talkie.Say(talkie_not_found_15, 15);
5353
DodgeSound(2000);
5454
#else
55-
beeper.Beep(0.5, 261.63 * 2); // C5 - Font
55+
beeper.Beep(0.5, 261.63 * 2); // C5 - Font
5656
beeper.Beep(0.5/3, 246.94 * 2); // B4 - di
5757
beeper.Beep(0.5/3, 220.00 * 2); // A4 - rec
5858
beeper.Beep(0.5/3, 196.00 * 2); // G4 - tor
59-
beeper.Beep(0.5, 174.61 * 2); // F4 - y
60-
beeper.Beep(0.5, 146.83 * 2); // D4 - not
61-
beeper.Beep(0.5, 130.81 * 2); // C4 - found
59+
beeper.Beep(0.5, 174.61 * 2); // F4 - y
60+
beeper.Beep(0.5, 146.83 * 2); // D4 - not
61+
beeper.Beep(0.5, 130.81 * 2); // C4 - found
6262
DodgeSound(2530);
6363
#endif
6464
#endif
@@ -99,10 +99,10 @@ void ProffieOSErrors::error_in_blade_array() {
9999
beeper.Beep(0.25, 196.00 * 2); // G4 - or
100100
beeper.Beep(0.25, 174.61 * 2); // F4 - in
101101
beeper.Beep(0.25, 164.81 * 2); // E4 - the
102-
beeper.Beep(0.3, 146.83 * 2); // D4 - blade
103-
beeper.Beep(0.2, 0); // Silence
104-
beeper.Beep(0.5, 146.83 * 2); // D4 - ar
105-
beeper.Beep(1.0, 130.81 * 2); // C4 - ray
102+
beeper.Beep(0.3, 146.83 * 2); // D4 - blade
103+
beeper.Beep(0.2, 0); // Silence
104+
beeper.Beep(0.5, 146.83 * 2); // D4 - ar
105+
beeper.Beep(1.0, 130.81 * 2); // C4 - ray
106106
DodgeSound(3000);
107107
#endif
108108
#endif

common/saber_base.h

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
class SaberBase;
1313
extern SaberBase* saberbases;
1414

15-
1615
// An effect is a one-shot trigger for something
1716
// Effects may have a location, but do not generally have a "duration".
1817
// However, durations may be derived from blade styles or sound effect durations
@@ -34,7 +33,7 @@ extern SaberBase* saberbases;
3433
DEFINE_EFFECT(IGNITION) \
3534
DEFINE_EFFECT(RETRACTION) \
3635
DEFINE_EFFECT(CHANGE) \
37-
/* just for resetting things, not meant for triggering effects, use NEWFONT/BLADEIN/BLADEOUT instead */ \
36+
/* just for resetting things, not meant for triggering effects, use NEWFONT/BLADEIN/BLADEOUT instead */ \
3837
DEFINE_EFFECT(CHDIR) \
3938
DEFINE_EFFECT(NEWFONT) \
4039
DEFINE_EFFECT(BLADEIN) \
@@ -46,13 +45,13 @@ extern SaberBase* saberbases;
4645
DEFINE_EFFECT(ACCENT_SWING) \
4746
DEFINE_EFFECT(ACCENT_SLASH) \
4847
DEFINE_EFFECT(SPIN) \
49-
/* Allows style to turn blade ON for interactive effects if prop/style support, FAST_ON skips PREON. */ \
48+
/* Allows style to turn blade ON for interactive effects if prop/style support, FAST_ON skips PREON. */ \
5049
DEFINE_EFFECT(ON) \
5150
DEFINE_EFFECT(FAST_ON) \
5251
DEFINE_EFFECT(QUOTE) \
5352
DEFINE_EFFECT(SECONDARY_IGNITION) \
5453
DEFINE_EFFECT(SECONDARY_RETRACTION) \
55-
/* Allows style to turn blade OFF for interactive effects if prop/style support, FAST_OFF skips POSTOFF. */ \
54+
/* Allows style to turn blade OFF for interactive effects if prop/style support, FAST_OFF skips POSTOFF. */ \
5655
DEFINE_EFFECT(OFF) \
5756
DEFINE_EFFECT(FAST_OFF) \
5857
DEFINE_EFFECT(OFF_CLASH) \
@@ -172,18 +171,23 @@ class BladeSet {
172171
constexpr BladeSet operator|(const BladeSet& other) const {
173172
return BladeSet(blades_ | other.blades_);
174173
}
174+
175175
constexpr BladeSet operator&(const BladeSet& other) const {
176176
return BladeSet(blades_ & other.blades_);
177177
}
178+
178179
constexpr BladeSet operator~() const {
179180
return BladeSet(~blades_);
180181
}
182+
181183
constexpr bool operator[](int blade) const {
182184
return (blades_ & (1 << blade)) != 0;
183185
}
186+
184187
constexpr bool off() const {
185188
return blades_ == 0;
186189
}
190+
187191
// Should this be if "other" is on, or if anything is on?
188192
// Right now it's if anything is on.
189193
constexpr bool on() const {
@@ -196,6 +200,7 @@ class BladeSet {
196200
void operator|=(const BladeSet& other) {
197201
blades_ |= other.blades_;
198202
}
203+
199204
void operator&=(const BladeSet& other) {
200205
blades_ &= other.blades_;
201206
}
@@ -229,9 +234,11 @@ class EffectLocation {
229234
static EffectLocation rnd() {
230235
return EffectLocation(65535 + random(22937), BladeSet::all());
231236
}
237+
232238
static EffectLocation rnd(BladeSet blades) {
233239
return EffectLocation(65535 + random(22937), blades);
234240
}
241+
235242
BladeSet blades() const { return blades_; }
236243
bool on_blade(int bladenum) const { return blades_[bladenum]; }
237244
uint16_t fixed() const { return location_; }
@@ -241,6 +248,7 @@ class EffectLocation {
241248
p.write('@');
242249
blades_.printTo(p);
243250
}
251+
244252
private:
245253
friend class SaberBase;
246254
uint16_t location_;
@@ -256,7 +264,6 @@ struct BladeEffect {
256264
int wavnum;
257265
};
258266

259-
260267
extern int GetBladeNumber(BladeBase *blade);
261268

262269
class SaberBase {
@@ -269,6 +276,7 @@ class SaberBase {
269276
interrupts();
270277
CHECK_LL(SaberBase, saberbases, next_saber_);
271278
}
279+
272280
void Unlink(const SaberBase* x) {
273281
CHECK_LL(SaberBase, saberbases, next_saber_);
274282
for (SaberBase** i = &saberbases; *i; i = &(*i)->next_saber_) {
@@ -299,12 +307,14 @@ class SaberBase {
299307
// Right now it's if anything is on.
300308
return on_.on();
301309
}
310+
302311
static bool BladeIsOn(int blade) { return on_[blade]; }
303312
static BladeSet OnBlades() { return on_; }
304313
static void TurnOn() {
305314
on_ = EffectLocation::ALL_BLADES;
306315
SaberBase::DoOn(0);
307316
}
317+
308318
static void TurnOn(EffectLocation location) {
309319
PVLOG_DEBUG << "TurnOn " << location << "\n";
310320
// You can't turn on a blade that's already on.
@@ -315,11 +325,13 @@ class SaberBase {
315325
on_ |= location.blades();
316326
SaberBase::DoOn(location);
317327
}
328+
318329
static void TurnOff(OffType off_type) {
319330
on_ = BladeSet();
320331
last_motion_request_ = millis();
321332
SaberBase::DoOff(off_type, 0);
322333
}
334+
323335
static void TurnOff(OffType off_type, EffectLocation location) {
324336
PVLOG_DEBUG << "TurnOff " << location << "\n";
325337
location.blades_ &= on_; // can only turn off blades which are on
@@ -338,6 +350,7 @@ class SaberBase {
338350
return IsOn() || (millis() - last_motion_request_) < 20000;
339351
#endif
340352
}
353+
341354
static void RequestMotion() {
342355
last_motion_request_ = millis();
343356
}
@@ -357,13 +370,15 @@ class SaberBase {
357370
LOCKUP_MELT, // For cutting through doors...
358371
LOCKUP_LIGHTNING_BLOCK, // Lightning block lockup
359372
};
373+
360374
static LockupType lockup_;
361375
static BladeSet lockup_blades_;
362376
static LockupType Lockup() { return lockup_; }
363377
static LockupType LockupForBlade(int blade) {
364378
if (!lockup_blades_[blade]) return LOCKUP_NONE;
365379
return lockup_;
366380
}
381+
367382
static void SetLockup(LockupType lockup, BladeSet blades = BladeSet::all()) {
368383
lockup_ = lockup;
369384
lockup_blades_ = blades;
@@ -422,22 +437,24 @@ public: \
422437

423438
SABERBASEFUNCTIONS();
424439

425-
426440
private:
427441
static void DoEffectInternal2(EffectType effect, EffectLocation location) {
428442
DoEffectInternal(effect, location);
429443
PushEffect(effect, location);
430444
}
445+
431446
public:
432447
static void DoEffect(EffectType effect, EffectLocation location) {
433448
ClearSoundInfo();
434449
DoEffectInternal2(effect, location);
435450
}
451+
436452
static void DoOn(EffectLocation location) {
437453
ClearSoundInfo();
438454
DoOnInternal(location);
439455
DoEffectInternal2(EFFECT_IGNITION, location);
440456
}
457+
441458
static void DoOff(OffType off_type, EffectLocation location) {
442459
ClearSoundInfo();
443460
DoOffInternal(off_type, location);
@@ -454,8 +471,8 @@ public: \
454471
// do nothing
455472
break;
456473
}
457-
458474
}
475+
459476
static void DoBladeDetect(bool detected) {
460477
ClearSoundInfo();
461478
if (detected) {
@@ -464,14 +481,17 @@ public: \
464481
DoEffect(EFFECT_BLADEOUT, 0);
465482
}
466483
}
484+
467485
static void DoChange(ChangeType change_type) {
468486
ClearSoundInfo();
469487
DoChangeInternal(change_type);
470488
}
489+
471490
static void DoTop(uint64_t total_cycles) {
472491
ClearSoundInfo();
473492
DoTopInternal(total_cycles);
474493
}
494+
475495
static void DoIsOn(bool* on) {
476496
ClearSoundInfo();
477497
DoIsOnInternal(on);
@@ -482,6 +502,7 @@ public: \
482502
sound_number = N;
483503
DoEffectInternal2(e, location);
484504
}
505+
485506
static void DoEffectR(EffectType e) { DoEffect(e, EffectLocation::rnd()); }
486507
static void DoBlast() { DoEffectR(EFFECT_BLAST); }
487508
static void DoForce() { DoEffectR(EFFECT_FORCE); }
@@ -509,12 +530,15 @@ public: \
509530
void SetClashStrength(float strength) {
510531
clash_strength_ = strength;
511532
}
533+
512534
static void DoClash() {
513535
DoEffectR(EFFECT_CLASH);
514536
}
537+
515538
static void DoStab() {
516539
DoEffect(EFFECT_STAB, 1.0f);
517540
}
541+
518542
static void UpdateClashStrength(float strength) {
519543
if (strength > clash_strength_) {
520544
clash_strength_ = strength;
@@ -535,6 +559,7 @@ public: \
535559
}
536560
CHECK_LL(SaberBase, saberbases, next_saber_);
537561
}
562+
538563
virtual void SB_Motion(const Vec3& gyro, bool clear) {}
539564

540565
/* Acceleration in g */
@@ -548,6 +573,7 @@ public: \
548573
}
549574
CHECK_LL(SaberBase, saberbases, next_saber_);
550575
}
576+
551577
virtual void SB_Accel(const Vec3& gyro, bool clear) {}
552578

553579
static uint32_t GetCurrentVariation() {
@@ -559,6 +585,7 @@ public: \
559585
current_variation_ += delta;
560586
DoChange(CHANGE_COLOR);
561587
}
588+
562589
// For smooth updates or restore.
563590
static void SetVariation(uint32_t v) {
564591
current_variation_ = v;
@@ -597,7 +624,6 @@ public: \
597624
return num_effects_;
598625
}
599626

600-
601627
// Not private for debugging purposes only.
602628
static uint32_t last_motion_request_;
603629

@@ -644,7 +670,6 @@ public: \
644670
num_effects_ = std::min(num_effects_ + 1, NELEM(effects_));
645671
}
646672

647-
648673
static size_t num_effects_;
649674
static BladeEffect effects_[10];
650675
static BladeSet on_;
@@ -663,4 +688,4 @@ constexpr BladeSet const EffectLocation::ALL_BLADES;
663688
constexpr BladeSet const EffectLocation::MOST_BLADES;
664689
ONCEPERBLADE(DECLARE_BLADE_BITS);
665690

666-
#endif
691+
#endif // COMMON_SABER_BASE_H

props/prop_base.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ class PropBase : CommandParser, protected Looper, protected SaberBase, public Mo
387387
#else
388388
#define WRAP_BLADE_SHORTERNER(N)
389389
#endif
390-
#define SET_BLADE_STYLE(N) do { \
390+
#define SET_BLADE_STYLE(N) do { \
391391
BladeStyle* tmp = style_parser.Parse(current_preset_.GetStyle(N)); \
392-
WRAP_BLADE_SHORTERNER(N) \
393-
current_config->blade##N->SetStyle(tmp); \
392+
WRAP_BLADE_SHORTERNER(N) \
393+
current_config->blade##N->SetStyle(tmp); \
394394
} while (0);
395395

396396
ONCEPERBLADE(SET_BLADE_STYLE)
@@ -434,7 +434,7 @@ class PropBase : CommandParser, protected Looper, protected SaberBase, public Mo
434434
TRACE(PROP, "end");
435435
}
436436

437-
// Set/Update Font & Style, skips Preon effect using FastOn (for use in Edit Mode and "fast" preset changes)
437+
// Set/Update Font & Style, skips Preon effect using FastOn (for use in Edit Mode and "fast" preset changes)
438438
void SetPresetFast(int preset_num) {
439439
PVLOG_DEBUG << "SetPresetFast(" << preset_num << ")\n";
440440
SetPreset(preset_num, false);

sound/effect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,10 +802,10 @@ EFFECT(endauto); // Doesn't exist in fonts, but I expect there may be use for au
802802
EFFECT(blast); // Not to be confused with "blst" and "blaster" as blocking sounds in sabers
803803

804804
// battery low
805-
EFFECT(lowbatt); // battery low
805+
EFFECT(lowbatt); // battery low
806806

807807
// TODO: Optimize this and make it possible
808-
// have the WAV reader use this.
808+
// to have the WAV reader use this.
809809
class EffectFileReader : public FileReader {
810810
public:
811811
EffectFileReader() : FileReader(), do_open_(0) {}

0 commit comments

Comments
 (0)