Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Python example (and v2 character set) for new features #242

Merged
merged 4 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arduino/splitflap/Splitflap/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ 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'
'.', '?', '-', '$', '\'', '#', 'y', 'p', ',', '!', '@', '&', 'w'
};

// Flap option 3: v2 flaps (limited 40-flap set using the first 40 flaps of the set)
Expand Down
8 changes: 4 additions & 4 deletions software/chainlink/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
)

words = [
'alpaca', 'baboon', 'badger', 'beluga', 'bobcat', 'ferret',
'gopher', 'impala', 'jackal', 'jaguar', 'kitten', 'marmot',
'monkey', 'ocelot', 'rabbit', 'racoon', 'turtle', 'walrus',
'weasel', 'wombat',
'ALPACA', 'BABOON', 'BADGER', 'BELUGA', 'BOBCAT', 'FERRET',
'GOPHER', 'IMPALA', 'JACKAL', 'JAGUAR', 'KITTEN', 'MARMOT',
'MONKEY', 'OCELOT', 'RABBIT', 'RACOON', 'TURTLE', 'WALRUS',
'WEASEL', 'WOMBAT',
]


Expand Down
20 changes: 10 additions & 10 deletions software/chainlink/splitflap_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ class ForceMovement(Enum):

RETRY_TIMEOUT = 0.25

# TODO: read alphabet from splitflap once this is possible
_DEFAULT_ALPHABET = [
' ',
'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',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'.',
',',
'\'',
_LEGACY_ALPHABET = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this based on the webserial example.

' ', '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', '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9', '.', ',', "'",
]

def __init__(self, serial_instance):
Expand All @@ -66,7 +62,8 @@ def __init__(self, serial_instance):
self._current_config = splitflap_pb2.SplitflapConfig()
self._num_modules = None

self._alphabet = Splitflap._DEFAULT_ALPHABET
self._alphabet = Splitflap._LEGACY_ALPHABET
self._alphabet_received = False

def _read_loop(self):
self._logger.debug('Read loop started')
Expand Down Expand Up @@ -125,6 +122,9 @@ def _process_frame(self, frame):
self._current_config.modules.append(splitflap_pb2.SplitflapConfig.ModuleConfig())
else:
assert self._num_modules == num_modules_reported, f'Number of reported modules changed (was {self._num_modules}, now {num_modules_reported})'
elif payload_type == 'general_state' and not self._alphabet_received:
self._alphabet_received = True
self._alphabet = list(message.general_state.flap_character_set.decode('utf-8'))

with self._lock:
for handler in self._message_handlers[payload_type] + self._message_handlers[None]:
Expand Down