Assetto Corsa Compe...
 
Notifications
Clear all

Assetto Corsa Competizione turnindicator blinking issue

2 Posts
1 Users
0 Reactions
1,987 Views
(@celicat230)
New Member
Joined: 3 years ago
Posts: 2
Topic starter  

Hi all,

I have the following setup:

E36 Cluster;

Arduino UNO;

Relay module 5v with 8 relays for the cluster symbol lights;

All working perfectly in combination with ETS2 (including the cluster turnindicators).

 

Issue:

With Assetto Corsa Competizione i can't get the turnidicators to work properly.

When activation the turnindicator (left or right) the RAW result shows a constant '1' instead of a blinking state like in ETS2.

 

With the blink formula i managed to get a blinking RAW result state with the formula:

blink('right',750,[DataCorePlugin.GameData.TurnRight])

 

RAW result is showing a False or True state instead of a '0' or '1'.

Unfortunately the relays don't react with this method.

 

I tried to change the shcustomprotocol with no luck:

if (left == true && right == false)
{
digitalWrite(leftPin,LOW);
digitalWrite(rightPin,HIGH);
}

else if (left == false && right == true)
{
digitalWrite(leftPin,HIGH);
digitalWrite(rightPin,LOW);
}

else if (left == true && right == true)
{
digitalWrite(leftPin,LOW);
digitalWrite(rightPin,LOW);

 

Working ETS2/ACC SHCustomProtocol

Spoiler
SHCustomProtocol
#ifndef __SHCUSTOMPROTOCOL_H__
#define __SHCUSTOMPROTOCOL_H__

#include <Arduino.h>

class SHCustomProtocol {
private:

public:

  /*
  CUSTOM PROTOCOL CLASS
  SEE  https://github.com/zegreatclan/SimHub/wiki/Custom-Arduino-hardware-support 

  GENERAL RULES :
    - ALWAYS BACKUP THIS FILE, reinstalling/updating SimHub would overwrite it with the default version.
    - Read data AS FAST AS POSSIBLE in the read function
    - NEVER block the arduino (using delay for instance)
    - Make sure the data read in "read()" function READS ALL THE DATA from the serial port matching the custom protocol definition
    - Idle function is called hundreds of times per second, never use it for slow code, arduino performances would fall
    - If you use library suspending interrupts make sure to use it only in the "read" function when ALL data has been read from the serial port.
      It is the only interrupt safe place

  COMMON FUNCTIONS :
    - FlowSerialReadStringUntil('\n')
      Read the incoming data up to the end (\n) won't be included
    - FlowSerialReadStringUntil(';')
      Read the incoming data up to the separator (;) separator won't be included
    - FlowSerialDebugPrintLn(string)
      Send a debug message to simhub which will display in the log panel and log file (only use it when debugging, it would slow down arduino in run conditions)

  */
  
int BeamLow;
int BeamHigh;
int park;
int left;
int right;
int engine;
int OilPressure;
int RainLights;


int lowbeam = 3;
int HIGH_BEAM = 7;
int parkPin = 8;
int leftPin = 9;
int rightPin = 10;
int checkenginePin = 11;
int OilPressurePin = 12;
int RainLightsPin = 13;


  // Called when starting the arduino (setup method in main sketch)

  void setup() {

pinMode(lowbeam,OUTPUT);
pinMode(HIGH_BEAM,OUTPUT);
pinMode(parkPin,OUTPUT);
pinMode(leftPin,OUTPUT);
pinMode(rightPin,OUTPUT);
pinMode(checkenginePin,OUTPUT);
pinMode(OilPressurePin,OUTPUT);
pinMode(RainLightsPin,OUTPUT);

digitalWrite(lowbeam,HIGH);
digitalWrite(HIGH_BEAM,HIGH);
digitalWrite(parkPin,HIGH);
digitalWrite(leftPin,HIGH);
digitalWrite(rightPin,HIGH);
digitalWrite(checkenginePin,HIGH);
digitalWrite(OilPressurePin,HIGH);
digitalWrite(RainLightsPin,HIGH);
 
  }

  // Called when new data is coming from computer
  void read() {

  int BeamLow = FlowSerialReadStringUntil(';').toInt();
  int BeamHigh = FlowSerialReadStringUntil(';').toInt();
  int park = FlowSerialReadStringUntil(';').toInt();
  int left = FlowSerialReadStringUntil(';').toInt();
  int right = FlowSerialReadStringUntil(';').toInt();
  int engine = FlowSerialReadStringUntil(';').toInt();
  int OilPressure = FlowSerialReadStringUntil(';').toInt();
  int RainLights = FlowSerialReadStringUntil(';').toInt();

/*if(lights == 0)
 {
 digitalWrite(lowbeam, LOW);
} else {
digitalWrite(lowbeam, HIGH);
}
*/
 
if (BeamHigh == 1)
 {
 digitalWrite(HIGH_BEAM, LOW);
} else {
digitalWrite(HIGH_BEAM, HIGH);
}

if (BeamLow == 0) 
{
digitalWrite(lowbeam, HIGH);
} else {
  digitalWrite(lowbeam, LOW);
}

// parkbrake

if(park == 1)
{
  digitalWrite(parkPin, LOW);  
}
else {
  digitalWrite(parkPin, HIGH); 
}

// OilPressure

if(OilPressure == 1)
{
  digitalWrite(OilPressurePin, LOW);  
}
else {
  digitalWrite(OilPressurePin, HIGH); 
}

// RainLights

if(RainLights == 1)
{
  digitalWrite(RainLightsPin, LOW);  
}
else {
  digitalWrite(RainLightsPin, HIGH); 
}

// enginefailure

if(engine == 1)
{
  digitalWrite(checkenginePin, LOW);  
}
else {
  digitalWrite(checkenginePin, HIGH); 
}

  if (left == 1 && right == 0)
  {
   digitalWrite(leftPin,LOW);
   digitalWrite(rightPin,HIGH);
  }

  else if (left == 0 && right == 1)
  {
   digitalWrite(leftPin,HIGH);
   digitalWrite(rightPin,LOW);
  }
  
else if (left == 1 && right == 1)
  {
   digitalWrite(leftPin,LOW);
   digitalWrite(rightPin,LOW);

  }
else

  {
    digitalWrite(leftPin,HIGH);
    digitalWrite(rightPin,HIGH);
  }

  
  }

  // Called once per arduino loop, timing can't be predicted, 
  // but it's called between each command sent to the arduino
  void loop() {


  
  }

  // Called once between each byte read on arduino,
  // THIS IS A CRITICAL PATH :
  // AVOID ANY TIME CONSUMING ROUTINES !!!
  // PREFER READ OR LOOP METHOS AS MUCH AS POSSIBLE
  // AVOID ANY INTERRUPTS DISABLE (serial data would be lost!!!)
  void idle() {
  }
};

#endif

 

 

 

 


   
Quote
(@celicat230)
New Member
Joined: 3 years ago
Posts: 2
Topic starter  

I created a workarround for the turnindicators in ACC. A better solution would be the realtime data from the game)

 

