Skip to content

Commit

Permalink
feat: support different screen sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidramiro committed Mar 17, 2024
1 parent e75eb18 commit 13a1ad4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <main.h>
#include "main.h"

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define SCREEN_HEIGHT 64

/// @brief Analog pin of the photodiode
const int photoDiodePin = A1;
Expand Down Expand Up @@ -30,12 +30,7 @@ void setup()

pinMode(photoDiodePin, INPUT);
Mouse.begin();
for (int i = 5; i > 0; i--)
{
sprintf(buffer, "starting in %d...", i);
printBufferToScreen(true);
delay(1000);
}
countdown(5);
}

/// @brief Measures brightness, waits for brightness change, saves latency. Shows an average after 10 cycyles.
Expand Down Expand Up @@ -97,6 +92,7 @@ void loop()
cycles = 0;

delay(5000);
countdown(5);
}
}

Expand Down Expand Up @@ -124,7 +120,7 @@ void initScreen()
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(15, 10);
display.setCursor(15, 0);
display.write(0x10);
display.print(" e2e-latency ");
display.write(0x11);
Expand All @@ -149,15 +145,15 @@ void printBufferToScreen(boolean segment, int glyph)
}

display.clearDisplay();
display.drawFastHLine(0, 10, 128, WHITE);
display.drawFastHLine(0, SCREEN_HEIGHT / 3, 128, WHITE);

display.setTextSize(1);
display.setCursor(0, 0);
display.println(topScreenBuf);
display.display();

display.setTextSize(2);
display.setCursor(0, 16);
display.setCursor(0, SCREEN_HEIGHT / 2);
display.write(glyph);
display.println(lowerScreenBuf);
display.display();
Expand All @@ -169,4 +165,14 @@ void reset()
moveMouseVertically(false);
delay(500);
brightness = 0;
}

void countdown(int seconds)
{
for (; seconds > 0; seconds--)
{
sprintf(buffer, "starting in %d...", seconds);
printBufferToScreen(true);
delay(1000);
}
}
1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

void reset();
void initScreen();
void countdown(int seconds);
void moveMouseVertically(bool direction);
void printBufferToScreen(boolean segment);
void printBufferToScreen(boolean segment, int glyph);

0 comments on commit 13a1ad4

Please sign in to comment.