Fix for programmable outputs not funcitoning

This commit is contained in:
Josh Stewart 2020-08-20 16:58:44 +10:00
parent bb58d02b36
commit 7c3db9b7df
5 changed files with 36 additions and 29 deletions

View File

@ -1151,24 +1151,25 @@ page = 13
outputPin6 = bits U08, 8, [0:7], $comp_IO_Pins
outputPin7 = bits U08, 9, [0:7], $comp_IO_Pins
outputDelay = array, U08, 10, [ 8], "S", 0.1, 0.0, 0.0, 25.5, 1
firstDataIn = array, U16, 18, [ 8], "", 1.0, 0.0, 0.0, 65535.0, 0
firstDataIn0= bits U16, 18, [0:7], $fullStatus_def
firstDataIn1= bits U16, 20, [0:7], $fullStatus_def
firstDataIn2= bits U16, 22, [0:7], $fullStatus_def
firstDataIn3= bits U16, 24, [0:7], $fullStatus_def
firstDataIn4= bits U16, 26, [0:7], $fullStatus_def
firstDataIn5= bits U16, 28, [0:7], $fullStatus_def
firstDataIn6= bits U16, 30, [0:7], $fullStatus_def
firstDataIn7= bits U16, 32, [0:7], $fullStatus_def
secondDataIn = array, U16, 34, [ 8], "", 1.0, 0.0, 0.0, 65535.0, 0
secondDataIn0= bits U16, 34, [0:7], $fullStatus_def
secondDataIn1= bits U16, 36, [0:7], $fullStatus_def
secondDataIn2= bits U16, 38, [0:7], $fullStatus_def
secondDataIn3= bits U16, 40, [0:7], $fullStatus_def
secondDataIn4= bits U16, 42, [0:7], $fullStatus_def
secondDataIn5= bits U16, 44, [0:7], $fullStatus_def
secondDataIn6= bits U16, 46, [0:7], $fullStatus_def
secondDataIn7= bits U16, 48, [0:7], $fullStatus_def
firstDataIn = array, U08, 18, [ 8], "", 1.0, 0.0, 0.0, 65535.0, 0
firstDataIn0= bits U08, 18, [0:7], $fullStatus_def
firstDataIn1= bits U08, 19, [0:7], $fullStatus_def
firstDataIn2= bits U08, 20, [0:7], $fullStatus_def
firstDataIn3= bits U08, 21, [0:7], $fullStatus_def
firstDataIn4= bits U08, 22, [0:7], $fullStatus_def
firstDataIn5= bits U08, 23, [0:7], $fullStatus_def
firstDataIn6= bits U08, 24, [0:7], $fullStatus_def
firstDataIn7= bits U08, 25, [0:7], $fullStatus_def
secondDataIn = array, U08, 26, [ 8], "", 1.0, 0.0, 0.0, 65535.0, 0
secondDataIn0= bits U08, 27, [0:7], $fullStatus_def
secondDataIn1= bits U08, 28, [0:7], $fullStatus_def
secondDataIn2= bits U08, 29, [0:7], $fullStatus_def
secondDataIn3= bits U08, 30, [0:7], $fullStatus_def
secondDataIn4= bits U08, 31, [0:7], $fullStatus_def
secondDataIn5= bits U08, 32, [0:7], $fullStatus_def
secondDataIn6= bits U08, 33, [0:7], $fullStatus_def
secondDataIn7= bits U08, 34, [0:7], $fullStatus_def
unused13_35_49 = array, U08, 35, [ 16] "%", 1.0, 0.0, 0.0, 100.0, 0
firstTarget = array, S16, 50, [ 8], "", 1.0, 0.0, -32768.0, 32768.0, 0
secondTarget = array, S16, 66, [ 8], "", 1.0, 0.0, -32768.0, 32768.0, 0
firstCompType0 = bits, U08, 82, [0:2], $comparator_def

View File

