Skip to content
Permalink
Browse files

refresh screen in handler_ScreenRefresh, not refreshTimer

remove screen_dirty as a global variable
  • Loading branch information
samdoshi committed Apr 15, 2017
1 parent 3b93348 commit 32dcda13175211a9838489c7c3e6ef95549497d4
@@ -154,7 +154,8 @@ void process_edit_keys(uint8_t k, uint8_t m, bool is_held_key) {
}


void screen_refresh_edit() {
bool screen_refresh_edit() {
bool screen_dirty = false;
if (r_edit_dirty & R_INPUT) {
char prefix = script + '1';
if (script == METRO_SCRIPT)
@@ -204,4 +205,6 @@ void screen_refresh_edit() {
screen_dirty = true;
r_edit_dirty &= ~R_LIST;
}

return screen_dirty;
}
@@ -7,6 +7,6 @@
void set_edit_mode(void);
void set_edit_mode_script(uint8_t new_script);
void process_edit_keys(uint8_t key, uint8_t mod_key, bool is_held_key);
void screen_refresh_edit(void);
bool screen_refresh_edit(void);

#endif
@@ -18,7 +18,6 @@ extern scene_state_t scene_state;
extern uint8_t r_edit_dirty;

extern region line[8];
extern bool screen_dirty;

extern uint8_t preset_select;

@@ -280,8 +280,8 @@ void process_help_keys(uint8_t k, uint8_t m, bool is_held_key) {
}
}

void screen_refresh_help() {
if (!(r_edit_dirty & R_ALL)) { return; }
bool screen_refresh_help() {
if (!(r_edit_dirty & R_ALL)) { return false; }

// clamp value of page_no
if (page_no >= HELP_PAGES) page_no = HELP_PAGES - 1;
@@ -297,5 +297,5 @@ void screen_refresh_help() {
}

r_edit_dirty &= ~R_ALL;
screen_dirty = true;
return true;
};
@@ -5,6 +5,6 @@
#include <stdint.h>

void process_help_keys(uint8_t key, uint8_t mod_key, bool is_held_key);
void screen_refresh_help(void);
bool screen_refresh_help(void);

#endif
@@ -99,7 +99,8 @@ void process_live_keys(uint8_t k, uint8_t m, bool is_held_key) {
}


void screen_refresh_live() {
bool screen_refresh_live() {
bool screen_dirty = false;
if (r_edit_dirty & R_INPUT) {
line_editor_draw(&le, '>', &line[7]);
screen_dirty = true;
@@ -218,4 +219,6 @@ void screen_refresh_live() {
activity &= ~A_MUTES;
activity &= ~A_REFRESH;
}

return screen_dirty;
}
@@ -7,6 +7,6 @@
void init_live_mode(void);
void set_live_mode(void);
void process_live_keys(uint8_t key, uint8_t mod_key, bool is_held_key);
void screen_refresh_live(void);
bool screen_refresh_live(void);

#endif
@@ -106,9 +106,6 @@ region line[8] = {
{.w = 128, .h = 8, .x = 0, .y = 48 }, {.w = 128, .h = 8, .x = 0, .y = 56 }
};

// defined in fudge.h
bool screen_dirty = false;


////////////////////////////////////////////////////////////////////////////////
// prototypes
@@ -199,12 +196,6 @@ static void refreshTimer_callback(void* o) {
e.type = kEventScreenRefresh;
e.data = 0;
event_post(&e);

if (screen_dirty) {
for (int i = 0; i < 8; i++) region_draw(&line[i]);

screen_dirty = false;
}
}

static void keyTimer_callback(void* o) {
@@ -350,13 +341,19 @@ static void handler_Trigger(s32 data) {
// refresh

static void handler_ScreenRefresh(s32 data) {
bool screen_dirty = false;

switch (mode) {
case M_PATTERN: screen_refresh_pattern(); break;
case M_PRESET_W: screen_refresh_preset_w(); break;
case M_PRESET_R: screen_refresh_preset_r(); break;
case M_HELP: screen_refresh_help(); break;
case M_LIVE: screen_refresh_live(); break;
case M_EDIT: screen_refresh_edit(); break;
case M_PATTERN: screen_dirty = screen_refresh_pattern(); break;
case M_PRESET_W: screen_dirty = screen_refresh_preset_w(); break;
case M_PRESET_R: screen_dirty = screen_refresh_preset_r(); break;
case M_HELP: screen_dirty = screen_refresh_help(); break;
case M_LIVE: screen_dirty = screen_refresh_live(); break;
case M_EDIT: screen_dirty = screen_refresh_edit(); break;
}

if (screen_dirty) {
for (size_t i = 0; i < 8; i++) { region_draw(&line[i]); }
}
}

@@ -256,8 +256,8 @@ void process_pattern_knob(uint16_t knob, uint8_t m) {
}
}

void screen_refresh_pattern() {
if (!(r_edit_dirty & R_ALL)) { return; }
bool screen_refresh_pattern() {
if (!(r_edit_dirty & R_ALL)) { return false; }

char s[32];
for (uint8_t y = 0; y < 8; y++) {
@@ -303,5 +303,5 @@ void screen_refresh_pattern() {

r_edit_dirty &= ~R_ALL;

screen_dirty = true;
return true;
}
@@ -6,6 +6,6 @@

void process_pattern_keys(uint8_t key, uint8_t mod_key, bool is_held_key);
void process_pattern_knob(uint16_t knob, uint8_t mod_key);
void screen_refresh_pattern(void);
bool screen_refresh_pattern(void);

#endif
@@ -65,8 +65,8 @@ void process_preset_r_keys(uint8_t k, uint8_t m, bool is_held_key) {
}
}

void screen_refresh_preset_r() {
if (!(r_edit_dirty & R_ALL)) { return; }
bool screen_refresh_preset_r() {
if (!(r_edit_dirty & R_ALL)) { return false; }

char s[32];
itoa(preset_select, s, 10);
@@ -82,5 +82,5 @@ void screen_refresh_preset_r() {
}

r_edit_dirty &= ~R_ALL;
screen_dirty = true;
return true;
};
@@ -7,6 +7,6 @@
void set_preset_r_mode(uint16_t knob);
void process_preset_r_knob(uint16_t knob, uint8_t mod_key);
void process_preset_r_keys(uint8_t key, uint8_t mod_key, bool is_held_key);
void screen_refresh_preset_r(void);
bool screen_refresh_preset_r(void);

#endif
@@ -82,8 +82,8 @@ void process_preset_w_keys(uint8_t k, uint8_t m, bool is_held_key) {
}


void screen_refresh_preset_w() {
if (!(r_edit_dirty & R_ALL)) { return; }
bool screen_refresh_preset_w() {
if (!(r_edit_dirty & R_ALL)) { return false; }

char header[6] = ">>> ";
itoa(preset_select, header + 4, 10);
@@ -101,5 +101,5 @@ void screen_refresh_preset_w() {
line_editor_draw(&le, '+', &line[7]);

r_edit_dirty &= ~R_ALL;
screen_dirty = true;
return true;
}
@@ -6,6 +6,6 @@

void set_preset_w_mode(void);
void process_preset_w_keys(uint8_t key, uint8_t mod_key, bool is_held_key);
void screen_refresh_preset_w(void);
bool screen_refresh_preset_w(void);

#endif

0 comments on commit 32dcda1

Please sign in to comment.