Skip to content

Commit

Permalink
Enigma: Improved navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Chysn committed Sep 29, 2018
1 parent b668a5e commit b5e31ee
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
21 changes: 18 additions & 3 deletions software/o_c_REV/APP_ENIGMA.ino
Expand Up @@ -144,8 +144,9 @@ public:
/////////////////////////////////////////////////////////////////
// Left button press changes the Mode
void OnLeftButtonPress() {
if (++mode > ENIGMA_MODE_PLAY) mode = ENIGMA_MODE_LIBRARY;
if (mode == ENIGMA_CONFIRM_RESET) mode = last_mode; // Cancel erase
else if (++mode > ENIGMA_MODE_PLAY) mode = ENIGMA_MODE_LIBRARY;
if (mode == ENIGMA_MODE_LIBRARY && play) ++mode;
ResetCursor();
help_countdown = help_time;
}
Expand Down Expand Up @@ -197,9 +198,17 @@ public:
SendSingleTuringMachine(tm_cursor);
}
}
if (mode == ENIGMA_MODE_ASSIGN) assign_audition = 0;
if (mode == ENIGMA_MODE_ASSIGN && !play) assign_audition = 0;
if (mode == ENIGMA_MODE_SONG) InsertStep();
if (mode == ENIGMA_MODE_PLAY) play = 1 - play;
if (mode == ENIGMA_MODE_PLAY) {
play = 1 - play;
if (play) {
// Save the audition assign state for when play is stopped
last_assign_audition = assign_audition;
assign_audition = 1;
}
else assign_audition = last_assign_audition;
}
}
}

Expand Down Expand Up @@ -271,6 +280,7 @@ private:
TuringMachineState tm_state; // The currently-selected state in Library mode
byte state_prob[HS::TURING_MACHINE_COUNT]; // Remember the last probability
bool assign_audition = 0; // Which area does Assign monitor? 0=Library, 1=Song
bool last_assign_audition; // Temporarily save the old audition state during playback
uint16_t track_step[100]; // List of steps in the current track
uint16_t total_steps = 0; // Total number of song_step[] entries used; index of the next step
byte last_track_step_index = 0; // For adding the next step
Expand Down Expand Up @@ -388,6 +398,10 @@ private:
}

void DrawAssignInterface() {
// Play status at top of screen
if (play) gfxIcon(118, 0, PLAY_ICON);
else gfxIcon(118, 0, PAUSE_ICON);

// Draw the left side, the selector
for (byte line = 0; line < 4; line++)
{
Expand Down Expand Up @@ -551,6 +565,7 @@ private:
char name[4];
HS::TuringMachine::SetName(name, song_step[ssi].tm());
gfxPrint(54, y, name);
track_tm[t].DrawSmallAt(54, y + 8);
}

// Clock Divide
Expand Down
2 changes: 1 addition & 1 deletion software/o_c_REV/OC_version.h
Expand Up @@ -3,6 +3,6 @@
//
// GENERATED FILE, DO NOT EDIT
//
#define OC_VERSION "HSv1.5"
#define OC_VERSION "HSv1.5A"
#endif

5 changes: 5 additions & 0 deletions software/o_c_REV/enigma/TuringMachineState.h
Expand Up @@ -112,6 +112,11 @@ class TuringMachineState {
}
}

void DrawSmallAt(byte x, byte y) {
for (byte b = 0; b < 16; b++)
if ((reg >> b) & 0x01) graphics.setPixel(16 - b + x, y);
}

private:
byte ix; // Turing machine index
uint16_t reg; // Shift register
Expand Down

0 comments on commit b5e31ee

Please sign in to comment.