Browse Source

Align stop pin behavior

- Make stop pin pure input without pullup
- Inverse stop pin logic, HIGH level is active break
Alexey Edelev 4 years ago
parent
commit
e3e7e28b47
1 changed files with 5 additions and 5 deletions
  1. 5 5
      Arduino/eScooterControl/accelerationcontrol.cpp

+ 5 - 5
Arduino/eScooterControl/accelerationcontrol.cpp

@@ -49,7 +49,7 @@ const PROGMEM unsigned short AccelerationLevelTable[11] = {
 };
 
 
-AccelerationControl::AccelerationControl() : m_stopState(HIGH)
+AccelerationControl::AccelerationControl() : m_stopState(LOW)
   , m_acceleratorMinValue(0)
   , m_accelerationLevel(0)
   , m_expectedAcceleration(0)
@@ -59,7 +59,7 @@ AccelerationControl::AccelerationControl() : m_stopState(HIGH)
 {
   Wire.begin();
   pinMode(AcceleratorSensorPin, INPUT);
-  pinMode(StopSensorPin, INPUT_PULLUP);
+  pinMode(StopSensorPin, INPUT);
   attachInterrupt(digitalPinToInterrupt(StopSensorPin), []() {
     AccelerationControl::instance()->stop();
   }, CHANGE);
@@ -89,7 +89,7 @@ void AccelerationControl::setAccelerationLevel(const byte level)
 
 void AccelerationControl::dispatch()
 {  
-  if (m_stopState == HIGH) {
+  if (m_stopState == LOW) {
     setAccelerationLevel(readAcceleratorData());
   }
   updateAcceleration();
@@ -97,8 +97,8 @@ void AccelerationControl::dispatch()
 
 void AccelerationControl::stop() {
   m_stopState = digitalRead(StopSensorPin);
-  Display::instance()->setStop(!m_stopState);
-  if (m_stopState == LOW) {
+  Display::instance()->setStop(m_stopState);
+  if (m_stopState == HIGH) {
     m_cruiseLevel = 0; //reset cruise when stop
     setAccelerationLevel(0);
   }