Correctifs de bugs
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// D:\Documents\Simulator project\SimulatorDescriptor.h
|
// D:\Documents\zendrive-simulator\SimulatorDescriptor.h
|
||||||
|
|
||||||
|
|
||||||
char ReportDescriptor[125] = {
|
char ReportDescriptor[122] = {
|
||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||||
0x09, 0x04, // USAGE (Joystick)
|
0x09, 0x04, // USAGE (Joystick)
|
||||||
0xa1, 0x01, // COLLECTION (Application)
|
0xa1, 0x01, // COLLECTION (Application)
|
||||||
@@ -45,8 +45,8 @@ char ReportDescriptor[125] = {
|
|||||||
0xa1, 0x01, // COLLECTION (Application)
|
0xa1, 0x01, // COLLECTION (Application)
|
||||||
0x85, 0x05, // REPORT_ID (5)
|
0x85, 0x05, // REPORT_ID (5)
|
||||||
0x05, 0x09, // USAGE_PAGE (Button)
|
0x05, 0x09, // USAGE_PAGE (Button)
|
||||||
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
0x19, 0x09, // USAGE_MINIMUM (Button 9)
|
||||||
0x29, 0x0b, // USAGE_MAXIMUM (Button 11)
|
0x29, 0x13, // USAGE_MAXIMUM (Button 19)
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||||
0x75, 0x01, // REPORT_SIZE (1)
|
0x75, 0x01, // REPORT_SIZE (1)
|
||||||
@@ -56,15 +56,14 @@ char ReportDescriptor[125] = {
|
|||||||
0x75, 0x05, // REPORT_SIZE (5)
|
0x75, 0x05, // REPORT_SIZE (5)
|
||||||
0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
||||||
0x05, 0x02, // USAGE_PAGE (Simulation Controls)
|
0x05, 0x02, // USAGE_PAGE (Simulation Controls)
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
0x15, 0x81, // LOGICAL_MINIMUM (-127)
|
||||||
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
|
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
|
||||||
0xa1, 0x00, // COLLECTION (Physical)
|
0xa1, 0x00, // COLLECTION (Physical)
|
||||||
0x09, 0xc8, // USAGE (Steering)
|
0x09, 0xc8, // USAGE (Steering)
|
||||||
0x75, 0x08, // REPORT_SIZE (8)
|
0x75, 0x08, // REPORT_SIZE (8)
|
||||||
0x95, 0x01, // REPORT_COUNT (1)
|
0x95, 0x01, // REPORT_COUNT (1)
|
||||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||||
0xc0, // END_COLLECTION
|
0xc0, // END_COLLECTION
|
||||||
0xc0, // END_COLLECTION
|
0xc0 // END_COLLECTION
|
||||||
0x05, 0x01 // USAGE_PAGE (Generic Desktop)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
// Pins declaration
|
// Pins declaration
|
||||||
const int SPEEDS_PIN = A0;
|
const int SPEEDS_PIN = A0;
|
||||||
const int HANDBRAKE_PIN = A5;
|
const int HANDBRAKE_PIN = A1;
|
||||||
const int CLUTCH_PIN = A2;
|
const int CLUTCH_PIN = A2;
|
||||||
const int BRAKE_PIN = A3;
|
const int BRAKE_PIN = A3;
|
||||||
const int ACCELERATOR_PIN = A4;
|
const int ACCELERATOR_PIN = A4;
|
||||||
const int DIRECTION_PIN = A1;
|
const int DIRECTION_PIN = A5;
|
||||||
const int LEFT_BLINKER_PIN = 2;
|
const int LEFT_BLINKER_PIN = 2;
|
||||||
const int RIGHT_BLINKER_PIN = 3;
|
const int RIGHT_BLINKER_PIN = 3;
|
||||||
const int WARNING_PIN = 4;
|
const int WARNING_PIN = 4;
|
||||||
@@ -21,13 +21,15 @@ const int CRUISE_DOWN_PIN = 7;
|
|||||||
const int STARTER_PIN = 8;
|
const int STARTER_PIN = 8;
|
||||||
const int HORN_PIN = 9;
|
const int HORN_PIN = 9;
|
||||||
const int LIGHTS_ON_PIN = 10;
|
const int LIGHTS_ON_PIN = 10;
|
||||||
const int ROAD_LIGHTS_PIN = 11;
|
const int ROAD_LIGHTS_PIN = 16;
|
||||||
const int HEAD_LIGHTS_PIN = 12;
|
const int HEAD_LIGHTS_PIN = 14;
|
||||||
const int FOG_LIGHTS_PIN = 13;
|
const int FOG_LIGHTS_PIN = 15;
|
||||||
|
|
||||||
|
const int INTERVAL = 15;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Initialize sensors
|
// Initialize sensors
|
||||||
pinMode(SPEEDS_PIN, INPUT_PULLUP);
|
pinMode(SPEEDS_PIN, INPUT);
|
||||||
pinMode(HANDBRAKE_PIN, INPUT_PULLUP);
|
pinMode(HANDBRAKE_PIN, INPUT_PULLUP);
|
||||||
pinMode(CLUTCH_PIN, INPUT_PULLUP);
|
pinMode(CLUTCH_PIN, INPUT_PULLUP);
|
||||||
pinMode(BRAKE_PIN, INPUT_PULLUP);
|
pinMode(BRAKE_PIN, INPUT_PULLUP);
|
||||||
@@ -47,10 +49,52 @@ void setup() {
|
|||||||
pinMode(FOG_LIGHTS_PIN, INPUT_PULLUP);
|
pinMode(FOG_LIGHTS_PIN, INPUT_PULLUP);
|
||||||
|
|
||||||
// Initialize ZenDrive Library
|
// Initialize ZenDrive Library
|
||||||
ZenDrive.begin(true);
|
ZenDrive.begin();
|
||||||
|
|
||||||
//Button shared margin
|
// Send current states
|
||||||
int btnMargin = 5;
|
/* Gearshift */
|
||||||
|
int value = analogRead(SPEEDS_PIN);
|
||||||
|
if(value < 200) ZenDrive.switchSpeed1();
|
||||||
|
else if(value < 326) ZenDrive.switchSpeed2();
|
||||||
|
else if(value < 421) ZenDrive.switchSpeed3();
|
||||||
|
else if(value < 493) ZenDrive.switchSpeed4();
|
||||||
|
else if(value < 551) ZenDrive.switchSpeed5();
|
||||||
|
else if(value < 596) ZenDrive.switchSpeed6();
|
||||||
|
else if(value < 634) ZenDrive.switchSpeedR();
|
||||||
|
else ZenDrive.switchNeutral();
|
||||||
|
//Read handbrake
|
||||||
|
ZenDrive.setHandbrake(map(analogRead(HANDBRAKE_PIN), 0, 1023, 0, 255));
|
||||||
|
ZenDrive.sendGearshiftStates();
|
||||||
|
|
||||||
|
/* Pedals module */
|
||||||
|
// Read clutch
|
||||||
|
ZenDrive.setClutch(map(analogRead(CLUTCH_PIN), 0, 1023, 0, 255));
|
||||||
|
// Read brake
|
||||||
|
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 */
|
||||||
|
// Left blinker
|
||||||
|
ZenDrive.setBlinkerLeft(digitalRead(LEFT_BLINKER_PIN));
|
||||||
|
// Right blinker
|
||||||
|
ZenDrive.setBlinkerRight(digitalRead(RIGHT_BLINKER_PIN));
|
||||||
|
// Warning
|
||||||
|
ZenDrive.setWarning(digitalRead(WARNING_PIN));
|
||||||
|
// Lights
|
||||||
|
if (!digitalRead(LIGHTS_ON_PIN)) ZenDrive.switchLightsOn();
|
||||||
|
else if(!digitalRead(ROAD_LIGHTS_PIN)) ZenDrive.switchRoadLights();
|
||||||
|
else ZenDrive.switchLightsOff();
|
||||||
|
// Head lights
|
||||||
|
ZenDrive.setHeadLights(digitalRead(HEAD_LIGHTS_PIN));
|
||||||
|
// Fog lights
|
||||||
|
ZenDrive.setFogLights(digitalRead(FOG_LIGHTS_PIN));
|
||||||
|
// Starter
|
||||||
|
ZenDrive.setStarter(digitalRead(STARTER_PIN));
|
||||||
|
// Read direction
|
||||||
|
ZenDrive.setDirection(map(analogRead(DIRECTION_PIN), 0, 1023, -127, 127));
|
||||||
|
ZenDrive.sendWheelStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@@ -61,14 +105,14 @@ void loop() {
|
|||||||
|
|
||||||
/* Gearshift module */
|
/* Gearshift module */
|
||||||
//Read speed states on the analog shared pin
|
//Read speed states on the analog shared pin
|
||||||
int value = analogRead(A0);
|
int value = analogRead(SPEEDS_PIN);
|
||||||
if(value > 900) ZenDrive.switchSpeedR();
|
if(value < 200) ZenDrive.switchSpeed1();
|
||||||
else if(value > 800) ZenDrive.switchSpeed6();
|
else if(value < 326) ZenDrive.switchSpeed2();
|
||||||
else if(value > 700) ZenDrive.switchSpeed5();
|
else if(value < 421) ZenDrive.switchSpeed3();
|
||||||
else if(value > 600) ZenDrive.switchSpeed4();
|
else if(value < 493) ZenDrive.switchSpeed4();
|
||||||
else if(value > 500) ZenDrive.switchSpeed3();
|
else if(value < 551) ZenDrive.switchSpeed5();
|
||||||
else if(value > 400) ZenDrive.switchSpeed2();
|
else if(value < 596) ZenDrive.switchSpeed6();
|
||||||
else if(value > 300) ZenDrive.switchSpeed1();
|
else if(value < 634) ZenDrive.switchSpeedR();
|
||||||
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));
|
||||||
@@ -93,8 +137,8 @@ void loop() {
|
|||||||
// Warning
|
// Warning
|
||||||
ZenDrive.setWarning(digitalRead(WARNING_PIN));
|
ZenDrive.setWarning(digitalRead(WARNING_PIN));
|
||||||
// Lights
|
// Lights
|
||||||
if (digitalRead(LIGHTS_ON_PIN)) ZenDrive.switchLightsOn();
|
if (!digitalRead(LIGHTS_ON_PIN)) ZenDrive.switchLightsOn();
|
||||||
else if(digitalRead(ROAD_LIGHTS_PIN)) ZenDrive.switchRoadLights();
|
else if(!digitalRead(ROAD_LIGHTS_PIN)) ZenDrive.switchRoadLights();
|
||||||
else ZenDrive.switchLightsOff();
|
else ZenDrive.switchLightsOff();
|
||||||
// Head lights
|
// Head lights
|
||||||
ZenDrive.setHeadLights(digitalRead(HEAD_LIGHTS_PIN));
|
ZenDrive.setHeadLights(digitalRead(HEAD_LIGHTS_PIN));
|
||||||
@@ -103,35 +147,16 @@ void loop() {
|
|||||||
// Starter
|
// Starter
|
||||||
ZenDrive.setStarter(digitalRead(STARTER_PIN));
|
ZenDrive.setStarter(digitalRead(STARTER_PIN));
|
||||||
// Horn
|
// Horn
|
||||||
ZenDrive.setHorn(digitalRead(HORN_PIN));
|
ZenDrive.setHorn(!digitalRead(HORN_PIN));
|
||||||
// Cruise on
|
// Cruise on
|
||||||
if(digitalRead(CRUISE_PIN)) ZenDrive.activeCruise();
|
if(!digitalRead(CRUISE_PIN)) ZenDrive.activeCruise();
|
||||||
// Cruise up
|
// Cruise up
|
||||||
if(digitalRead(CRUISE_UP_PIN)) ZenDrive.increaseCruise();
|
if(!digitalRead(CRUISE_UP_PIN)) ZenDrive.increaseCruise();
|
||||||
// Cruise down
|
// Cruise down
|
||||||
if(digitalRead(CRUISE_DOWN_PIN)) ZenDrive.decreaseCruise();
|
if(!digitalRead(CRUISE_DOWN_PIN)) ZenDrive.decreaseCruise();
|
||||||
// Read direction
|
// Read direction
|
||||||
ZenDrive.setDirection(map(analogRead(DIRECTION_PIN), 0, 1023, -127, 127));
|
ZenDrive.setDirection(map(analogRead(DIRECTION_PIN), 0, 1023, -127, 127));
|
||||||
// Send steering wheel states if they are changes
|
// Send steering wheel states if they are changes
|
||||||
if(ZenDrive.wheelNeedRefresh) ZenDrive.sendWheelStates();
|
if(ZenDrive.wheelNeedRefresh) ZenDrive.sendWheelStates();
|
||||||
|
|
||||||
// Read pin value
|
|
||||||
/*int clutchValue = map(analogRead(clutchPin), 0, 1023, 0, 255);
|
|
||||||
if(clutchValue < lastClutchState - 5 || clutchValue > lastClutchState + 5){
|
|
||||||
//Serial.println(clutchValue);
|
|
||||||
ZenDrive.setHandbrake(clutchValue);
|
|
||||||
lastClutchState = clutchValue;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
/*for (int index = 0; index < 4; index++)
|
|
||||||
{
|
|
||||||
int currentButtonState = !digitalRead(index + pinToButtonMap);
|
|
||||||
if (currentButtonState != lastButtonState[index])
|
|
||||||
{
|
|
||||||
Joystick.setButton(index, currentButtonState);
|
|
||||||
lastButtonState[index] = currentButtonState;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
|||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||||
0x09, 0x04, // USAGE (Joystick)
|
0x09, 0x04, // USAGE (Joystick)
|
||||||
0xa1, 0x01, // COLLECTION (Application)
|
0xa1, 0x01, // COLLECTION (Application)
|
||||||
0x85, GEARSHIFT_REPORT_ID, // REPORT_ID (3)
|
0x85, 0x03, // REPORT_ID (3)
|
||||||
0x05, 0x09, // USAGE_PAGE (Button)
|
0x05, 0x09, // USAGE_PAGE (Button)
|
||||||
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
||||||
0x29, 0x08, // USAGE_MAXIMUM (Button 8)
|
0x29, 0x08, // USAGE_MAXIMUM (Button 8)
|
||||||
@@ -47,7 +47,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
|||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||||
0x09, 0x04, // USAGE (Joystick)
|
0x09, 0x04, // USAGE (Joystick)
|
||||||
0xa1, 0x01, // COLLECTION (Application)
|
0xa1, 0x01, // COLLECTION (Application)
|
||||||
0x85, PEDALS_REPORT_ID, // REPORT_ID (4)
|
0x85, 0x04, // REPORT_ID (4)
|
||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||||
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
|
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
|
||||||
@@ -63,10 +63,10 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
|||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||||
0x09, 0x04, // USAGE (Joystick)
|
0x09, 0x04, // USAGE (Joystick)
|
||||||
0xa1, 0x01, // COLLECTION (Application)
|
0xa1, 0x01, // COLLECTION (Application)
|
||||||
0x85, WHEEL_REPORT_ID, // REPORT_ID (5)
|
0x85, 0x05, // REPORT_ID (5)
|
||||||
0x05, 0x09, // USAGE_PAGE (Button)
|
0x05, 0x09, // USAGE_PAGE (Button)
|
||||||
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
0x19, 0x09, // USAGE_MINIMUM (Button 9)
|
||||||
0x29, 0x0b, // USAGE_MAXIMUM (Button 11)
|
0x29, 0x13, // USAGE_MAXIMUM (Button 19)
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||||
0x75, 0x01, // REPORT_SIZE (1)
|
0x75, 0x01, // REPORT_SIZE (1)
|
||||||
@@ -76,8 +76,8 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
|||||||
0x75, 0x05, // REPORT_SIZE (5)
|
0x75, 0x05, // REPORT_SIZE (5)
|
||||||
0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
||||||
0x05, 0x02, // USAGE_PAGE (Simulation Controls)
|
0x05, 0x02, // USAGE_PAGE (Simulation Controls)
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
0x15, 0x81, // LOGICAL_MINIMUM (-127)
|
||||||
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
|
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
|
||||||
0xa1, 0x00, // COLLECTION (Physical)
|
0xa1, 0x00, // COLLECTION (Physical)
|
||||||
0x09, 0xc8, // USAGE (Steering)
|
0x09, 0xc8, // USAGE (Steering)
|
||||||
0x75, 0x08, // REPORT_SIZE (8)
|
0x75, 0x08, // REPORT_SIZE (8)
|
||||||
@@ -108,7 +108,7 @@ ZenDrive_::ZenDrive_()
|
|||||||
steering = 0;
|
steering = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZenDrive_::begin(bool initAutoSendState)
|
void ZenDrive_::begin()
|
||||||
{
|
{
|
||||||
// Sending initial states
|
// Sending initial states
|
||||||
sendGearshiftStates();
|
sendGearshiftStates();
|
||||||
@@ -293,6 +293,7 @@ void ZenDrive_::setBlinkerLeft(bool value)
|
|||||||
{
|
{
|
||||||
bitSet(wheelCommands, 0);
|
bitSet(wheelCommands, 0);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 0);
|
bitClear(wheelCommands, 0);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
isBlinkerLeft = !isBlinkerLeft;
|
isBlinkerLeft = !isBlinkerLeft;
|
||||||
@@ -305,6 +306,7 @@ void ZenDrive_::setBlinkerRight(bool value)
|
|||||||
{
|
{
|
||||||
bitSet(wheelCommands, 1);
|
bitSet(wheelCommands, 1);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 1);
|
bitClear(wheelCommands, 1);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
isBlinkerRight = !isBlinkerRight;
|
isBlinkerRight = !isBlinkerRight;
|
||||||
@@ -317,6 +319,7 @@ void ZenDrive_::setWarning(bool value)
|
|||||||
{
|
{
|
||||||
bitSet(wheelCommands, 2);
|
bitSet(wheelCommands, 2);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 2);
|
bitClear(wheelCommands, 2);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
isWarning = !isWarning;
|
isWarning = !isWarning;
|
||||||
@@ -332,8 +335,10 @@ void ZenDrive_::switchLightsOn()
|
|||||||
for(int i = 0; i < steps; i++){
|
for(int i = 0; i < steps; i++){
|
||||||
bitSet(wheelCommands, 3);
|
bitSet(wheelCommands, 3);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 3);
|
bitClear(wheelCommands, 3);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
isLights = true;
|
isLights = true;
|
||||||
isRoadLights = false;
|
isRoadLights = false;
|
||||||
}
|
}
|
||||||
@@ -349,8 +354,10 @@ void ZenDrive_::switchRoadLights()
|
|||||||
for(int i = 0; i < steps; i++){
|
for(int i = 0; i < steps; i++){
|
||||||
bitSet(wheelCommands, 3);
|
bitSet(wheelCommands, 3);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 3);
|
bitClear(wheelCommands, 3);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
isLights = false;
|
isLights = false;
|
||||||
isRoadLights = true;
|
isRoadLights = true;
|
||||||
}
|
}
|
||||||
@@ -366,8 +373,10 @@ void ZenDrive_::switchLightsOff()
|
|||||||
for(int i = 0; i < steps; i++){
|
for(int i = 0; i < steps; i++){
|
||||||
bitSet(wheelCommands, 3);
|
bitSet(wheelCommands, 3);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 3);
|
bitClear(wheelCommands, 3);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
isLights = false;
|
isLights = false;
|
||||||
isRoadLights = false;
|
isRoadLights = false;
|
||||||
}
|
}
|
||||||
@@ -380,6 +389,7 @@ void ZenDrive_::setHeadLights(bool value)
|
|||||||
{
|
{
|
||||||
bitSet(wheelCommands, 4);
|
bitSet(wheelCommands, 4);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 4);
|
bitClear(wheelCommands, 4);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
isHeadLights = !isHeadLights;
|
isHeadLights = !isHeadLights;
|
||||||
@@ -392,6 +402,7 @@ void ZenDrive_::setFogLights(bool value)
|
|||||||
{
|
{
|
||||||
bitSet(wheelCommands, 5);
|
bitSet(wheelCommands, 5);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 5);
|
bitClear(wheelCommands, 5);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
isFogLights = !isFogLights;
|
isFogLights = !isFogLights;
|
||||||
@@ -404,6 +415,7 @@ void ZenDrive_::setStarter(bool value)
|
|||||||
{
|
{
|
||||||
bitSet(wheelCommands, 6);
|
bitSet(wheelCommands, 6);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 6);
|
bitClear(wheelCommands, 6);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
isStarter = !isStarter;
|
isStarter = !isStarter;
|
||||||
@@ -416,6 +428,7 @@ void ZenDrive_::setHorn(bool value)
|
|||||||
{
|
{
|
||||||
if(value) bitSet(wheelCommands, 7);
|
if(value) bitSet(wheelCommands, 7);
|
||||||
else bitClear(wheelCommands, 7);
|
else bitClear(wheelCommands, 7);
|
||||||
|
isHorn = !isHorn;
|
||||||
wheelNeedRefresh = true;
|
wheelNeedRefresh = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -424,24 +437,30 @@ void ZenDrive_::activeCruise()
|
|||||||
{
|
{
|
||||||
bitSet(wheelCommands, 8);
|
bitSet(wheelCommands, 8);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 8);
|
bitClear(wheelCommands, 8);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
wheelNeedRefresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZenDrive_::increaseCruise()
|
void ZenDrive_::increaseCruise()
|
||||||
{
|
{
|
||||||
bitSet(wheelCommands, 9);
|
bitSet(wheelCommands, 9);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 9);
|
bitClear(wheelCommands, 9);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
wheelNeedRefresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZenDrive_::decreaseCruise()
|
void ZenDrive_::decreaseCruise()
|
||||||
{
|
{
|
||||||
bitSet(wheelCommands, 10);
|
bitSet(wheelCommands, 10);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
delay(50);
|
||||||
bitClear(wheelCommands, 10);
|
bitClear(wheelCommands, 10);
|
||||||
sendWheelStates();
|
sendWheelStates();
|
||||||
|
wheelNeedRefresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZenDrive_::setDirection(uint8_t value)
|
void ZenDrive_::setDirection(uint8_t value)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
ZenDrive_();
|
ZenDrive_();
|
||||||
|
|
||||||
void begin(bool initAutoSendState = true);
|
void begin();
|
||||||
void end();
|
void end();
|
||||||
|
|
||||||
// Gearshift module
|
// Gearshift module
|
||||||
@@ -66,7 +66,6 @@ public:
|
|||||||
void switchSpeed5();
|
void switchSpeed5();
|
||||||
void switchSpeed6();
|
void switchSpeed6();
|
||||||
void switchSpeedR();
|
void switchSpeedR();
|
||||||
int currentHandbrake = 0;
|
|
||||||
void setHandbrake(int8_t value);
|
void setHandbrake(int8_t value);
|
||||||
|
|
||||||
// Pedals module
|
// Pedals module
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ const int SHARED_BUTTONS = A1;
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
pinMode(SHARED_BUTTONS, INPUT_PULLUP);
|
pinMode(SHARED_BUTTONS, INPUT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
Serial.println(analogRead(SHARED_BUTTONS));
|
Serial.println(analogRead(SHARED_BUTTONS));
|
||||||
delay(50);
|
delay(250);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user