Skip to content

Instantly share code, notes, and snippets.

@aheadley
Last active February 9, 2018 20:38
Show Gist options
  • Save aheadley/d89f2be34fd8386ece9da88b4fa22a12 to your computer and use it in GitHub Desktop.
Save aheadley/d89f2be34fd8386ece9da88b4fa22a12 to your computer and use it in GitHub Desktop.
A snippet of code from cava found while making my keyboard light up for https://www.youtube.com/watch?v=Z12w1AvWehE
if(f[i] > flastd[i]){//higher then last one
if (tty) for (n = flastd[i] / 8; n < f[i] / 8; n++) for (q = 0; q < bw; q++) mvprintw((h - n), i*bw + q + i*bs + rest, "%d",8);
else for (n = flastd[i] / 8; n < f[i] / 8; n++) for (q = 0; q < bw; q++) mvaddwstr((h - n), i*bw + q + i*bs + rest, bh[7]);
if (f[i] % 8 != 0) {
if (tty) for (q = 0; q < bw; q++) mvprintw( (h - n), i*bw + q + i*bs + rest, "%d",(f[i] % 8) );
else for (q = 0; q < bw; q++) mvaddwstr( (h - n), i*bw + q + i*bs + rest, bh[(f[i] % 8) - 1]);
}
}else if(f[i] < flastd[i]){//lower then last one
for (n = f[i] / 8; n < flastd[i]/8 + 1; n++) for (q = 0; q < bw; q++) mvaddstr( (h - n), i*bw + q + i*bs + rest, " ");
if (f[i] % 8 != 0) {
if (tty) for (q = 0; q < bw; q++) mvprintw((h - f[i] / 8), i*bw + q + i*bs + rest, "%d",(f[i] % 8) );
else for (q = 0; q < bw; q++) mvaddwstr((h - f[i] / 8), i*bw + q + i*bs + rest, bh[(f[i] % 8) - 1]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment