1
- #ifdef USE_DEVICE
2
-
3
1
#include " ../../uCtrl.h"
4
2
#include " device.hpp"
5
3
@@ -163,7 +161,7 @@ bool Device::handleAnalogEvent(uint8_t port, uint16_t value, uint8_t interrupted
163
161
{
164
162
// static uint16_t address;
165
163
166
- --port;
164
+ // --port;
167
165
if ( _remote.adc_port [port].event_address != 1023 ) { // >= 0 ) {
168
166
// Handler dispatcher
169
167
_ctrl.port = port+1 ;
@@ -184,8 +182,7 @@ bool Device::handleAnalogEvent(uint8_t port, uint16_t value, uint8_t interrupted
184
182
185
183
bool Device::handleDigitalEvent (uint8_t port, uint16_t value, uint8_t interrupted)
186
184
{
187
- --port;
188
-
185
+ // --port;
189
186
if ( _remote.din_port [port].event_address != 1023 ) { // != -1 ) {
190
187
// _ctrl.port = port+1;
191
188
#if defined(USE_DEVICE_LABELS)
@@ -231,7 +228,7 @@ bool Device::handleDigitalEvent(uint8_t port, uint16_t value, uint8_t interrupte
231
228
void Device::setupCtrl (uint8_t port, uint16_t value)
232
229
{
233
230
uint8_t size_of_ports;
234
- --port;
231
+ // --port;
235
232
236
233
// 1023 default value we got no _remote.adc_port[port].device_id
237
234
if ( _remote.adc_port [port].event_address == 1023 ) {
@@ -286,7 +283,7 @@ void Device::clearMap(uint8_t device_id)
286
283
#endif
287
284
}
288
285
289
- void Device::eventMap (uint8_t device_id, CONTROL_DATA * event, uint8_t * eventName = NULL , int16_t label_offset = 0 )
286
+ void Device::eventMap (uint8_t device_id, CONTROL_DATA * event, uint8_t * eventName, int16_t label_offset)
290
287
{
291
288
uint16_t memory_address;
292
289
@@ -421,7 +418,7 @@ void Device::getDeviceMapEventData(uint8_t device_id, uint16_t event_address, CO
421
418
uint8_t * Device::getDeviceName (uint8_t device_id)
422
419
{
423
420
if ( device_id > _device_number ) {
424
- return ;
421
+ return nullptr ;
425
422
}
426
423
if ( device_id == 0 ) {
427
424
device_id = _selected_device;
@@ -544,7 +541,7 @@ void Device::editCtrlsetDevice(int8_t inc, uint8_t port)
544
541
if ( event.data_label != 65535 ) {
545
542
memcpy (_ctrl.data_label , getDataLabel (_remote.adc_port [port].device_id , event.data_label , _edit_ctrl_last_value), 16 );
546
543
} else {
547
- sprintf (_ctrl.data_label , " %-8d" , event.label_offset + _edit_ctrl_last_value);
544
+ sprintf (( char *) _ctrl.data_label , " %-8d" , event.label_offset + _edit_ctrl_last_value);
548
545
// sprintf (_ctrl.data_label, "%d", event.label_offset + _edit_ctrl_last_value);
549
546
}
550
547
/*
@@ -605,7 +602,7 @@ void Device::editCtrlsetCtrl(int8_t inc, uint8_t port)
605
602
if ( event.data_label != 65535 ) {
606
603
memcpy (_ctrl.data_label , getDataLabel (_remote.adc_port [port].device_id , event.data_label , _edit_ctrl_last_value), 16 );
607
604
} else {
608
- sprintf (_ctrl.data_label , " %-8d" , event.label_offset + _edit_ctrl_last_value);
605
+ sprintf (( char *) _ctrl.data_label , " %-8d" , event.label_offset + _edit_ctrl_last_value);
609
606
// sprintf (_ctrl.data_label, "%d", event.label_offset + _edit_ctrl_last_value);
610
607
}
611
608
/*
@@ -827,19 +824,17 @@ void Device::remoteEventHandler(CONTROL_DATA * event, uint8_t device_id, uint16_
827
824
828
825
switch (event->type ) {
829
826
830
- #ifdef USE_MIDI
831
827
case uctrl::MIDI_ANALOG:
832
828
case uctrl::MIDI_TRIGGER:
833
829
case uctrl::MIDI_BUTTON:
834
830
if ( interrupted == 1 ) {
835
831
if ( uCtrl.midi != nullptr && _ctrl_mode != 1 ) {
836
- uCtrl.midi ->sendMessage (eventToMidiMsg (event, value, _device[device_id].chn ), _device[device_id].port +1 , 0 , event->config );
832
+ uCtrl.midi ->sendMessage (eventToMidiMsg (event, value, _device[device_id].chn ), _device[device_id].port +1 , interrupted , event->config );
837
833
}
838
834
return ;
839
835
} else {
840
836
break ;
841
837
}
842
- #endif
843
838
844
839
// this is non realtime action, so always return if its interrupted
845
840
case uctrl::APP_CTRL:
@@ -860,6 +855,9 @@ void Device::remoteEventHandler(CONTROL_DATA * event, uint8_t device_id, uint16_
860
855
// the comming piece of code should only be processed if interrupted == 0, or face the consequences...
861
856
862
857
#ifdef USE_DEVICE_LABELS
858
+ if ( uCtrl.oled == nullptr )
859
+ return ;
860
+
863
861
// TODO: dont use oled object here... go for callback solution!
864
862
// if event name has a # on it means do not show feedback, do it silent
865
863
if ( event->name [0 ] != ' #' ) {
@@ -870,7 +868,7 @@ void Device::remoteEventHandler(CONTROL_DATA * event, uint8_t device_id, uint16_
870
868
if ( event->data_label != 65535 ) {
871
869
memcpy (_ctrl.data_label , getDataLabel (device_id, event->data_label , value), 16 );
872
870
} else {
873
- sprintf (_ctrl.data_label , " %-8d" , event->label_offset + value);
871
+ sprintf (( char *) _ctrl.data_label , " %-8d" , event->label_offset + value);
874
872
// sprintf (_ctrl.data_label, "%d", event->label_offset + value);
875
873
}
876
874
if ( _data_feedback_show == false ) {
@@ -972,13 +970,13 @@ void Device::sendEvent(uint16_t eventAddress, uint8_t device_id, uint16_t value)
972
970
*/
973
971
void Device::lockControl (uint8_t remote_port)
974
972
{
975
- #ifdef USE_AIN
976
- if ( remote_port == 0 ) {
977
- uCtrl.ain ->lockAllControls ();
978
- } else {
979
- uCtrl.ain ->lockControl (remote_port-1 );
973
+ if ( uCtrl.ain != nullptr ) {
974
+ if ( remote_port == 0 ) {
975
+ uCtrl.ain ->lockAllControls ();
976
+ } else {
977
+ uCtrl.ain ->lockControl (remote_port-1 );
978
+ }
980
979
}
981
- #endif
982
980
}
983
981
/*
984
982
// Special shift button with n taps support
@@ -1077,10 +1075,8 @@ bool Device::isPressed(uint8_t port)
1077
1075
#endif
1078
1076
*/
1079
1077
1080
- #ifdef USE_DIN
1081
- return uCtrl.din ->getDataRaw (port);
1082
- #endif
1083
-
1078
+ if ( uCtrl.din != nullptr )
1079
+ return uCtrl.din ->getDataRaw (port);
1084
1080
}
1085
1081
1086
1082
void Device::ctrlMap (uint8_t device_id, uint16_t control_id, uint16_t range_min, uint16_t range_max, int16_t label_offset, uint8_t * name)
@@ -1355,5 +1351,4 @@ const uint8_t * Device::getDataLabel(uint8_t device_id, uint16_t address, uint16
1355
1351
1356
1352
} }
1357
1353
1358
- uctrl::module::Device device_module;
1359
- #endif
1354
+ // uctrl::module::Device device_module;
0 commit comments