Browse Source

70 to 100

main
gsd 7 months ago
parent
commit
68938a0657
  1. 39
      pipboyIO/extDisplay.cpp
  2. 8
      pipboyIO/radDisplaySettings.h

39
pipboyIO/extDisplay.cpp

@ -18,7 +18,7 @@ void initExtDisplay() {
for(;;); for(;;);
} }
changeExt(0); changeExt(50);
} }
void changeExt(float value) { void changeExt(float value) {
@ -35,18 +35,24 @@ void pixelOnExtDisplay(int16_t x, int16_t y) {
} }
float valueOnExtDisplay(float value) { float valueOnExtDisplay(float value) {
return mapFloat(value, 10, 70, 150, 210); return mapFloat(value, 0, 100, 150, 210);
} }
void drawLineExtDisplay(float value) { void drawLineExtDisplay(float value) {
int r = 120; int r1 = 122;
int r2 = 112;
float rad = value * PI / 180.0; float rad = value * PI / 180.0;
float radSin = sin(rad); float radSin = sin(rad);
float radCos = cos(rad); float radCos = cos(rad);
for (int x = extCenterX - 1; x < extCenterX + 1; x++) { for (int x = extCenterX - 1; x < extCenterX + 1; x++) {
for (int y = extCenterY - 1; y < extCenterY + 1; y++) { for (int y = extCenterY - 1; y < extCenterY + 1; y++) {
extDisplay.drawLine(x, y, x + (r * radSin), y - (r * radCos), WHITE); extDisplay.drawLine(
x + (r1 * radSin),
y - (r1 * radCos),
x + (r2 * radSin),
y - (r2 * radCos),
WHITE);
} }
} }
} }
@ -54,8 +60,9 @@ void drawLineExtDisplay(float value) {
void overlayOnExtDisplay() { void overlayOnExtDisplay() {
int duga[2] = {85, 125}; int duga[2] = {85, 125};
for (int d = 0; d < 2; d++) { for (int d = 0; d < 2; d++) {
for (int angle = 150; angle <= 210.0; angle += 1) { for (int angleCalc = 150; angleCalc <= 210.0; angleCalc+= 1) {
float rad = angle * PI / 180.0; float rad = angleCalc * PI / 180.0;
int angle = map(angleCalc, 210, 150, 0, 100);
float radSin = sin(rad); float radSin = sin(rad);
float radCos = cos(rad); float radCos = cos(rad);
@ -70,7 +77,7 @@ void overlayOnExtDisplay() {
extDisplay.drawLine(endX, endY, startX, startY, WHITE); extDisplay.drawLine(endX, endY, startX, startY, WHITE);
} }
if (d == 0 && angle % 2 == 0) { if (d == 0 && angle % 5 == 0) {
int duga0ext = 90; int duga0ext = 90;
int startX = 64 + (duga0ext * radSin); int startX = 64 + (duga0ext * radSin);
int startY = -70 - (duga0ext * radCos); int startY = -70 - (duga0ext * radCos);
@ -85,7 +92,7 @@ void overlayOnExtDisplay() {
} }
if (d == 0 && angle % 10 == 0) { if (d == 0 && angle % 10 == 0) {
int neededLetter = abs(140 - angle); int neededLetter = abs(100 - angle);
int duga1ext = duga[d] + 15; int duga1ext = duga[d] + 15;
int startX = 64 + (duga1ext * radSin); int startX = 64 + (duga1ext * radSin);
int startY = -70 - (duga1ext * radCos); int startY = -70 - (duga1ext * radCos);
@ -143,6 +150,22 @@ void overlayOnExtDisplay() {
extDisplay.drawPixel(startX + EightLetterPoint[i][0], startY + EightLetterPoint[i][1] + moveLetters, WHITE); extDisplay.drawPixel(startX + EightLetterPoint[i][0], startY + EightLetterPoint[i][1] + moveLetters, WHITE);
} }
break; break;
case 90:
for (int i = 0; i < sizeof(NineLetterPoint) / sizeof(NineLetterPoint[0]); i++) {
extDisplay.drawPixel(startX + NineLetterPoint[i][0], startY + NineLetterPoint[i][1] + moveLetters, WHITE);
}
break;
case 100:
for (int i = 0; i < sizeof(ZeroLetterPoint) / sizeof(ZeroLetterPoint[0]); i++) {
extDisplay.drawPixel(startX + ZeroLetterPoint[i][0], startY + ZeroLetterPoint[i][1] + moveLetters, WHITE);
}
for (int i = 0; i < sizeof(OneLetterPoint) / sizeof(OneLetterPoint[0]); i++) {
extDisplay.drawPixel(startX + OneLetterPoint[i][0], startY + OneLetterPoint[i][1] + moveLetters * 2, WHITE);
}
break;
default: default:
break; break;

8
pipboyIO/radDisplaySettings.h

@ -86,4 +86,12 @@ const int OneLetterPoint[][2] = {
{4, 2}, {4, 1}, {4, 0} {4, 2}, {4, 1}, {4, 0}
}; };
const int NineLetterPoint[][2] = {
{0, 3}, {0, 2}, {0, 1}, {0, 0},
{1, 3}, {1, 0},
{2, 3}, {2, 2}, {2, 1}, {2, 0},
{3, 0},
{4, 3}, {4, 2}, {4, 1}, {4, 0}
};
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max); float mapFloat(float x, float in_min, float in_max, float out_min, float out_max);
Loading…
Cancel
Save