BEEEEEEEEEEEEEEEEEP
This commit is contained in:
@@ -1582,6 +1582,14 @@ var Screen = (function () {
|
||||
'Z': '\u2128',
|
||||
};
|
||||
|
||||
// for BEL
|
||||
var audioCtx = null;
|
||||
try {
|
||||
audioCtx = new (window.AudioContext || window.audioContext || window.webkitAudioContext)();
|
||||
} catch (er) {
|
||||
console.error("Browser does not support AudioContext, can't beep.", er);
|
||||
}
|
||||
|
||||
/** Get cell under cursor */
|
||||
function _curCell() {
|
||||
return screen[cursor.y*W + cursor.x];
|
||||
@@ -1837,6 +1845,34 @@ var Screen = (function () {
|
||||
});
|
||||
}
|
||||
|
||||
function _beep()
|
||||
{
|
||||
var osc, gain;
|
||||
if (!audioCtx) return;
|
||||
|
||||
// Main beep
|
||||
osc = audioCtx.createOscillator();
|
||||
gain = audioCtx.createGain();
|
||||
osc.connect(gain);
|
||||
gain.connect(audioCtx.destination);
|
||||
gain.gain.value = 0.5;
|
||||
osc.frequency.value = 750;
|
||||
osc.type = 'sine';
|
||||
osc.start();
|
||||
osc.stop(audioCtx.currentTime+0.05);
|
||||
|
||||
// Surrogate beep (making it sound like 'oops')
|
||||
osc = audioCtx.createOscillator();
|
||||
gain = audioCtx.createGain();
|
||||
osc.connect(gain);
|
||||
gain.connect(audioCtx.destination);
|
||||
gain.gain.value = 0.2;
|
||||
osc.frequency.value = 400;
|
||||
osc.type = 'sine';
|
||||
osc.start(audioCtx.currentTime+0.05);
|
||||
osc.stop(audioCtx.currentTime+0.08);
|
||||
}
|
||||
|
||||
/** Load screen content from a binary sequence (new) */
|
||||
function load(str) {
|
||||
var content = str.substr(1);
|
||||
@@ -1847,6 +1883,9 @@ var Screen = (function () {
|
||||
case 'T':
|
||||
_load_labels(content);
|
||||
break;
|
||||
case 'B':
|
||||
_beep();
|
||||
break;
|
||||
default:
|
||||
console.warn("Bad data message type, ignoring.");
|
||||
}
|
||||
|
||||
@@ -25,6 +25,14 @@ var Screen = (function () {
|
||||
'Z': '\u2128',
|
||||
};
|
||||
|
||||
// for BEL
|
||||
var audioCtx = null;
|
||||
try {
|
||||
audioCtx = new (window.AudioContext || window.audioContext || window.webkitAudioContext)();
|
||||
} catch (er) {
|
||||
console.error("Browser does not support AudioContext, can't beep.", er);
|
||||
}
|
||||
|
||||
/** Get cell under cursor */
|
||||
function _curCell() {
|
||||
return screen[cursor.y*W + cursor.x];
|
||||
@@ -280,6 +288,34 @@ var Screen = (function () {
|
||||
});
|
||||
}
|
||||
|
||||
function _beep()
|
||||
{
|
||||
var osc, gain;
|
||||
if (!audioCtx) return;
|
||||
|
||||
// Main beep
|
||||
osc = audioCtx.createOscillator();
|
||||
gain = audioCtx.createGain();
|
||||
osc.connect(gain);
|
||||
gain.connect(audioCtx.destination);
|
||||
gain.gain.value = 0.5;
|
||||
osc.frequency.value = 750;
|
||||
osc.type = 'sine';
|
||||
osc.start();
|
||||
osc.stop(audioCtx.currentTime+0.05);
|
||||
|
||||
// Surrogate beep (making it sound like 'oops')
|
||||
osc = audioCtx.createOscillator();
|
||||
gain = audioCtx.createGain();
|
||||
osc.connect(gain);
|
||||
gain.connect(audioCtx.destination);
|
||||
gain.gain.value = 0.2;
|
||||
osc.frequency.value = 400;
|
||||
osc.type = 'sine';
|
||||
osc.start(audioCtx.currentTime+0.05);
|
||||
osc.stop(audioCtx.currentTime+0.08);
|
||||
}
|
||||
|
||||
/** Load screen content from a binary sequence (new) */
|
||||
function load(str) {
|
||||
var content = str.substr(1);
|
||||
@@ -290,6 +326,9 @@ var Screen = (function () {
|
||||
case 'T':
|
||||
_load_labels(content);
|
||||
break;
|
||||
case 'B':
|
||||
_beep();
|
||||
break;
|
||||
default:
|
||||
console.warn("Bad data message type, ignoring.");
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "ansi_parser.h"
|
||||
#include "uart_driver.h"
|
||||
#include "sgr.h"
|
||||
#include "cgi_sockets.h"
|
||||
|
||||
static char utf_collect[4];
|
||||
static int utf_i = 0;
|
||||
@@ -127,8 +128,7 @@ apars_handle_spaceCmd(char c)
|
||||
void ICACHE_FLASH_ATTR
|
||||
apars_handle_bel(void)
|
||||
{
|
||||
ansi_warn("NOIMPL: BEEP");
|
||||
// TODO pass to the browser somehow
|
||||
send_beep();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,6 +64,14 @@ notifyLabelsTimCb(void *arg)
|
||||
notify_available = true;
|
||||
}
|
||||
|
||||
/** Beep */
|
||||
void ICACHE_FLASH_ATTR
|
||||
send_beep(void)
|
||||
{
|
||||
// here's some potential for a race error with the other broadcast functions :C
|
||||
cgiWebsockBroadcast(URL_WS_UPDATE, "B", 1, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Broadcast screen state to sockets.
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
|
||||
#define URL_WS_UPDATE "/term/update.ws"
|
||||
|
||||
#include <cgiwebsocket.h>
|
||||
#include "screen.h"
|
||||
|
||||
/** Update websocket connect callback */
|
||||
void updateSockConnect(Websock *ws);
|
||||
void screen_notifyChange(ScreenNotifyChangeTopic topic);
|
||||
|
||||
void send_beep(void);
|
||||
|
||||
// defined in the makefile
|
||||
#if DEBUG_INPUT
|
||||
#define ws_warn warn
|
||||
|
||||
Reference in New Issue
Block a user