From e10e6eddbfe4a32632d80e6e08dd6912be9458b6 Mon Sep 17 00:00:00 2001 From: Elizabeth Cray Date: Sun, 19 Jan 2025 01:01:31 -0500 Subject: [PATCH] End-Of-Session: WIP commands, invert input logic cause pullups --- README.md | 15 ++++++++++++++- platformio.ini | 1 + src/main.cpp | 28 +++++++++++++++++----------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b908169..50d493b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ # Eck Eck -![EckEckEckEck.gif](https://media-be.chewy.com/wp-content/uploads/2023/05/05165809/cat-chattering-chirping-at-birds.gif) \ No newline at end of file +![EckEckEckEck.gif](https://media-be.chewy.com/wp-content/uploads/2023/05/05165809/cat-chattering-chirping-at-birds.gif) + + +### Current WIP issue: + +command issue: + +``` +.........................................................SR D +...........SR 1 +..............................SR +Processing input: D1 +Command: D - +``` diff --git a/platformio.ini b/platformio.ini index 01e8488..afb48a6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,3 +12,4 @@ platform = atmelavr board = nanoatmega328 framework = arduino +monitor_speed = 115200 diff --git a/src/main.cpp b/src/main.cpp index c3058d2..0a7a2bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,21 +51,21 @@ void setup() { adjust_length(p_buf); log("Setup complete\n"); log("Dit length: "); - log(dit); + log(String(dit)); log("\n"); log("Dah length: "); - log(dah); + log(String(dah)); log("\n"); log("Potentiometer: "); - log(p_buf); + log(String(p_buf)); log("\n"); } void loop() { log("."); - if (digitalRead(input_dah)){ + if (!digitalRead(input_dah)){ send(true); - }else if (digitalRead(input_dit)){ + }else if (!digitalRead(input_dit)){ send(false); } @@ -83,7 +83,7 @@ void loop() { if (Serial.available() > 0) { buf = Serial.read(); log("SR "); - log(buf); + log(String(buf)); log("\n"); if ((uint16_t) buf == 13){ process_input(serial_buffer); @@ -96,8 +96,8 @@ void loop() { delay(debounce); } -void adjust_length(uint8_t adjusted_length){ - uint16_t new_dah = map(adjusted_length, 0, 1023, p_min, p_max); +void adjust_length(uint16_t adjusted_length){ + uint16_t new_dah = map(adjusted_length, 20, 1000, p_min, p_max); set_length(new_dah/2, new_dah); } @@ -112,6 +112,11 @@ void process_input(String input){ log("\n"); char command = input[0]; input.remove(0); + log("Command: "); + log(String(command)); + log(" - "); + log(input); + log("\n"); uint16_t length = 0; switch(command){ case 'S': @@ -126,7 +131,7 @@ void process_input(String input){ set_length(dit, length); break; case 'D': - debug = input.toInt()==1; + debug = boolean(input.toInt()==1); EEPROM.write(22, debug); break; default: @@ -146,9 +151,10 @@ void send(bool b) { void set_length(uint16_t length_dit, uint16_t length_dah) { log("Setting dit length to "); - log(length_dit); + log(String(length_dit)); log(" and dah length to "); - log(length_dah); + log(String(length_dah)); + log("\n"); dit = length_dit; dah = length_dah; EEPROM.write(20, length_dit);