@ -1219,8 +1219,9 @@ struct config13 {
uint8_t unused12_1;
uint8_t outputPin[8];
uint8_t outputDelay[8]; //0.1S
uint16_t firstDataIn[8];
uint16_t secondDataIn[8];
uint8_t firstDataIn[8];
uint8_t secondDataIn[8];
uint8_t unused_13[16];
int16_t firstTarget[8];
int16_t secondTarget[8];
//89bytes

View File

@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "storage.h"
#include "crankMaths.h"
#include "init.h"
#include "utils.h"
#include "engineProtection.h"
#include BOARD_H //Note that this is not a real file, it is defined in globals.h.

View File

@ -22,7 +22,7 @@ These are some utility functions and variables used through the main code
#define BITWISE_XOR 3
uint16_t ioDelay[sizeof(configPage13.outputPin)];
uint8_t outputPin[sizeof(configPage13.outputPin)];
//uint8_t outputPin[sizeof(configPage13.outputPin)];
void setResetControlPinState();
byte pinTranslate(byte);

View File

@ -205,11 +205,10 @@ void initialiseProgrammableIO()
{
for (uint8_t y = 0; y < sizeof(configPage13.outputPin); y++)
{
if (outputPin[y] < BOARD_NR_GPIO_PINS) { outputPin[y] = configPage13.outputPin[y]; }
if ( (outputPin[y] > 0) && (outputPin[y] < BOARD_NR_GPIO_PINS) )
if ( (configPage13.outputPin[y] > 0) && (configPage13.outputPin[y] < BOARD_NR_GPIO_PINS) )
{
pinMode(outputPin[y], OUTPUT);
digitalWrite(outputPin[y], (configPage13.outputInverted & (1U << y)));
pinMode(configPage13.outputPin[y], OUTPUT);
digitalWrite(configPage13.outputPin[y], (configPage13.outputInverted & (1U << y)));
}
}
}
@ -223,8 +222,9 @@ void checkProgrammableIO()
{
firstCheck = false;
secondCheck = false;
if ( outputPin[y] > 0 ) //if outputPin == 0 it is disabled
{
if ( configPage13.outputPin[y] > 0 ) //if outputPin == 0 it is disabled
{
//byte theIndex = configPage13.firstDataIn[y];
data = ProgrammableIOGetData(configPage13.firstDataIn[y]);
data2 = configPage13.firstTarget[y];
@ -254,18 +254,19 @@ void checkProgrammableIO()
if (configPage13.operation[y].bitwise == BITWISE_XOR) { firstCheck ^= secondCheck; }
}
}
if ( (firstCheck == true) && (configPage13.outputDelay[y] != 0) && (configPage13.outputDelay[y] < 255) )
{
if ( (ioDelay[y] >= configPage13.outputDelay[y]) )
{
if (outputPin[y] <= 128) { digitalWrite(outputPin[y], (configPage13.outputInverted & (1U << y)) ^ firstCheck); }
if (configPage13.outputPin[y] <= 128) { digitalWrite(configPage13.outputPin[y], (configPage13.outputInverted & (1U << y)) ^ firstCheck); }
}
else { ioDelay[y]++; }
}
else
{
if ( outputPin[y] <= 128 ) { digitalWrite(outputPin[y], (configPage13.outputInverted & (1U << y)) ^ firstCheck); }
if ( configPage13.outputPin[y] <= 128 ) { digitalWrite(configPage13.outputPin[y], (configPage13.outputInverted & (1U << y)) ^ firstCheck); }
if ( firstCheck == false ) { ioDelay[y] = 0; }
}
if ( firstCheck == true ) { BIT_SET(currentStatus.outputsStatus, y); }
@ -287,6 +288,9 @@ int16_t ProgrammableIOGetData(uint16_t index)
}
if (x >= sizeof(fsIntIndex)) { result = fullStatus[index]; }
else { result = word(fullStatus[index+1], fullStatus[index]); }
//Special cases for temperatures
if( (index == 6) || (index == 7) ) { result -= CALIBRATION_TEMPERATURE_OFFSET; }
}
else { result = -1; } //Index is bigger than fullStatus array
return result;