-
Notifications
You must be signed in to change notification settings - Fork 0
Examples
Mikagino edited this page Jul 30, 2026
·
2 revisions
For full game examples look into the Repository's folder Examples where you can find some implementations.
// Setup Sensors
_arsemiCore.AddSensor(new DigitalSensor("Button", 2))
.SetInterval(50)
.AddEvent(_buttonPressEventName, rb => EventCondition.AboveThreshold(rb, 0));
_arsemiCore.AddSensor(new MAX30102Sensor("Heartrate"))
.SetInterval(50)
.AddEvent(_heartrushEventName, rb => EventCondition.BelowThreshold(rb, 50))
.AddFilter(FilterAliases.ButterworthHighPassFilter(100, 10), "Highpass");
// Connect to microcontroller
if(await _arsemiCore.ConnectMicrocontrollerAsync() != MessageParsing.ConnectionResult.SUCCESS)
return;
// _arsemiCore.FinishSetup(); // finishes the setup and sends sensor data to the microcontroller, is not working so this setup must be done manually
// Generate the globals file for accessing the sensorIds, must only be done once but is still recommended to do it
// every time you build the project to mitigate errors later on, when the sensor's order or count is changed
await ConfigSaver.GenerateGlobals(_arsemiCore, PathToConfigDirectory);
_arsemiCore.StartLoop(); // Start the execution and processing of Arsemi-Core
_arsemiCore.EventReceived += HandleEvent; // Connect to own handling function to process the added events
Sensor events work similar to the input systems in many game engines. You check in a function which event has been emitted and then have code for each different event.
public static void HandleEvent(EventData eventData) {
if(eventData.Name == "VerySweaty") {
// insert handling of the event here
}
}