auto-sync
This commit is contained in:
parent
8d1cdf757e
commit
4e588ff8f1
|
@ -103,15 +103,18 @@ extern short currentPageId;
|
||||||
*/
|
*/
|
||||||
LoggingWithStorage tsLogger("binary");
|
LoggingWithStorage tsLogger("binary");
|
||||||
|
|
||||||
extern persistent_config_s configWorkingCopy;
|
/**
|
||||||
|
* this is a local copy of the configuration. Any changes to this copy
|
||||||
|
* have no effect until this copy is explicitly propagated to the main working copy
|
||||||
|
*/
|
||||||
|
persistent_config_s configWorkingCopy;
|
||||||
|
|
||||||
extern persistent_config_container_s persistentState;
|
extern persistent_config_container_s persistentState;
|
||||||
|
|
||||||
static efitimems_t previousWriteReportMs = 0;
|
static efitimems_t previousWriteReportMs = 0;
|
||||||
|
|
||||||
ts_channel_s tsChannel;
|
ts_channel_s tsChannel;
|
||||||
|
|
||||||
extern uint8_t crcWriteBuffer[300];
|
|
||||||
|
|
||||||
static int ts_serial_ready(bool isConsoleRedirect) {
|
static int ts_serial_ready(bool isConsoleRedirect) {
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
if (isSerialOverUart() ^ isConsoleRedirect) {
|
if (isSerialOverUart() ^ isConsoleRedirect) {
|
||||||
|
@ -557,11 +560,6 @@ void syncTunerStudioCopy(void) {
|
||||||
|
|
||||||
tunerstudio_counters_s tsState;
|
tunerstudio_counters_s tsState;
|
||||||
TunerStudioOutputChannels tsOutputChannels;
|
TunerStudioOutputChannels tsOutputChannels;
|
||||||
/**
|
|
||||||
* this is a local copy of the configuration. Any changes to this copy
|
|
||||||
* have no effect until this copy is explicitly propagated to the main working copy
|
|
||||||
*/
|
|
||||||
persistent_config_s configWorkingCopy;
|
|
||||||
|
|
||||||
short currentPageId;
|
short currentPageId;
|
||||||
|
|
||||||
|
|
|
@ -398,7 +398,7 @@ public:
|
||||||
* here we have all the listeners which should be notified about a configuration
|
* here we have all the listeners which should be notified about a configuration
|
||||||
* change
|
* change
|
||||||
*/
|
*/
|
||||||
IntListenerArray configurationListeners;
|
IntListenerArray<15> configurationListeners;
|
||||||
|
|
||||||
monitoring_timestamps_s m;
|
monitoring_timestamps_s m;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
efitick_t nowNt;
|
efitick_t nowNt;
|
||||||
volatile efitime_t previousShaftEventTimeNt;
|
volatile efitime_t previousShaftEventTimeNt;
|
||||||
private:
|
private:
|
||||||
IntListenerArray triggerListeneres;
|
IntListenerArray<15> triggerListeneres;
|
||||||
int hwEventCounters[HW_EVENT_TYPES];
|
int hwEventCounters[HW_EVENT_TYPES];
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,10 +19,8 @@ typedef struct {
|
||||||
bool isActiveHigh; // false for ICU_INPUT_ACTIVE_LOW, true for ICU_INPUT_ACTIVE_HIGH
|
bool isActiveHigh; // false for ICU_INPUT_ACTIVE_LOW, true for ICU_INPUT_ACTIVE_HIGH
|
||||||
volatile bool started;
|
volatile bool started;
|
||||||
|
|
||||||
// todo: make this a template & reduce number of listeners?
|
IntListenerArray<1> widthListeners;
|
||||||
// todo: would one listener be enough?
|
IntListenerArray<1> periodListeners;
|
||||||
IntListenerArray widthListeners;
|
|
||||||
IntListenerArray periodListeners;
|
|
||||||
} digital_input_s;
|
} digital_input_s;
|
||||||
|
|
||||||
void turnOnCapturePin(const char *msg, brain_pin_e brainPin);
|
void turnOnCapturePin(const char *msg, brain_pin_e brainPin);
|
||||||
|
|
|
@ -289,14 +289,14 @@ void firmwareError(const char *errorMsg, ...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char UNUSED_RAM_SIZE[100];
|
static char UNUSED_RAM_SIZE[2100];
|
||||||
|
|
||||||
static char UNUSED_CCM_SIZE[3600] CCM_OPTIONAL;
|
static char UNUSED_CCM_SIZE[8500] CCM_OPTIONAL;
|
||||||
|
|
||||||
int getRusEfiVersion(void) {
|
int getRusEfiVersion(void) {
|
||||||
if (UNUSED_RAM_SIZE[0] != 0)
|
if (UNUSED_RAM_SIZE[0] != 0)
|
||||||
return 123; // this is here to make the compiler happy about the unused array
|
return 123; // this is here to make the compiler happy about the unused array
|
||||||
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
||||||
return 3211; // this is here to make the compiler happy about the unused array
|
return 3211; // this is here to make the compiler happy about the unused array
|
||||||
return 20160630;
|
return 20160705;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,58 +8,3 @@
|
||||||
#include "listener_array.h"
|
#include "listener_array.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
IntListenerArray::IntListenerArray() {
|
|
||||||
currentListenersCount = 0;
|
|
||||||
memset(&args, 0, sizeof(args));
|
|
||||||
memset(&callbacks, 0, sizeof(callbacks));
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntListenerArray::registerCallback(VoidInt handler, void *arg) {
|
|
||||||
efiAssertVoid(currentListenersCount < MAX_INT_LISTENER_COUNT, "Too many callbacks");
|
|
||||||
int index = currentListenersCount++;
|
|
||||||
callbacks[index] = handler;
|
|
||||||
args[index] = arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntListenerArray::registerCallback(Void listener) {
|
|
||||||
registerCallback((VoidInt)listener, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void invokeCallbacks(IntListenerArray *array, int value) {
|
|
||||||
for (int i = 0; i < array->currentListenersCount; i++)
|
|
||||||
(array->callbacks[i])(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntListenerArray::invokeJustArgCallbacks() {
|
|
||||||
for (int i = 0; i < currentListenersCount; i++) {
|
|
||||||
VoidPtr listener = (VoidPtr)callbacks[i];
|
|
||||||
void *arg = args[i];
|
|
||||||
(listener)(arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void invokeArgIntCallbacks(IntListenerArray *array, int value) {
|
|
||||||
for (int i = 0; i < array->currentListenersCount; i++) {
|
|
||||||
ArgIntListener listener = (ArgIntListener)array->callbacks[i];
|
|
||||||
void *arg = array->args[i];
|
|
||||||
(listener)(arg, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void invokeIntIntCallbacks(IntListenerArray *array, int value, int value2) {
|
|
||||||
for (int i = 0; i < array->currentListenersCount; i++) {
|
|
||||||
VoidIntInt listener = (VoidIntInt)array->callbacks[i];
|
|
||||||
(listener)(value, value2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void invokeIntIntVoidCallbacks(IntListenerArray *array, int value, int value2) {
|
|
||||||
for (int i = 0; i < array->currentListenersCount; i++) {
|
|
||||||
IntIntVoidListener listener = (IntIntVoidListener)array->callbacks[i];
|
|
||||||
(listener)(value, value2, array->args[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearCallbacks(IntListenerArray *array) {
|
|
||||||
array->currentListenersCount = 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
#ifndef LISTENER_ARRAY_H_
|
#ifndef LISTENER_ARRAY_H_
|
||||||
#define LISTENER_ARRAY_H_
|
#define LISTENER_ARRAY_H_
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include "rusefi_types.h"
|
#include "rusefi_types.h"
|
||||||
|
#include "error_handling.h"
|
||||||
#define MAX_INT_LISTENER_COUNT 15
|
|
||||||
|
|
||||||
// todo: reorder parameters for consistency?
|
// todo: reorder parameters for consistency?
|
||||||
typedef void (*IntIntVoidListener)(int value1, int value2, void *arg);
|
typedef void (*IntIntVoidListener)(int value1, int value2, void *arg);
|
||||||
|
@ -20,6 +20,7 @@ typedef void (*ArgListener)(void *arg);
|
||||||
typedef void (*ArgIntListener)(void *arg, int value);
|
typedef void (*ArgIntListener)(void *arg, int value);
|
||||||
|
|
||||||
// todo: rename this class, that's not just 'callback(int param) anymore
|
// todo: rename this class, that's not just 'callback(int param) anymore
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
class IntListenerArray {
|
class IntListenerArray {
|
||||||
public:
|
public:
|
||||||
IntListenerArray();
|
IntListenerArray();
|
||||||
|
@ -31,11 +32,88 @@ public:
|
||||||
void * args[MAX_INT_LISTENER_COUNT];
|
void * args[MAX_INT_LISTENER_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
void invokeCallbacks(IntListenerArray *array, int value);
|
//template<int MAX_INT_LISTENER_COUNT>
|
||||||
void invokeJustArgCallbacks(IntListenerArray *array);
|
//void invokeCallbacks(IntListenerArray *array, int value);
|
||||||
void invokeArgIntCallbacks(IntListenerArray *array, int value);
|
//
|
||||||
void invokeIntIntCallbacks(IntListenerArray *array, int value, int value2);
|
//template<int MAX_INT_LISTENER_COUNT>
|
||||||
void invokeIntIntVoidCallbacks(IntListenerArray *array, int value, int value2);
|
//void invokeJustArgCallbacks(IntListenerArray *array);
|
||||||
void clearCallbacks(IntListenerArray *array);
|
//
|
||||||
|
//template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
//void invokeArgIntCallbacks(IntListenerArray *array, int value);
|
||||||
|
//
|
||||||
|
//template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
//void invokeIntIntCallbacks(IntListenerArray *array, int value, int value2);
|
||||||
|
//
|
||||||
|
//template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
//void invokeIntIntVoidCallbacks(IntListenerArray *array, int value, int value2);
|
||||||
|
|
||||||
|
//template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
//void clearCallbacks(IntListenerArray *array);
|
||||||
|
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
IntListenerArray<MAX_INT_LISTENER_COUNT>::IntListenerArray() {
|
||||||
|
currentListenersCount = 0;
|
||||||
|
memset(&args, 0, sizeof(args));
|
||||||
|
memset(&callbacks, 0, sizeof(callbacks));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
void IntListenerArray<MAX_INT_LISTENER_COUNT>::registerCallback(VoidInt handler, void *arg) {
|
||||||
|
efiAssertVoid(currentListenersCount < MAX_INT_LISTENER_COUNT, "Too many callbacks");
|
||||||
|
int index = currentListenersCount++;
|
||||||
|
callbacks[index] = handler;
|
||||||
|
args[index] = arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
void IntListenerArray<MAX_INT_LISTENER_COUNT>::registerCallback(Void listener) {
|
||||||
|
registerCallback((VoidInt)listener, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
void invokeCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array, int value) {
|
||||||
|
for (int i = 0; i < array->currentListenersCount; i++)
|
||||||
|
(array->callbacks[i])(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
void IntListenerArray<MAX_INT_LISTENER_COUNT>::invokeJustArgCallbacks() {
|
||||||
|
for (int i = 0; i < currentListenersCount; i++) {
|
||||||
|
VoidPtr listener = (VoidPtr)callbacks[i];
|
||||||
|
void *arg = args[i];
|
||||||
|
(listener)(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
void invokeArgIntCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array, int value) {
|
||||||
|
for (int i = 0; i < array->currentListenersCount; i++) {
|
||||||
|
ArgIntListener listener = (ArgIntListener)array->callbacks[i];
|
||||||
|
void *arg = array->args[i];
|
||||||
|
(listener)(arg, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
void invokeIntIntCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array, int value, int value2) {
|
||||||
|
for (int i = 0; i < array->currentListenersCount; i++) {
|
||||||
|
VoidIntInt listener = (VoidIntInt)array->callbacks[i];
|
||||||
|
(listener)(value, value2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
void invokeIntIntVoidCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array, int value, int value2) {
|
||||||
|
for (int i = 0; i < array->currentListenersCount; i++) {
|
||||||
|
IntIntVoidListener listener = (IntIntVoidListener)array->callbacks[i];
|
||||||
|
(listener)(value, value2, array->args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int MAX_INT_LISTENER_COUNT>
|
||||||
|
void clearCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array) {
|
||||||
|
array->currentListenersCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* LISTENER_ARRAY_H_ */
|
#endif /* LISTENER_ARRAY_H_ */
|
||||||
|
|
Loading…
Reference in New Issue