diff --git a/platformio.ini b/platformio.ini index 0d62d3f..03f55de 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1,5 +1,5 @@ [platformio] -default_envs = StepperArm +default_envs = StatusLight [env:main] platform = teensy diff --git a/scripts/protobuf/JoystickMotorControl/joystick_control.py b/scripts/protobuf/JoystickMotorControl/joystick_control.py index 9705df6..32ce972 100755 --- a/scripts/protobuf/JoystickMotorControl/joystick_control.py +++ b/scripts/protobuf/JoystickMotorControl/joystick_control.py @@ -180,25 +180,25 @@ def keyboard_thread(): # print("Press 'esc' to exit...") # print("Currently pressed keys:", ', '.join(current_keys)) if "Key.up" in current_keys and "Key.down" not in current_keys: - with left_speed_lock: - left_speed = 3000 - with right_speed_lock: - right_speed = 3000 - elif "Key.up" not in current_keys and "Key.down" in current_keys: with left_speed_lock: left_speed = -3000 with right_speed_lock: right_speed = -3000 - elif "Key.right" in current_keys and "Key.left" not in current_keys: + elif "Key.up" not in current_keys and "Key.down" in current_keys: with left_speed_lock: left_speed = 3000 with right_speed_lock: - right_speed = -3000 - elif "Key.right" not in current_keys and "Key.left" in current_keys: + right_speed = 3000 + elif "Key.right" in current_keys and "Key.left" not in current_keys: with left_speed_lock: left_speed = -3000 with right_speed_lock: right_speed = 3000 + elif "Key.right" not in current_keys and "Key.left" in current_keys: + with left_speed_lock: + left_speed = 3000 + with right_speed_lock: + right_speed = -3000 else: with left_speed_lock: left_speed = 0 diff --git a/src/StatusLight/main.cpp b/src/StatusLight/main.cpp index 390ab18..3873410 100644 --- a/src/StatusLight/main.cpp +++ b/src/StatusLight/main.cpp @@ -4,6 +4,12 @@ #include #include "StatusLight.hpp" +// v1.0 PCB pins +// const int GREEN_PIN = 30; +// const int BLUE_PIN = 31; +// const int RED_PIN = 32; + +// protoboard pins const int GREEN_PIN = 35; const int BLUE_PIN = 34; const int RED_PIN = 32; @@ -36,57 +42,57 @@ int main() { pinMode(LED_BUILTIN, OUTPUT); // status_light::StatusLight statusLight({{"GREEN", GREEN_PIN},{"BLUE", BLUE_PIN},{"RED", RED_PIN}}); - // // Ethernet setup - // qindesign::network::Ethernet.begin(); - // udp.begin(PORT); + // Ethernet setup + qindesign::network::Ethernet.begin(); + udp.begin(PORT); - // // initialize data - // size_t requestLength; - // uint8_t requestBuffer[256]; + // initialize data + size_t requestLength; + uint8_t requestBuffer[256]; // handleLEDRequest(RED_PROTO, 1); while (true) { - // OLD - digitalWrite(GREEN_PIN, HIGH); - delay(500); - digitalWrite(BLUE_PIN, HIGH); - delay(500); - digitalWrite(RED_PIN, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - delay(2000); - digitalWrite(GREEN_PIN, LOW); - delay(500); - digitalWrite(BLUE_PIN, LOW); - delay(500); - digitalWrite(RED_PIN, LOW); - digitalWrite(LED_BUILTIN, LOW); - delay(2000); + // // OLD + // digitalWrite(GREEN_PIN, HIGH); + // delay(500); + // digitalWrite(BLUE_PIN, HIGH); + // delay(500); + // digitalWrite(RED_PIN, HIGH); + // digitalWrite(LED_BUILTIN, HIGH); + // delay(2000); + // digitalWrite(GREEN_PIN, LOW); + // delay(500); + // digitalWrite(BLUE_PIN, LOW); + // delay(500); + // digitalWrite(RED_PIN, LOW); + // digitalWrite(LED_BUILTIN, LOW); + // delay(2000); // // read incoming UDP messages - // requestLength = udp.parsePacket(); - // if (udp.available()) { + requestLength = udp.parsePacket(); + if (udp.available()) { - // Serial.println("Packet received: "); + Serial.println("Packet received: "); - // memset(requestBuffer, 0, 256); - // udp.readBytes(requestBuffer, requestLength); - // bool success = protobuf::Messages::decodeStatusLightRequest(requestBuffer, requestLength, requestCommand); + memset(requestBuffer, 0, 256); + udp.readBytes(requestBuffer, requestLength); + bool success = protobuf::Messages::decodeStatusLightRequest(requestBuffer, requestLength, requestCommand); - // Serial.print("[color="); - // Serial.print(requestCommand.color); - // Serial.print(", display="); - // Serial.print(requestCommand.display); - // Serial.println("]"); - - // // // OLD - // // handleLEDRequest(requestCommand.color, requestCommand.display); + Serial.print("[color="); + Serial.print(requestCommand.color); + Serial.print(", display="); + Serial.print(requestCommand.display); + Serial.println("]"); + + // // OLD + handleLEDRequest(requestCommand.color, requestCommand.display); - // // NEW - // statusLight.resetLeds(); - // statusLight.setLedState("GREEN", HIGH); - // statusLight.setLedBlink("GREEN", requestCommand.display); - // } + // NEW + // statusLight.resetLeds(); + // statusLight.setLedState("GREEN", HIGH); + // statusLight.setLedBlink("GREEN", requestCommand.display); + } // // OLD // if (blinkTimer >= BLINK_RATE_MS) { @@ -106,10 +112,10 @@ int main() { // NEW // statusLight.update(); - // if (blinkTimer >= BLINK_RATE_MS) { - // blinkTimer -= BLINK_RATE_MS; - // digitalToggle(LED_BUILTIN); - // } + if (blinkTimer >= BLINK_RATE_MS) { + blinkTimer -= BLINK_RATE_MS; + digitalToggle(LED_BUILTIN); + } } }