-
-
Save robertcedwards/2f7a061af8ccc987aab2 to your computer and use it in GitHub Desktop.
import os | |
import sys | |
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "dll")) | |
import ac | |
import acsys | |
import serial | |
import time | |
#ser = serial.Serial(3, 9600) | |
ser = serial.Serial(port = 'COM4', baudrate = 9600, timeout = 0) | |
count = 0 | |
def acMain(acVersion): | |
# do something with serial library | |
global ser | |
ac.log("called acMain()") | |
time.sleep(3) | |
#ser.write("1:0;".encode()) | |
ser.write("3:17000;".encode()) | |
return "Arduino Serial" | |
def acUpdate(deltaT): | |
global ser,ac,acsys,count | |
if count == 15: | |
value=ac.getCarState(0,acsys.CS.SpeedMPH) | |
value = str(round(value)) | |
toSend="1:" + value + ";" | |
ser.write(toSend.encode()) | |
gear=ac.getCarState(0,acsys.CS.Gear) | |
gear = int(gear) | |
gear = gear - 1 | |
if gear == 0: | |
gear = "n" | |
elif gear == -1: | |
gear = "r" | |
else: | |
gear = str(gear) | |
toSendGear = "2:" + gear + ";" | |
ser.write(toSendGear.encode()) | |
count = 0 | |
else: | |
count = count + 1 | |
def acShutdown(): | |
global ser | |
ac.log("called acShutdown()") | |
ser.close() |
#include <AccelStepper.h> | |
AccelStepper stepper(1, 2, 3); | |
const String keyRev = "1"; | |
int speed; | |
int previous; | |
String vRev = "0"; | |
int delimiter = 59; // means: ; | |
char data[80]; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(13, OUTPUT); | |
pinMode(11, OUTPUT); | |
stepper.setMaxSpeed(1000); | |
stepper.setSpeed(100); | |
stepper.setAcceleration(500); | |
} | |
void loop() | |
{ | |
while (Serial.available() > 0) { | |
Serial.readBytesUntil(delimiter, data, 80); | |
String command = String(data); | |
if (command.substring(0,1) == keyRev) { | |
vRev = command.substring(2); | |
} | |
memset(data, '\0', 80); | |
} | |
if (vRev.toInt() > 5) { | |
speed = vRev.toInt() * 15; | |
stepper.moveTo(speed); | |
stepper.run(); | |
//previous = speed; | |
} | |
else { | |
digitalWrite(11, LOW); | |
} | |
} |
Hi,
if you would like to help me I will really appreciate it!
In need a hand because I'm still getting problems, when I start AC with my App activated, console says that there are some problems with the moule 'App/python/Assetto-dash.py'. I think it's a problem with the directory structure of the modules but I'm not sure about that. Have you any suggestion?
Did you use pySerial or another module?
@pipplalTA Hello! I believe it is using pySerial. Maybe you need to install that as a prerequisite? I'm getting this up and running again for my new sim setup so I'll be installing this again. So I'll let you know what I find...
I think I need some help. I can not add the acsys library to python, it gives an error how can i not do it.
Hi, do you know where do i get the AC module? (pip command maybe?)
@demirkolerme & @andersonvnicius & @pippalTA It looks like you might need to enable Python in Assetto Corsa in
"Documents\Assetto Corsa\cfg\gameplay.ini"
Look for this line and change it to 1
[PYTHON]
ENABLE_PYTHON=1
https://docs.google.com/document/d/13trBp6K1TjWbToUQs_nfFsB291-zVJzRZCNaTYt4Dzc/pub