Ajout fonctionnalité de maintien d'état au démarrage
This commit is contained in:
@@ -53,10 +53,7 @@ void setup() {
|
|||||||
pinMode(HEAD_LIGHTS_PIN, INPUT_PULLUP);
|
pinMode(HEAD_LIGHTS_PIN, INPUT_PULLUP);
|
||||||
pinMode(FOG_LIGHTS_PIN, INPUT_PULLUP);
|
pinMode(FOG_LIGHTS_PIN, INPUT_PULLUP);
|
||||||
|
|
||||||
// Initialize ZenDrive Library
|
// Set current states
|
||||||
ZenDrive.begin();
|
|
||||||
|
|
||||||
// Send current states
|
|
||||||
/* Gearshift */
|
/* Gearshift */
|
||||||
if(USE_GEARSHIFT){
|
if(USE_GEARSHIFT){
|
||||||
int value = analogRead(SPEEDS_PIN);
|
int value = analogRead(SPEEDS_PIN);
|
||||||
@@ -70,7 +67,6 @@ void setup() {
|
|||||||
else ZenDrive.switchNeutral();
|
else ZenDrive.switchNeutral();
|
||||||
//Read handbrake
|
//Read handbrake
|
||||||
ZenDrive.setHandbrake(map(analogRead(HANDBRAKE_PIN), 0, 1023, 0, 255));
|
ZenDrive.setHandbrake(map(analogRead(HANDBRAKE_PIN), 0, 1023, 0, 255));
|
||||||
ZenDrive.sendGearshiftStates();
|
|
||||||
}
|
}
|
||||||
/* Pedals module */
|
/* Pedals module */
|
||||||
if(USE_PEDALS){
|
if(USE_PEDALS){
|
||||||
@@ -80,7 +76,6 @@ void setup() {
|
|||||||
ZenDrive.setBrake(map(analogRead(BRAKE_PIN), 0, 1023, 0, 255));
|
ZenDrive.setBrake(map(analogRead(BRAKE_PIN), 0, 1023, 0, 255));
|
||||||
// Read accelerator
|
// Read accelerator
|
||||||
ZenDrive.setAccelerator(map(analogRead(ACCELERATOR_PIN), 0, 1023, 0, 255));
|
ZenDrive.setAccelerator(map(analogRead(ACCELERATOR_PIN), 0, 1023, 0, 255));
|
||||||
ZenDrive.sendPedalsStates();
|
|
||||||
}
|
}
|
||||||
/* Steering wheel module */
|
/* Steering wheel module */
|
||||||
if(USE_WHEEL){
|
if(USE_WHEEL){
|
||||||
@@ -113,8 +108,9 @@ void setup() {
|
|||||||
ZenDrive.setStarter(digitalRead(STARTER_PIN));
|
ZenDrive.setStarter(digitalRead(STARTER_PIN));
|
||||||
// Read direction
|
// Read direction
|
||||||
ZenDrive.setDirection(map(analogRead(DIRECTION_PIN), 0, 1023, -127, 127));
|
ZenDrive.setDirection(map(analogRead(DIRECTION_PIN), 0, 1023, -127, 127));
|
||||||
ZenDrive.sendWheelStates();
|
|
||||||
}
|
}
|
||||||
|
// Initialize ZenDrive Library
|
||||||
|
ZenDrive.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|||||||
@@ -92,20 +92,6 @@ ZenDrive_::ZenDrive_()
|
|||||||
// Setup HID report structure
|
// Setup HID report structure
|
||||||
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
|
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
|
||||||
HID().AppendDescriptor(&node);
|
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()
|
void ZenDrive_::begin()
|
||||||
|
|||||||
Reference in New Issue
Block a user