mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-04-18 03:47:29 +08:00
wip : receive all types of protocols
This commit is contained in:
@@ -36,40 +36,6 @@ int main(int argc, char** argv) {
|
||||
ggWave->setTxMode(GGWave::TxMode::VariableLength);
|
||||
|
||||
printf("Selecting Tx protocol %d\n", txProtocol);
|
||||
switch (txProtocol) {
|
||||
case 0:
|
||||
{
|
||||
printf("Using 'Normal' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 40, 9, 3, 50);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
printf("Using 'Fast' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 40, 6, 3, 50);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
printf("Using 'Fastest' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 40, 3, 3, 50);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
printf("Using 'Ultrasonic' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 320, 9, 3, 50);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
printf("Using 'Fast' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 40, 6, 3, 50);
|
||||
}
|
||||
};
|
||||
printf("\n");
|
||||
|
||||
ggWave->init(0, "");
|
||||
|
||||
std::mutex mutex;
|
||||
std::thread inputThread([&]() {
|
||||
@@ -86,7 +52,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
ggWave->init(input.size(), input.data());
|
||||
ggWave->init(input.size(), input.data(), ggWave->getTxProtocols()[txProtocol]);
|
||||
}
|
||||
inputOld = input;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ GGWave *g_ggWave = nullptr;
|
||||
// JS interface
|
||||
extern "C" {
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
int setText(int textLength, const char * text) {
|
||||
g_ggWave->init(textLength, text);
|
||||
int setText(int textLength, const char * text, int protocolId) {
|
||||
g_ggWave->init(textLength, text, g_ggWave->getTxProtocols()[protocolId]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -77,29 +77,8 @@ extern "C" {
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
int setTxMode(int txMode) {
|
||||
g_ggWave->setTxMode((GGWave::TxMode)(txMode));
|
||||
g_ggWave->init(0, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE
|
||||
void setParameters(
|
||||
int paramFreqDelta,
|
||||
int paramFreqStart,
|
||||
int paramFramesPerTx,
|
||||
int paramBytesPerTx,
|
||||
int /*paramECCBytesPerTx*/,
|
||||
int paramVolume) {
|
||||
if (g_ggWave == nullptr) return;
|
||||
|
||||
g_ggWave->setParameters(
|
||||
paramFreqDelta,
|
||||
paramFreqStart,
|
||||
paramFramesPerTx,
|
||||
paramBytesPerTx,
|
||||
paramVolume);
|
||||
|
||||
g_ggWave->init(0, "");
|
||||
}
|
||||
}
|
||||
|
||||
void GGWave_setDefaultCaptureDeviceName(std::string name) {
|
||||
|
||||
@@ -71,42 +71,6 @@ int main(int argc, char** argv) {
|
||||
|
||||
ggWave->setTxMode(GGWave::TxMode::VariableLength);
|
||||
|
||||
printf("Selecting Tx protocol %d\n", txProtocol);
|
||||
switch (txProtocol) {
|
||||
case 0:
|
||||
{
|
||||
printf("Using 'Normal' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 40, 9, 3, 50);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
printf("Using 'Fast' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 40, 6, 3, 50);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
printf("Using 'Fastest' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 40, 3, 3, 50);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
printf("Using 'Ultrasonic' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 320, 9, 3, 50);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
printf("Using 'Fast' Tx Protocol\n");
|
||||
ggWave->setParameters(1, 40, 6, 3, 50);
|
||||
}
|
||||
};
|
||||
printf("\n");
|
||||
|
||||
ggWave->init(0, "");
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) {
|
||||
fprintf(stderr, "Error: %s\n", SDL_GetError());
|
||||
return -1;
|
||||
@@ -175,7 +139,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (inputCurrent.update) {
|
||||
ggWave->init(inputCurrent.message.data.size(), inputCurrent.message.data.data());
|
||||
ggWave->init(inputCurrent.message.data.size(), inputCurrent.message.data.data(), ggWave->getTxProtocols()[2]);
|
||||
inputCurrent.update = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user