Refacto function run_display Add call to function refresh_display_notes Add call to function refresh_display_gamme
Fork of Nucleo_piano_V1 by
Revision 10:09b4203b5ae9, committed 2018-07-04
- Comitter:
- Aliened
- Date:
- Wed Jul 04 23:06:52 2018 +0000
- Parent:
- 9:653ee515b0ad
- Commit message:
- Refacto function run_display; Add call to refresh_display_notes; Add call to refresh_display_gamme
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jul 04 22:17:46 2018 +0000 +++ b/main.cpp Wed Jul 04 23:06:52 2018 +0000 @@ -108,6 +108,38 @@ } } +void refresh_display_notes(char *old_buffer) +{ + lcd.cls(); + lockGamme.lock(); + if (strcmp(bufferOutput, "")) + { + lcd.printf("%s- g[%d]", bufferOutput, gamme); + pc.printf("Play notes: %s with gamme %d\n", bufferOutput, gamme); + } + else + { + lcd.printf("Gamme = %d", gamme); + pc.printf("Release notes\n"); + } + lockGamme.unlock(); + strcpy(old_buffer, bufferOutput); +} + +int refresh_display_gamme(int old_gamme) +{ + lockGamme.lock(); + if (old_gamme != gamme) + { + lcd.cls(); + lcd.printf("Gamme = %d", gamme); + pc.printf("Change gamme %d to gamme %d\n", old_gamme, gamme); + old_gamme = gamme; + } + lockGamme.unlock(); + return old_gamme; +} + void run_display() { char old_buffer[30] = ""; @@ -122,32 +154,9 @@ { lockBufferOutput.lock(); if (strcmp(old_buffer, bufferOutput)) - { - lcd.cls(); - lockGamme.lock(); - if (strcmp(bufferOutput, "")) - { - lcd.printf("%s- g[%d]", bufferOutput, gamme); - pc.printf("Play notes: %s with gamme %d\n", bufferOutput, gamme); - } - else { - lcd.printf("Gamme = %d", gamme); - pc.printf("Release notes\n"); - } - lockGamme.unlock(); - strcpy(old_buffer, bufferOutput); - } - else { - lockGamme.lock(); - if (old_gamme != gamme) - { - lcd.cls(); - lcd.printf("Gamme = %d", gamme); - pc.printf("Change gamme %d to gamme %d\n", old_gamme, gamme); - old_gamme = gamme; - } - lockGamme.unlock(); - } + refresh_display_notes(old_buffer); + else + old_gamme = refresh_display_gamme(old_gamme); lockBufferOutput.unlock(); Thread::wait(100); }