Skip to content

Commit 003cea6

Browse files
committed
add flap code to module
1 parent 0205c53 commit 003cea6

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

code/module/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch

code/module/src/main.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
#include <Arduino.h>
22
#include "utils.h"
33
#include <vector>
4+
#include "SplitFlap.h"
45

56
#define TXD1 19
67
#define RXD1 21
78

9+
// defines pins
10+
#define STEP_PIN 13
11+
#define DIR_PIN 12
12+
13+
SplitFlap splitFlap(STEP_PIN, DIR_PIN);
14+
815
// Use Serial1 for UART communication
916
HardwareSerial mySerial(2);
1017

18+
SplitFlap splitFlap(13, 12);
19+
1120
bool readingPacket = false;
1221

1322
void handleMyByte(uint8_t byte)
1423
{
1524
Serial.println("Received byte: " + String(byte));
16-
// TODO: set the flap number
25+
splitFlap.setFlap(byte);
1726
}
1827

1928
void setup()
2029
{
2130
Serial.begin(115200);
2231
mySerial.begin(9600, SERIAL_8N1, RXD1, TXD1); // UART setup
2332

33+
splitFlap.init();
34+
2435
Serial.println("Module started");
2536
}
2637

2738
void loop()
2839
{
40+
splitFlap.update();
41+
2942
// Check if data is available to read
3043
if (mySerial.available())
3144
{

code/controller/src/SplitFlap.h renamed to code/shared/include/SplitFlap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class SplitFlap
3030
pinMode(dirPin, OUTPUT);
3131

3232
digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction
33+
34+
this->home();
35+
}
36+
37+
void home()
38+
{
39+
// TODO: implement homing sequence
3340
}
3441

3542
void update()

0 commit comments

Comments
 (0)