From 6d24c5e7f230a25c140f992d4f54123ad3abec69 Mon Sep 17 00:00:00 2001 From: Paul Dino Jones Date: Sat, 18 Jan 2025 13:20:56 -0500 Subject: [PATCH] Add numlights setting --- src/monocoque/devices/serialdevice.c | 3 ++- src/monocoque/devices/simdevice.h | 1 + src/monocoque/helper/confighelper.c | 4 ++++ src/monocoque/helper/confighelper.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/monocoque/devices/serialdevice.c b/src/monocoque/devices/serialdevice.c index dd4d54b..34d0c6e 100644 --- a/src/monocoque/devices/serialdevice.c +++ b/src/monocoque/devices/serialdevice.c @@ -39,7 +39,7 @@ int arduino_shiftlights_update(SimDevice* this, SimData* simdata) int result = 1; - int num_avail_leds = 6; + int num_avail_leds = serialdevice->numlights; int rpm = simdata->rpms; int maxrpm = simdata->maxrpm; int litleds = 0; @@ -197,6 +197,7 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms) { switch (ds->dev_subtype) { case (SIMDEVTYPE_SHIFTLIGHTS): this->devicetype = ARDUINODEV__SHIFTLIGHTS; + this->numlights = ds->serialdevsettings.numlights; this->m.vtable = &arduino_shiftlights_vtable; slogi("Initializing arduino device for shiftlights."); break; diff --git a/src/monocoque/devices/simdevice.h b/src/monocoque/devices/simdevice.h index 57e66ec..4bd965c 100644 --- a/src/monocoque/devices/simdevice.h +++ b/src/monocoque/devices/simdevice.h @@ -52,6 +52,7 @@ typedef struct SerialDeviceType devicetype; // move these two they only apply to the haptic device int motorsposition; + int numlights; int baudrate; double ampfactor; double state; diff --git a/src/monocoque/helper/confighelper.c b/src/monocoque/helper/confighelper.c index e19b26e..3472c48 100644 --- a/src/monocoque/helper/confighelper.c +++ b/src/monocoque/helper/confighelper.c @@ -716,6 +716,10 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co config_setting_lookup_int(device_settings, "motors", &motorposition); ds->serialdevsettings.motorsposition = motorposition; + int numlights = 6; + config_setting_lookup_int(device_settings, "numlights", &numlights); + ds->serialdevsettings.numlights = numlights; + int baud = 9600; config_setting_lookup_int(device_settings, "baud", &baud); ds->serialdevsettings.baud = baud; diff --git a/src/monocoque/helper/confighelper.h b/src/monocoque/helper/confighelper.h index 7f44806..c048ff7 100644 --- a/src/monocoque/helper/confighelper.h +++ b/src/monocoque/helper/confighelper.h @@ -152,6 +152,7 @@ typedef struct { char* portdev; MotorPosition motorsposition; + int numlights; float ampfactor; int baud; }