forked from pure-data/pure-data
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
related to #174
- Loading branch information
Showing
6 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/***************************************************************************** | ||
* Copyright 2019 Serge Poltavsky. All rights reserved. | ||
* | ||
* This file may be distributed under the terms of GNU Public License version | ||
* 3 (GPL v3) as defined by the Free Software Foundation (FSF). A copy of the | ||
* license should have been included with this file, or the project in which | ||
* this file belongs to. You may also find the details of GPL v3 at: | ||
* http://www.gnu.org/licenses/gpl-3.0.txt | ||
* | ||
* If you have any questions regarding the use of this file, feel free to | ||
* contact the author of this file, or the owner of the project in which | ||
* this file belongs to. | ||
*****************************************************************************/ | ||
#include "system_info.h" | ||
#include "ceammc_containers.h" | ||
#include "ceammc_crc32.h" | ||
#include "ceammc_factory.h" | ||
|
||
CEAMMC_DEFINE_SYM(temp) | ||
|
||
SystemInfo::SystemInfo(const PdArgs& args) | ||
: DispatchedObject<BaseObject>(args) | ||
, sysinfo_(nullptr, ceammc_sysinfo_free) | ||
{ | ||
createOutlet(); | ||
|
||
sysinfo_.reset(ceammc_sysinfo_create( | ||
{ // | ||
this, | ||
[](void* user, const char* label, float value) { | ||
auto this_ = static_cast<SystemInfo*>(user); | ||
if (this_) { | ||
AtomArray<2> data { value, gensym(label) }; | ||
this_->anyTo(0, sym_temp(), data.view()); | ||
} | ||
} }, | ||
{ subscriberId(), [](size_t id) { Dispatcher::instance().send({ id, 0 }); } })); | ||
} | ||
|
||
bool SystemInfo::notify(int) | ||
{ | ||
if (sysinfo_) | ||
return ceammc_sysinfo_process(sysinfo_.get()); | ||
else | ||
return false; | ||
} | ||
|
||
void SystemInfo::m_temp(t_symbol* s, const AtomListView& lv) | ||
{ | ||
if (sysinfo_) | ||
ceammc_sysinfo_get_temperature(sysinfo_.get()); | ||
} | ||
|
||
void setup_system_info() | ||
{ | ||
ObjectFactory<SystemInfo> obj("system.info"); | ||
obj.addMethod("temp", &SystemInfo::m_temp); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/***************************************************************************** | ||
* Copyright 2024 Serge Poltavski. All rights reserved. | ||
* | ||
* This file may be distributed under the terms of GNU Public License version | ||
* 3 (GPL v3) as defined by the Free Software Foundation (FSF). A copy of the | ||
* license should have been included with this file, or the project in which | ||
* this file belongs to. You may also find the details of GPL v3 at: | ||
* http://www.gnu.org/licenses/gpl-3.0.txt | ||
* | ||
* If you have any questions regarding the use of this file, feel free to | ||
* contact the author of this file, or the owner of the project in which | ||
* this file belongs to. | ||
*****************************************************************************/ | ||
#ifndef SYSTEM_INFO_H | ||
#define SYSTEM_INFO_H | ||
|
||
#include "ceammc_object.h" | ||
#include "ceammc_poll_dispatcher.h" | ||
#include "system_rust.hpp" | ||
|
||
#include <memory> | ||
using namespace ceammc; | ||
|
||
class SystemInfo : public DispatchedObject<BaseObject> { | ||
std::unique_ptr<ceammc_system_info, void (*)(ceammc_system_info*)> sysinfo_; | ||
|
||
public: | ||
SystemInfo(const PdArgs& args); | ||
|
||
bool notify(int) final; | ||
void m_temp(t_symbol* s, const AtomListView& lv); | ||
}; | ||
|
||
#endif // SYSTEM_INFO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters