Skip to content

Commit

Permalink
Tested configuration loading
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbez1 committed May 14, 2024
1 parent 802aaca commit 3f06e88
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
16 changes: 8 additions & 8 deletions arduino/splitflap/Splitflap/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
#define HOME_CALIBRATION_ENABLED true

// 3) Flap Contents & Order
#define NUM_FLAPS (40)
#define NUM_FLAPS (52)

// This should match the order of flaps on the spool, with the first being the
// "home" flap.
// const uint8_t flaps[NUM_FLAPS] = {
// ' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
// 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
// 'Z', 'g', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'r',
// '.', '?', '-', '$', '\'', '#', 'y', 'p', ',', '!', '~', '&', 'w'
// };
const uint8_t flaps[NUM_FLAPS] = {
' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
'Z', 'g', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'r',
'.',
'.', '?', '-', '$', '\'', '#', 'y', 'p', ',', '!', '~', '&', 'w'
};
// const uint8_t flaps[NUM_FLAPS] = {
// ' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
// 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
// 'Z', 'g', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'r',
// '.',
// };

// 4) Hardware configuration and features
#ifndef SPLITFLAP_PIO_HARDWARE_CONFIG
Expand Down
20 changes: 20 additions & 0 deletions arduino/splitflap/esp32/core/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ bool Configuration::loadFromDisk() {
pb_buffer_.module_offset_steps_count
);
log(buf);

uint8_t previewN = min(pb_buffer_.module_offset_steps_count, static_cast<pb_size_t>(6));
snprintf(
buf,
sizeof(buf),
"First %u offsets:",
previewN
);
log(buf);
for (uint8_t i = 0; i < previewN; i++) {
snprintf(
buf,
sizeof(buf),
" %u: %u",
i,
pb_buffer_.module_offset_steps[i]
);
log(buf);
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion arduino/splitflap/esp32/core/splitflap_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void SplitflapTask::processQueue() {
uint16_t offsets[NUM_MODULES];
for (uint8_t i = 0; i < NUM_MODULES; i++) {
// Make sure all modules are stopped, since writing to config may take a while
if (modules[i]->state != NORMAL || modules[i]->current_accel_step != 0) {
if (modules[i]->current_accel_step != 0) {
snprintf(buffer, sizeof(buffer), "Can't save offsets; module %u isn't idle", i);
log(buffer);
return;
Expand Down

0 comments on commit 3f06e88

Please sign in to comment.