Skip to content

Commit

Permalink
Make minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dakalamin committed Oct 12, 2024
1 parent 0c3f7af commit 840faa0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
26 changes: 13 additions & 13 deletions src/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ class Buffer {
}

/*
Shift buffer left and return index of the first empty element after the shift
After elements are sent to display, first BRAILLE_CELLS elements are cleared,
but some non-empty elements may remain in the buffer
e.g.: let brailleCells = 4 and Buffer::size = 7
----------------------------- 0 1 2 3 4 5 6
initial state: ------------- | A | B | C | D | E | F | . |
after showBuffer(): -------- | . | . | . | . | E | F | . | ( ABCD on display )
after shiftBufferLeft(): --- | E | F |[.]| . | . | . | . |
[.] is the first empty element, its index is returned -> 2
Shift buffer left and return index of the first empty element after the shift
After elements are sent to display, first BRAILLE_CELLS elements are cleared,
but some non-empty elements may remain in the buffer
e.g.: let brailleCells = 4 and Buffer::size = 7
----------------------------- 0 1 2 3 4 5 6
initial state: ------------- | A | B | C | D | E | F | . |
after showBuffer(): -------- | . | . | . | . | E | F | . | ( ABCD on display )
after shiftBufferLeft(): --- | E | F |[.]| . | . | . | . |
[.] is the first empty element, its index is returned -> 2
*/
byte shiftLeft() {
byte to = 0;
Expand All @@ -54,7 +54,7 @@ class Buffer {
_contents[i] = EMPTY;
}

void add(byte element); // defined in translation.h
void add(byte element); // defined in translation.h
void add(byte element, byte& index) {
_contents[index++] = element;
}
Expand Down
30 changes: 15 additions & 15 deletions src/custom_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
If you use PlatformIO, consider configuring it in `platformio.ini` first
*/

// #define AUTO_PIN
// #define BUTTON_PIN
// #define DATA_PIN
// #define LATCH_PIN
// #define CLOCK_PIN
// #define AUTO_PIN // uint
// #define BUTTON_PIN // uint
// #define DATA_PIN // uint
// #define LATCH_PIN // uint
// #define CLOCK_PIN // uint

// #define BAUD_RATE
// #define BAUD_RATE // uint

// #define BUTTON_CLICK_MS
// #define BUTTON_CYCLE_MS
// #define BUTTON_CLICK_MS // uint
// #define BUTTON_CYCLE_MS // uint

// #define AUTOCOUNT_CELLS
// #define BRAILLE_CELLS
// #define AUTOCOUNT_CELLS // bool
// #define BRAILLE_CELLS // uint

// #define ANIMATION_ON_START
// #define ANIMATION_MS_PER_CELL
// #define ANIMATION_ON_START // bool
// #define ANIMATION_MS_PER_CELL // uint

// #define SERIAL_ECHO
// #define SERIAL_ECHO // bool

// #define LF_IS_EOM
// #define SERIAL_NA_IS_EOM
// #define LF_IS_EOM // bool
// #define SERIAL_NA_IS_EOM // bool
6 changes: 3 additions & 3 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "patterns.h"


void _shiftOut(byte pattern) {
void _shiftOut(byte pattern=0) {
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, pattern);
digitalWrite(LATCH_PIN, HIGH);
Expand All @@ -16,15 +16,15 @@ void countBrailleCells() {

for (brailleCells = 0; digitalRead(AUTO_PIN); brailleCells++) {
delay((ANIMATION_ON_START) ? ANIMATION_MS_PER_CELL : MIN_DELAY_MS);
_shiftOut(0);
_shiftOut();
}
#else
brailleCells = BRAILLE_CELLS;

#if ANIMATION_ON_START
for (byte i = 0; i < brailleCells; i++) {
delay(ANIMATION_MS_PER_CELL);
_shiftOut(0);
_shiftOut();
}
#endif
#endif
Expand Down

0 comments on commit 840faa0

Please sign in to comment.