Spoiler
SHCustomProtocol
#ifndef __SHCUSTOMPROTOCOL_H__
#define __SHCUSTOMPROTOCOL_H__

#include <Arduino.h>

class SHCustomProtocol {
private:

public:

  /*
  CUSTOM PROTOCOL CLASS
  SEE  https://github.com/zegreatclan/SimHub/wiki/Custom-Arduino-hardware-support 

  GENERAL RULES :
    - ALWAYS BACKUP THIS FILE, reinstalling/updating SimHub would overwrite it with the default version.
    - Read data AS FAST AS POSSIBLE in the read function
    - NEVER block the arduino (using delay for instance)
    - Make sure the data read in "read()" function READS ALL THE DATA from the serial port matching the custom protocol definition
    - Idle function is called hundreds of times per second, never use it for slow code, arduino performances would fall
    - If you use library suspending interrupts make sure to use it only in the "read" function when ALL data has been read from the serial port.
      It is the only interrupt safe place

  COMMON FUNCTIONS :
    - FlowSerialReadStringUntil('\n')
      Read the incoming data up to the end (\n) won't be included
    - FlowSerialReadStringUntil(';')
      Read the incoming data up to the separator (;) separator won't be included
    - FlowSerialDebugPrintLn(string)
      Send a debug message to simhub which will display in the log panel and log file (only use it when debugging, it would slow down arduino in run conditions)

  */
  
int BeamLow;
int BeamHigh;
int park;
int engine;
int OilPressure;
int RainLights;


int lowbeam = 3;
int HIGH_BEAM = 7;
int parkPin = 8;
int leftPin = 9;
int rightPin = 10;
int checkenginePin = 11;
int OilPressurePin = 12;
int RainLightsPin = 13;

String left;
String right;

  // Called when starting the arduino (setup method in main sketch)

  void setup() {

pinMode(lowbeam,OUTPUT);
pinMode(HIGH_BEAM,OUTPUT);
pinMode(parkPin,OUTPUT);
pinMode(leftPin,OUTPUT);
pinMode(rightPin,OUTPUT);
pinMode(checkenginePin,OUTPUT);
pinMode(OilPressurePin,OUTPUT);
pinMode(RainLightsPin,OUTPUT);

digitalWrite(lowbeam,HIGH);
digitalWrite(HIGH_BEAM,HIGH);
digitalWrite(parkPin,HIGH);
digitalWrite(leftPin,HIGH);
digitalWrite(rightPin,HIGH);
digitalWrite(checkenginePin,HIGH);
digitalWrite(OilPressurePin,HIGH);
digitalWrite(RainLightsPin,HIGH);
 
  }

