-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38586c8
commit e53149f
Showing
5 changed files
with
93 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/*!` | ||
/*! | ||
* \file io_expanders_mock.cpp | ||
* | ||
* This file is part of AYAB. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*! | ||
* \file knitting_machine_adapter.cpp | ||
* | ||
* This file is part of AYAB. | ||
* | ||
* AYAB is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* AYAB is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with AYAB. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Original Work Copyright 2013 Christian Obersteiner, Andreas Müller | ||
* http://ayab-knitting.com | ||
*/ | ||
#include "knitting_machine_adapter.h" | ||
|
||
#include <gmock/gmock.h> | ||
|
||
#include "knitting_machine.h" | ||
|
||
#include "board.h" | ||
|
||
using namespace ::testing; | ||
|
||
KnittingMachineAdapter::KnittingMachineAdapter(KnittingMachine &km, | ||
ArduinoMock &arduinoMock, | ||
Flags flags) | ||
: m_km(km), m_flags(flags) { | ||
EXPECT_CALL(arduinoMock, digitalRead(ENC_PIN_A)) | ||
.Times(AnyNumber()) | ||
.WillRepeatedly( | ||
Invoke([&] { return m_km.getEncoderOutput1() ? HIGH : LOW; })); | ||
|
||
EXPECT_CALL(arduinoMock, digitalRead(ENC_PIN_B)) | ||
.Times(AnyNumber()) | ||
.WillRepeatedly( | ||
Invoke([&] { return m_km.getEncoderOutput2() ? HIGH : LOW; })); | ||
|
||
EXPECT_CALL(arduinoMock, analogRead(EOL_PIN_L)) | ||
.Times(AnyNumber()) | ||
.WillRepeatedly(Invoke( | ||
[&] { return m_km.getLeftPositionSensorVoltage() * 1023 / 5; })); | ||
|
||
EXPECT_CALL(arduinoMock, digitalRead(ENC_PIN_C)) | ||
.Times(AnyNumber()) | ||
.WillRepeatedly(Invoke([&] { return m_km.getBeltPhase() ? HIGH : LOW; })); | ||
|
||
EXPECT_CALL(arduinoMock, analogRead(EOL_PIN_R)) | ||
.Times(AnyNumber()) | ||
.WillRepeatedly(Invoke([&] { | ||
if (m_flags & DigitalRightSensor) { | ||
// On the KH-910 EOL_PIN_R is plugged into the K digital signal | ||
return m_km.getRightPositionSensorKSignal() * 1023 / 5; | ||
} else { | ||
return m_km.getRightPositionSensorVoltage() * 1023 / 5; | ||
} | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters