Update HX-Joystick.ino
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// FILE: HX-Joystick.ino
|
// FILE: HX-Joystick.ino
|
||||||
// AUTHOR: Didier Aeschimann
|
// AUTHOR: Didier Aeschimann
|
||||||
// PURPOSE: HandBrake Joystick
|
// PURPOSE: HandBrake Joystick for RallyBlock
|
||||||
// URL: https://git.home.daprogs.net/DAProgs/handbrake_joystick/
|
// URL: https://git.home.daprogs.net/DAProgs/handbrake_joystick/
|
||||||
|
|
||||||
|
|
||||||
@@ -19,9 +19,17 @@ HX711 scale;
|
|||||||
|
|
||||||
String readString, servo1, servo2;
|
String readString, servo1, servo2;
|
||||||
|
|
||||||
// adjust pins if needed
|
// Pins for HX711
|
||||||
uint8_t dataPin = 6;
|
uint8_t dataPin = 6;
|
||||||
uint8_t clockPin = 7;
|
uint8_t clockPin = 7;
|
||||||
|
|
||||||
|
bool showConfig;
|
||||||
|
bool showValue;
|
||||||
|
bool showDebug;
|
||||||
|
|
||||||
|
long loadCell;
|
||||||
|
long MinVal=0;
|
||||||
|
long MaxVal=0;
|
||||||
long brake_;
|
long brake_;
|
||||||
long conf_minValue=0;
|
long conf_minValue=0;
|
||||||
long conf_maxValue=13000;
|
long conf_maxValue=13000;
|
||||||
@@ -35,13 +43,6 @@ void setup()
|
|||||||
scale.tare();
|
scale.tare();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool showConfig;
|
|
||||||
bool showValue;
|
|
||||||
bool showDebug;
|
|
||||||
|
|
||||||
long loadCell;
|
|
||||||
long MinVal=0;
|
|
||||||
long MaxVal=0;
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
@@ -61,15 +62,11 @@ void loop()
|
|||||||
if(loadCell > conf_minValue)
|
if(loadCell > conf_minValue)
|
||||||
brake_ = map(loadCell, conf_minValue, (conf_maxValue+1), 0, 1024);
|
brake_ = map(loadCell, conf_minValue, (conf_maxValue+1), 0, 1024);
|
||||||
|
|
||||||
// long test;
|
#ifdef BrakeMode
|
||||||
// test = map(21320,0,21321,0,1023);
|
Joystick.setBrake(brake_);
|
||||||
// Serial.println(test);
|
#else
|
||||||
|
Joystick.setXAxis(brake_);
|
||||||
#ifdef BrakeMode
|
#endif
|
||||||
Joystick.setBrake(brake_);
|
|
||||||
#else
|
|
||||||
Joystick.setXAxis(brake_);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (Serial.available()) {
|
while (Serial.available()) {
|
||||||
if (Serial.available() >0) {
|
if (Serial.available() >0) {
|
||||||
@@ -102,7 +99,7 @@ void loop()
|
|||||||
|
|
||||||
if (showConfig) {
|
if (showConfig) {
|
||||||
showConfig = false;
|
showConfig = false;
|
||||||
Serial.println("DAProgs Handbrake Joystick. v1.0");
|
Serial.println("DAProgs Handbrake Joystick. v1.01");
|
||||||
Serial.println("Configs:");
|
Serial.println("Configs:");
|
||||||
Serial.print(" minVal=");
|
Serial.print(" minVal=");
|
||||||
Serial.println(MinVal);
|
Serial.println(MinVal);
|
||||||
@@ -119,12 +116,10 @@ void loop()
|
|||||||
#else
|
#else
|
||||||
Serial.println(" mode=axis");
|
Serial.println(" mode=axis");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (readString.length() >0) {
|
if (readString.length() >0) {
|
||||||
Serial.println(readString); //see what was received
|
Serial.println(readString); //see what was received
|
||||||
|
|
||||||
@@ -140,8 +135,7 @@ void loop()
|
|||||||
|
|
||||||
readString="";
|
readString="";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
delay(2);
|
delay(2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user