Ajout fonctionnalité de maintien d'état au démarrage

This commit is contained in:
=
2021-01-27 14:35:40 +01:00
parent 562a43a6dd
commit 56e5041c5f
2 changed files with 3 additions and 21 deletions

View File

@@ -53,10 +53,7 @@ void setup() {
pinMode(HEAD_LIGHTS_PIN, INPUT_PULLUP);
pinMode(FOG_LIGHTS_PIN, INPUT_PULLUP);
// Initialize ZenDrive Library
ZenDrive.begin();
// Send current states
// Set current states
/* Gearshift */
if(USE_GEARSHIFT){
int value = analogRead(SPEEDS_PIN);
@@ -70,7 +67,6 @@ void setup() {
else ZenDrive.switchNeutral();
//Read handbrake
ZenDrive.setHandbrake(map(analogRead(HANDBRAKE_PIN), 0, 1023, 0, 255));
ZenDrive.sendGearshiftStates();
}
/* Pedals module */
if(USE_PEDALS){
@@ -80,7 +76,6 @@ void setup() {
ZenDrive.setBrake(map(analogRead(BRAKE_PIN), 0, 1023, 0, 255));
// Read accelerator
ZenDrive.setAccelerator(map(analogRead(ACCELERATOR_PIN), 0, 1023, 0, 255));
ZenDrive.sendPedalsStates();
}
/* Steering wheel module */
if(USE_WHEEL){
@@ -113,8 +108,9 @@ void setup() {
ZenDrive.setStarter(digitalRead(STARTER_PIN));
// Read direction
ZenDrive.setDirection(map(analogRead(DIRECTION_PIN), 0, 1023, -127, 127));
ZenDrive.sendWheelStates();
}
// Initialize ZenDrive Library
ZenDrive.begin();
}
void loop() {

View File

@@ -92,20 +92,6 @@ ZenDrive_::ZenDrive_()
// Setup HID report structure
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
HID().AppendDescriptor(&node);
// Initalize state for each module
// Gearshift module
speeds = B00000001; // (NEUTRAL;SPEED1;SPEED2;SPEED3;SPEED4;SPEED5;SPEED6;SPEEDR)
handbrake = 255;
//Pedals module
clutch = 0;
brake = 0;
accelerator = 0;
//Steering wheel module
wheelCommands = 0; // (BLINKER LEFT;BLINKER RIGHT;WARNING;LIGHTS;HEADLIGHTS;FOGLIGHTS;STARTER;HORN;CRUISE;CRUISE +;CRUISE -;NOT USED;NOT USED;NOT USED;NOT USED;NOT USED)
steering = 0;
}
void ZenDrive_::begin()