-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy patholed.ino
66 lines (61 loc) · 2.12 KB
/
oled.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
void updateOLED() {
if ( programOverride ) {
OLED.invertDisplay();
OLED.clear();
OLED.setFont( ArialMT_Plain_16 );
OLED.setTextAlignment( TEXT_ALIGN_CENTER );
OLED.drawString( DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2 - 8, lightStatus );
OLED.display();
return;
}
OLED.normalDisplay();
showBarGraphOLED();
}
void showBarGraphOLED() {
int barWidth = DISPLAY_WIDTH / numberOfChannels;
OLED.normalDisplay();
OLED.clear();
for ( byte thisChannel = 0; thisChannel < numberOfChannels; thisChannel++ ) {
int x1 = barWidth * thisChannel;
int bottomOfBar = DISPLAY_HEIGHT - 11;
int y1 = ( bottomOfBar ) - ( bottomOfBar * ( channel[thisChannel].currentPercentage / 100 ) ) * 0.6;
int x2 = barWidth;
int y2 = bottomOfBar - y1;
OLED.fillRect( x1 + 2, y1, x2 - 2, y2 );
OLED.setFont( ArialMT_Plain_10 );
OLED.setTextAlignment( TEXT_ALIGN_CENTER );
OLED.drawString( 2 + x1 + barWidth / 2, y1 - 11, String( (int) channel[thisChannel].currentPercentage ) );
}
OLED.drawString( DISPLAY_WIDTH / 2, 0, formattedTime( localTime() ) );
showIpOrHostname();
OLED.display();
}
void showIpOrHostname() {
OLED.setFont(ArialMT_Plain_10);
static time_t nextOLEDswitch = now() + 5;
static bool showIP = true;
if ( now() >= nextOLEDswitch ) {
showIP = !showIP;
nextOLEDswitch = now() + 5;
}
OLED.drawString( DISPLAY_WIDTH / 2, 52, showIP ? WiFi.localIP().toString() : WiFi.hostname() );
OLED.display();
}
void showUploadProgressOLED( const String progress, const String filename ) {
OLED.clear();
OLED.setFont( ArialMT_Plain_16 );
OLED.setTextAlignment( TEXT_ALIGN_CENTER );
OLED.drawString( DISPLAY_WIDTH / 2, 0, F( "UPLOADING:" ) );
OLED.drawString( DISPLAY_WIDTH / 2, 20, filename );
OLED.setFont( ArialMT_Plain_24 );
OLED.drawString( DISPLAY_WIDTH / 2, 40, progress + "%" );
OLED.display();
}
void showDeleteOLED( const String filename ) {
OLED.clear();
OLED.setFont( ArialMT_Plain_16 );
OLED.setTextAlignment( TEXT_ALIGN_CENTER );
OLED.drawString( DISPLAY_WIDTH / 2, 0, F( "DELETING" ) );
OLED.drawString( DISPLAY_WIDTH / 2, 20, filename );
OLED.display();
}