  // Called when new data is coming from computer
  void read() {

  int BeamLow = FlowSerialReadStringUntil(';').toInt();
  int BeamHigh = FlowSerialReadStringUntil(';').toInt();
  int park = FlowSerialReadStringUntil(';').toInt();
  left = FlowSerialReadStringUntil(';');
  right = FlowSerialReadStringUntil(';');
  int engine = FlowSerialReadStringUntil(';').toInt();
  int OilPressure = FlowSerialReadStringUntil(';').toInt();
  int RainLights = FlowSerialReadStringUntil(';').toInt();

/*if(lights == 0)
 {
 digitalWrite(lowbeam, LOW);
} else {
digitalWrite(lowbeam, HIGH);
}
*/
 
if (BeamHigh == 1)
 {
 digitalWrite(HIGH_BEAM, LOW);
} else {
digitalWrite(HIGH_BEAM, HIGH);
}

if (BeamLow == 0) 
{
digitalWrite(lowbeam, HIGH);
} else {
  digitalWrite(lowbeam, LOW);
}

// parkbrake

if(park == 1)
{
  digitalWrite(parkPin, LOW);  
}
else {
  digitalWrite(parkPin, HIGH); 
}

// OilPressure

if(OilPressure == 1)
{
  digitalWrite(OilPressurePin, LOW);  
}
else {
  digitalWrite(OilPressurePin, HIGH); 
}

// RainLights

if(RainLights == 1)
{
  digitalWrite(RainLightsPin, LOW);  
}
else {
  digitalWrite(RainLightsPin, HIGH); 
}

// enginefailure

if(engine == 1)
{
  digitalWrite(checkenginePin, LOW);  
}
else {
  digitalWrite(checkenginePin, HIGH); 
}

// Turnindicators

  if (left.equalsIgnoreCase("True") && right.equalsIgnoreCase("False"))
  {
   digitalWrite(leftPin,LOW);
   digitalWrite(rightPin,HIGH);
  }

  else if (left.equalsIgnoreCase("False") && right.equalsIgnoreCase("True"))
  {
   digitalWrite(leftPin,HIGH);
   digitalWrite(rightPin,LOW);
  }
  
else if (left.equalsIgnoreCase("True") && right.equalsIgnoreCase("True"))
  {
   digitalWrite(leftPin,LOW);
   digitalWrite(rightPin,LOW);

  }
else

  {
    digitalWrite(leftPin,HIGH);
    digitalWrite(rightPin,HIGH);
  }

  
  }

  // Called once per arduino loop, timing can't be predicted, 
  // but it's called between each command sent to the arduino
  void loop() {


  
  }

  // Called once between each byte read on arduino,
  // THIS IS A CRITICAL PATH :
  // AVOID ANY TIME CONSUMING ROUTINES !!!
  // PREFER READ OR LOOP METHOS AS MUCH AS POSSIBLE
  // AVOID ANY INTERRUPTS DISABLE (serial data would be lost!!!)
  void idle() {
  }
};

#endif

 

Spoiler
NCALC ACC
if([DataCorePlugin.GameRawData.Graphics.LightsStage], '1', '0') 
 + ';' +
if([DataCorePlugin.GameRawData.Graphics.FlashingLights], '1', '0')
 + ';' +
if([DataCorePlugin.GameData.Handbrake], '1', '0')
 + ';' +
blink('links',500,[DataCorePlugin.GameData.TurnIndicatorLeft])
 + ';' +
blink('rechts',500,[DataCorePlugin.GameData.TurnIndicatorRight])
 + ';' +
if([DataCorePlugin.GameData.CarDamage1],'1', '0')
 + ';' +
if([DataCorePlugin.GameData.CarDamage2],
'1', '0')
 + ';' +
if([DataCorePlugin.GameRawData.Graphics.RainLights], '1', '0')

 

I also had to change the NCALC formula for ETS2

 

Spoiler
NCALC ETS2
if([DataCorePlugin.GameRawData.TruckValues.CurrentValues.LightsValues.BeamLow], '1', '0') 
 + ';' +
if([DataCorePlugin.GameRawData.TruckValues.CurrentValues.LightsValues.BeamHigh], '1', '0')
 + ';' +
if([DataCorePlugin.GameRawData.TruckValues.CurrentValues.MotorValues.BrakeValues.ParkingBrake], '1', '0')
 + ';' +
if([DataCorePlugin.GameRawData.TruckValues.CurrentValues.LightsValues.BlinkerLeftOn], 'True', 'False')
 + ';' +
if([DataCorePlugin.GameRawData.TruckValues.CurrentValues.LightsValues.BlinkerRightOn], 'True', 'False')
 + ';' +
if([DataCorePlugin.GameRawData.TruckValues.CurrentValues.DamageValues.Engine] > 0.7, '1', '0')
 + ';' +
if([DataCorePlugin.GameRawData.TruckValues.CurrentValues.DashboardValues.WarningValues.OilPressure], '1', '0')

 

Greetings,

Henk


   
ReplyQuote
Share: