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 src/Snake.cpp to allow buss values 0...9, A...Z #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 19 additions & 2 deletions src/Snake.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#include "Southpole.hpp"
#include "dsp/digital.hpp"

#define NSNAKEBUSS 16
#define NSBUSS_NUM_INTEGERS 10
#define NSBUSS_NUM_CHARS 26

#define NSBUSS_CHAR_START 65

#define NSNAKEBUSS NSBUSS_NUM_INTEGERS + NSBUSS_NUM_CHARS
#define NSNAKEPORTS 10

struct Snake : Module {
Expand Down Expand Up @@ -190,8 +195,20 @@ struct SnakeDisplay : TransparentWidget {
nvgFillColor(vg, nvgTransRGBA(textColor, 16));
nvgText(vg, textPos.x, textPos.y, "~~~~", NULL);
nvgFillColor(vg, textColor);

/* Orignally the buss values was being converted to hex.
* We want 0...9, A...Z
* So for buss values greater then 9, we need to convert
* the bus value to its equivalent ascii-char value.
*/
char strbuss[4];
sprintf(strbuss,"%1x",module->buss);
if (module->buss < NSBUSS_NUM_INTEGERS) {
sprintf(strbuss,"%1x",module->buss);
} else if (module->buss < NSNAKEBUSS+1) {
/* assumes that a buss value of 10 equates to 65 'A' */
int ch = NSBUSS_CHAR_START + (module->buss - NSBUSS_NUM_INTEGERS);
sprintf(strbuss,"%c",ch);
}
nvgText(vg, textPos.x, textPos.y, strbuss, NULL);
}
};
Expand Down