mirror of
https://github.com/ALLFATHER-BV/wadamesh.git
synced 2026-11-07 14:17:18 +00:00
newMsgImpl's chime/vibration decision moves into src/ui-touch/NotifyAlert.h (same rules, a static_assert ties its slots to the prefs' TOUCH_SND_* and TOUCH_CHMUTE_*); the P4's vibrate task takes its beat count from it. test/test_notify_alert.cpp: Do Not Disturb silences both for every event, the master Sound switch only the chime, Vibrate off only the buzz; the per-event switches and channel mutes gate the buzz as they gate the chime; a DM with its switch off does not fall back to the message slot; a muted mention is a plain message; 1, 2 and 3 beats for message, DM and mention. test/test_p4_haptic.cpp runs the production P4Haptic.cpp against a register model of the AW86224 on a fake Wire1 (test/p4_haptic_fakes), each case in its own process: first use loads the 711-byte waveform at 0x0800 and verifies it, the FIFO thresholds match the vendor formula, a retained SRAM is not rewritten and one differing byte reloads it; a buzz plays waveform 1 looped with auto brake at the given gain for exactly its duration and is stopped; 0 or negative durations touch nothing; an absent chip stays off the bus after the first probe; a busy bus skips the buzz; a chip that never idles does not hang; every transaction happens with the I2C_2 bus held. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.9 KiB
C++
57 lines
2.9 KiB
C++
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
//
|
|
// Host test for what a new message sounds and buzzes (#730, src/ui-touch/NotifyAlert.h,
|
|
// used by UITask::newMsgImpl and the T-Display P4's vibrate task).
|
|
//
|
|
// c++ -std=c++17 -Wall -Wextra -I src test/test_notify_alert.cpp -o /tmp/test_notify_alert \
|
|
// && /tmp/test_notify_alert
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
|
|
#include "ui-touch/NotifyAlert.h"
|
|
|
|
using namespace NotifyAlert;
|
|
|
|
static In base() {
|
|
In in{};
|
|
in.snd_mentions = in.snd_direct = in.snd_messages = true;
|
|
in.vibrate_on = true;
|
|
return in;
|
|
}
|
|
|
|
int main() {
|
|
// The three events, everything on: their own slot, chime and buzz.
|
|
{ In in = base(); Out o = decide(in); assert(o.slot == MSG && o.sound && o.vib); }
|
|
{ In in = base(); in.is_dm = true; Out o = decide(in); assert(o.slot == DM && o.sound && o.vib); }
|
|
{ In in = base(); in.is_mention = true; Out o = decide(in); assert(o.slot == MEN && o.sound && o.vib); }
|
|
|
|
// Do Not Disturb: neither, for every event.
|
|
for (int ev = 0; ev < 3; ++ev) {
|
|
In in = base(); in.dnd = true; in.is_dm = ev == 1; in.is_mention = ev == 2;
|
|
Out o = decide(in); assert(!o.sound && !o.vib);
|
|
}
|
|
// Master Sound off: the buzz still comes ("even with Sound off"), the chime does not.
|
|
{ In in = base(); in.sound_quiet = true; Out o = decide(in); assert(o.slot == MSG && !o.sound && o.vib); }
|
|
{ In in = base(); in.sound_quiet = true; in.is_dm = true; Out o = decide(in); assert(o.slot == DM && !o.sound && o.vib); }
|
|
// Vibrate off: the chime only. Both off: nothing.
|
|
{ In in = base(); in.vibrate_on = false; Out o = decide(in); assert(o.sound && !o.vib); }
|
|
{ In in = base(); in.vibrate_on = false; in.sound_quiet = true; Out o = decide(in); assert(o.slot == NONE && !o.sound && !o.vib); }
|
|
|
|
// The per-event switches and channel mutes gate the buzz as they gate the chime.
|
|
{ In in = base(); in.snd_messages = false; Out o = decide(in); assert(o.slot == NONE && !o.vib); }
|
|
{ In in = base(); in.cmute = MUTE_MSG; Out o = decide(in); assert(o.slot == NONE && !o.vib); }
|
|
{ In in = base(); in.is_dm = true; in.snd_direct = false; Out o = decide(in); assert(o.slot == NONE && !o.vib); }
|
|
// A muted DM switch does not fall back to the message slot.
|
|
{ In in = base(); in.is_dm = true; in.snd_direct = false; in.snd_messages = true; assert(decide(in).slot == NONE); }
|
|
// A mention with mentions off (or muted) is a plain message, if messages are on.
|
|
{ In in = base(); in.is_mention = true; in.snd_mentions = false; assert(decide(in).slot == MSG); }
|
|
{ In in = base(); in.is_mention = true; in.cmute = MUTE_MEN; assert(decide(in).slot == MSG); }
|
|
{ In in = base(); in.is_mention = true; in.cmute = MUTE_MEN | MUTE_MSG; assert(decide(in).slot == NONE); }
|
|
|
|
// The pattern plays once for a message, twice for a DM, three times for a mention.
|
|
assert(vibBeats(MSG) == 1 && vibBeats(DM) == 2 && vibBeats(MEN) == 3);
|
|
|
|
printf("test_notify_alert: ok\n");
|
|
return 0;
|
|
}
|