mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
experimental new beeps
This commit is contained in:
parent
16127040f4
commit
4bcafba98a
@ -66,6 +66,8 @@ nn_computer *nn_newComputer(nn_universe *universe, nn_address address, nn_archit
|
|||||||
c->resources[i].id = NN_NULL_RESOURCE;
|
c->resources[i].id = NN_NULL_RESOURCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->hasBeep = false;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,3 +654,21 @@ const char *nn_resource_nextMethodInfo(nn_computer *computer, nn_size_t id, cons
|
|||||||
nn_deviceInfoList_t *nn_getComputerDeviceInfoList(nn_computer *computer) {
|
nn_deviceInfoList_t *nn_getComputerDeviceInfoList(nn_computer *computer) {
|
||||||
return computer->deviceInfo;
|
return computer->deviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nn_computer_clearBeep(nn_computer *computer) {
|
||||||
|
computer->hasBeep = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void nn_computer_setBeep(nn_computer *computer, double frequency, double duration, double volume) {
|
||||||
|
computer->hasBeep = true;
|
||||||
|
computer->beepFrequency = frequency;
|
||||||
|
computer->beepDuration = duration;
|
||||||
|
computer->beepVolume = volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
nn_bool_t nn_computer_getBeep(nn_computer *computer, double *frequency, double *duration, double *volume) {
|
||||||
|
if(frequency != NULL) *frequency = computer->beepFrequency;
|
||||||
|
if(duration != NULL) *duration = computer->beepDuration;
|
||||||
|
if(volume != NULL) *volume = computer->beepVolume;
|
||||||
|
return computer->hasBeep;
|
||||||
|
}
|
||||||
|
@ -207,6 +207,23 @@ static int testLuaArch_computer_uptime(lua_State *L) {
|
|||||||
|
|
||||||
// TODO: beep
|
// TODO: beep
|
||||||
static int testLuaArch_computer_beep(lua_State *L) {
|
static int testLuaArch_computer_beep(lua_State *L) {
|
||||||
|
nn_computer *c = testLuaArch_getComputer(L);
|
||||||
|
// defaults
|
||||||
|
double frequency = 200;
|
||||||
|
double duration = 0.25;
|
||||||
|
double volume = 1;
|
||||||
|
|
||||||
|
if(lua_type(L, 1) == LUA_TNUMBER) {
|
||||||
|
frequency = lua_tonumber(L, 1);
|
||||||
|
}
|
||||||
|
if(lua_type(L, 2) == LUA_TNUMBER) {
|
||||||
|
duration = lua_tonumber(L, 2);
|
||||||
|
}
|
||||||
|
if(lua_type(L, 3) == LUA_TNUMBER) {
|
||||||
|
volume = lua_tonumber(L, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
nn_computer_setBeep(c, frequency, duration, volume);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user