End-Of-Session: WIP commands, invert input logic cause pullups

This commit is contained in:
Elizabeth Cray 2025-01-19 01:01:31 -05:00
parent 9aa1838a26
commit e10e6eddbf
3 changed files with 32 additions and 12 deletions

View File

@ -1,3 +1,16 @@
# Eck Eck # Eck Eck
![EckEckEckEck.gif](https://media-be.chewy.com/wp-content/uploads/2023/05/05165809/cat-chattering-chirping-at-birds.gif) ![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 -
```

View File

@ -12,3 +12,4 @@
platform = atmelavr platform = atmelavr
board = nanoatmega328 board = nanoatmega328
framework = arduino framework = arduino
monitor_speed = 115200

View File

@ -51,21 +51,21 @@ void setup() {
adjust_length(p_buf); adjust_length(p_buf);
log("Setup complete\n"); log("Setup complete\n");
log("Dit length: "); log("Dit length: ");
log(dit); log(String(dit));
log("\n"); log("\n");
log("Dah length: "); log("Dah length: ");
log(dah); log(String(dah));
log("\n"); log("\n");
log("Potentiometer: "); log("Potentiometer: ");
log(p_buf); log(String(p_buf));
log("\n"); log("\n");
} }
void loop() { void loop() {
log("."); log(".");
if (digitalRead(input_dah)){ if (!digitalRead(input_dah)){
send(true); send(true);
}else if (digitalRead(input_dit)){ }else if (!digitalRead(input_dit)){
send(false); send(false);
} }
@ -83,7 +83,7 @@ void loop() {
if (Serial.available() > 0) { if (Serial.available() > 0) {
buf = Serial.read(); buf = Serial.read();
log("SR "); log("SR ");
log(buf); log(String(buf));
log("\n"); log("\n");
if ((uint16_t) buf == 13){ if ((uint16_t) buf == 13){
process_input(serial_buffer); process_input(serial_buffer);
@ -96,8 +96,8 @@ void loop() {
delay(debounce); delay(debounce);
} }
void adjust_length(uint8_t adjusted_length){ void adjust_length(uint16_t adjusted_length){
uint16_t new_dah = map(adjusted_length, 0, 1023, p_min, p_max); uint16_t new_dah = map(adjusted_length, 20, 1000, p_min, p_max);
set_length(new_dah/2, new_dah); set_length(new_dah/2, new_dah);
} }
@ -112,6 +112,11 @@ void process_input(String input){
log("\n"); log("\n");
char command = input[0]; char command = input[0];
input.remove(0); input.remove(0);
log("Command: ");
log(String(command));
log(" - ");
log(input);
log("\n");
uint16_t length = 0; uint16_t length = 0;
switch(command){ switch(command){
case 'S': case 'S':
@ -126,7 +131,7 @@ void process_input(String input){
set_length(dit, length); set_length(dit, length);
break; break;
case 'D': case 'D':
debug = input.toInt()==1; debug = boolean(input.toInt()==1);
EEPROM.write(22, debug); EEPROM.write(22, debug);
break; break;
default: default:
@ -146,9 +151,10 @@ void send(bool b) {
void set_length(uint16_t length_dit, uint16_t length_dah) { void set_length(uint16_t length_dit, uint16_t length_dah) {
log("Setting dit length to "); log("Setting dit length to ");
log(length_dit); log(String(length_dit));
log(" and dah length to "); log(" and dah length to ");
log(length_dah); log(String(length_dah));
log("\n");
dit = length_dit; dit = length_dit;
dah = length_dah; dah = length_dah;
EEPROM.write(20, length_dit); EEPROM.write(20, length_dit);