forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trade: Fixes, features, and improvements
This commit wraps up a number of changes that aim to improve the trade process, its robustness, add some features, and fix some bugs. Change list in rough order of importance: More robust logic during trading which more correctly syncs states between the Flipper and Game Boy. Fixes #20 as a side effect. Implement trade patch list. This allows for the Flipper to both send and receive patch data. Fixes #18 Ability for the Flipper to correctly receive the Pokemon traded to it and put that Pokemon in the Flipper's trade buffer. This allows for trading back and forth, as well as the following feature. Ability for the Flipper to back out of the trade menu, modify the current Pokemon, and re-enter the trade menu without having to completely reset the Game Boy and re-enter the Cable Club. Fixes #19 Completely isolate Trade's context and scope. The _alloc() function now sets itself up with a View and adds it to the app's view_dispatcher. Then returns an anonymous pointer to the Trade context. Adds a huge comment block in the trade source outlining the current understanding of the actual trade data protocol. Also adds specific comments for more context specific details through various trade states. Sets up draw timer callback on 250 ms intervals. This callback toggles a variable that is used to switch between the two screens during the TRADING state. The actual draw callback may be called more often. Using a timer and variable modification allows us exact control of screen changes. Clean up overall state tracking. There are now two states that are tracked, the Game Boy/link state, and the actual trade states. This also allows elimination of additional bools that were used for state tracking in parallel. State transitions and meanings should now be a bit more straightforward. CLK pin now implements an interrupt on either edge. The ISR was updated to shift data out on the falling edge, and read data in on the rising edge. This eliminates delays while in an interrupt context as well as mimics Game Boy behavior by matching the setup/hold times. Remove use of magic numbers as much as possible. Bytes to/from the Pokemon game now use macros for most of the bytes. Many of these were pulled from https://github.com/pret/pokered defines. Clean up cycle counter to real-time maths. Copied general paradigms from Flipper onewire code. This also includes the bit counter timeout and now ensures correct timeouts are measured between transmitted bytes.
- Loading branch information
1 parent
de8ef7d
commit c617ce3
Showing
10 changed files
with
768 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.