This commit is contained in:
2019-07-07 14:42:17 +02:00
parent 7d7b76872f
commit dbcf80ef25
2 changed files with 181 additions and 170 deletions

82
icons.h Normal file
View File

@@ -0,0 +1,82 @@
// 'volume', 32x32px
const unsigned char volume_icon [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x02, 0x07, 0xc0,
0x00, 0x07, 0x01, 0xe0, 0x00, 0x0f, 0x00, 0x70, 0x00, 0x1f, 0x18, 0x38, 0x00, 0x3f, 0x1e, 0x1c,
0x00, 0x7f, 0x0f, 0x1c, 0x00, 0xff, 0x03, 0x8e, 0x01, 0xff, 0x01, 0x8e, 0xff, 0xff, 0x71, 0xc6,
0xff, 0xff, 0x78, 0xc7, 0xff, 0xff, 0x38, 0xe7, 0xff, 0xff, 0x1c, 0x63, 0xff, 0xff, 0x1c, 0x63,
0xff, 0xff, 0x1c, 0x63, 0xff, 0xff, 0x1c, 0x63, 0xff, 0xff, 0x38, 0xe7, 0xff, 0xff, 0x78, 0xc7,
0xff, 0xff, 0x71, 0xc6, 0x03, 0xff, 0x01, 0x86, 0x00, 0xff, 0x03, 0x8e, 0x00, 0x7f, 0x0f, 0x1c,
0x00, 0x3f, 0x1e, 0x1c, 0x00, 0x1f, 0x18, 0x38, 0x00, 0x0f, 0x00, 0x70, 0x00, 0x07, 0x01, 0xe0,
0x00, 0x02, 0x07, 0xc0, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'play_pause-512', 128x32px
const unsigned char playpause_icon [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'bitmap', 128x32px
const unsigned char fastforward_icon [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0xc0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x01, 0xf0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x01, 0xf8, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x01, 0xfe, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfe, 0x01, 0xff, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x81, 0xff, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xc1, 0xff, 0xf0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xf1, 0xff, 0xfc, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xf1, 0xff, 0xfc, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xc1, 0xff, 0xf0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x81, 0xff, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfe, 0x01, 0xff, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x01, 0xfe, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x01, 0xf8, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x01, 0xf0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0xc0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

View File

@@ -4,6 +4,8 @@
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <Ticker.h> #include <Ticker.h>
#include "icons.h"
#define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels #define SCREEN_HEIGHT 32 // OLED display height, in pixels
@@ -22,98 +24,20 @@ const char* password = "raisingelephantsissoutterlyboring";
WiFiClient espClient; WiFiClient espClient;
// 'volume', 32x32px struct song_info {
const unsigned char volume_icon [] PROGMEM = { String title;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x02, 0x07, 0xc0, String artist;
0x00, 0x07, 0x01, 0xe0, 0x00, 0x0f, 0x00, 0x70, 0x00, 0x1f, 0x18, 0x38, 0x00, 0x3f, 0x1e, 0x1c,
0x00, 0x7f, 0x0f, 0x1c, 0x00, 0xff, 0x03, 0x8e, 0x01, 0xff, 0x01, 0x8e, 0xff, 0xff, 0x71, 0xc6,
0xff, 0xff, 0x78, 0xc7, 0xff, 0xff, 0x38, 0xe7, 0xff, 0xff, 0x1c, 0x63, 0xff, 0xff, 0x1c, 0x63,
0xff, 0xff, 0x1c, 0x63, 0xff, 0xff, 0x1c, 0x63, 0xff, 0xff, 0x38, 0xe7, 0xff, 0xff, 0x78, 0xc7,
0xff, 0xff, 0x71, 0xc6, 0x03, 0xff, 0x01, 0x86, 0x00, 0xff, 0x03, 0x8e, 0x00, 0x7f, 0x0f, 0x1c,
0x00, 0x3f, 0x1e, 0x1c, 0x00, 0x1f, 0x18, 0x38, 0x00, 0x0f, 0x00, 0x70, 0x00, 0x07, 0x01, 0xe0,
0x00, 0x02, 0x07, 0xc0, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'play_pause-512', 128x32px
const unsigned char playpause_icon [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x3c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}; };
// 'bitmap', 128x32px enum btn_flag { BTN_NONE, BTN_VOLUP, BTN_VOLDN, BTN_PAUSE, BTN_NEXT };
const unsigned char fastforward_icon [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0xc0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x01, 0xf0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x01, 0xf8, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x01, 0xfe, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfe, 0x01, 0xff, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x81, 0xff, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xc1, 0xff, 0xf0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xf1, 0xff, 0xfc, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xf1, 0xff, 0xfc, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xc1, 0xff, 0xf0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x81, 0xff, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfe, 0x01, 0xff, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x01, 0xfe, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x01, 0xf8, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x01, 0xf0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0xc0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
btn_flag flag = BTN_NONE;
bool flag_next = false;
bool flag_pause = false;
bool flag_volup = false;
bool flag_voldn = false;
bool inhibit = false; bool inhibit = false;
Ticker inhibit_ticker; Ticker inhibit_ticker;
const int debounce_wait = 200;
//ISRs
void reset_inhibit() { void reset_inhibit() {
inhibit = false; inhibit = false;
@@ -121,33 +45,35 @@ void reset_inhibit() {
void set_flag_pause() { void set_flag_pause() {
if (!inhibit) { if (!inhibit) {
flag_pause = true; flag = BTN_PAUSE;
inhibit = true; inhibit = true;
inhibit_ticker.once_ms(1000, reset_inhibit); inhibit_ticker.once_ms(debounce_wait, reset_inhibit);
} }
} }
void set_flag_next() { void set_flag_next() {
if (!inhibit) { if (!inhibit) {
flag_next = true; flag = BTN_NEXT;
inhibit = true; inhibit = true;
inhibit_ticker.once_ms(1000, reset_inhibit); inhibit_ticker.once_ms(debounce_wait, reset_inhibit);
} }
} }
void set_flag_volup() { void set_flag_volup() {
if (!inhibit) { if (!inhibit) {
flag_volup = true; flag = BTN_VOLUP;
inhibit = true; inhibit = true;
inhibit_ticker.once_ms(1000, reset_inhibit); inhibit_ticker.once_ms(debounce_wait, reset_inhibit);
} }
} }
void set_flag_voldn() { void set_flag_voldn() {
if (!inhibit) { if (!inhibit) {
flag_voldn = true; flag = BTN_VOLDN;
inhibit = true; inhibit = true;
inhibit_ticker.once_ms(1000, reset_inhibit); inhibit_ticker.once_ms(debounce_wait, reset_inhibit);
} }
} }
//end ISRs
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@@ -167,6 +93,8 @@ void setup() {
delay(1000); delay(1000);
Serial.println("Start main program");
pinMode(BUTTON_NEXT, INPUT_PULLUP); pinMode(BUTTON_NEXT, INPUT_PULLUP);
pinMode(BUTTON_PAUSE, INPUT_PULLUP); pinMode(BUTTON_PAUSE, INPUT_PULLUP);
pinMode(BUTTON_VOLUP, INPUT_PULLUP); pinMode(BUTTON_VOLUP, INPUT_PULLUP);
@@ -178,53 +106,65 @@ void setup() {
display_song_info(); display_song_info();
} }
void loop() { void loop() {
Serial.println("loop");
for (int i = 0; i<10; i++) { for (int i = 0; i<10; i++) {
delay(100); delay(100);
if (flag_next) {
next_song(); switch (flag) {
} else if (flag_pause) { case BTN_NEXT:
toggle_pause(); Serial.println("next flag");
} else if (flag_volup) { next_song();
display_volume(); flag = BTN_NONE;
volume_up(); break;
delay(10); case BTN_PAUSE:
display_volume(); Serial.println("pause flag");
delay(500); toggle_pause();
while (!digitalRead(BUTTON_VOLUP)) { flag = BTN_NONE;
break;
case BTN_VOLUP:
Serial.println("volup flag");
display_volume();
volume_up(); volume_up();
delay(10); delay(10);
display_volume(); display_volume();
delay(250); delay(500);
} while (!digitalRead(BUTTON_VOLUP)) {
} else if (flag_voldn) { volume_up();
display_volume(); delay(10);
delay(10); display_volume();
volume_down(); delay(250);
display_volume(); }
delay(500); flag = BTN_NONE;
while (!digitalRead(BUTTON_VOLDN)) { break;
volume_down(); case BTN_VOLDN:
delay(10); Serial.println("voldn flag");
display_volume(); display_volume();
delay(250); delay(10);
} volume_down();
display_volume();
delay(500);
while (!digitalRead(BUTTON_VOLDN)) {
volume_down();
delay(10);
display_volume();
delay(250);
}
flag = BTN_NONE;
break;
} }
flag_next = false;
flag_pause = false;
flag_volup = false;
flag_voldn = false;
} }
display_song_info(); display_song_info();
} }
void display_error(char* error) { void display_error(char* error) {
Serial.println("Displaying error:");
Serial.println(error);
display.clearDisplay(); display.clearDisplay();
display.setCursor(0, 0); display.setCursor(0, 0);
display.println("Error:"); display.println("Error:");
@@ -235,12 +175,20 @@ void display_error(char* error) {
void send_command(String command) { void send_command(String command) {
WiFiClient client; WiFiClient client;
client.connect(MPDHOST, MPDPORT); if (client.connect(MPDHOST, MPDPORT)) {
client.println(command); client.println(command);
while (client.available()) { while (client.available()) {
Serial.write(client.read()); Serial.write(client.read());
}
client.stop();
}
else {
Serial.print("send command \"");
Serial.print(command);
Serial.println("\" failed");
display_error("mpd connect failed");
client.stop();
} }
client.stop();
} }
void next_song() { void next_song() {
@@ -299,28 +247,29 @@ int get_volume() {
else { else {
display_error("mpd connect failed"); display_error("mpd connect failed");
client.stop(); client.stop();
return; return -1;
} }
return atoi(vol_str); return vol_str.toInt();
} }
void display_volume() { int get_song_info(song_info* song_info) {
WiFiClient client; WiFiClient client;
String volume;
if (client.connect(MPDHOST, MPDPORT)) { if (client.connect(MPDHOST, MPDPORT)) {
Serial.println("connected"); Serial.println("connected");
client.print("status\n"); client.print("currentsong\n");
while (client.connected() || client.available()) while (client.connected() || client.available())
{ {
if (client.available()) if (client.available())
{ {
String line = client.readStringUntil('\n'); String line = client.readStringUntil('\n');
if (line.startsWith("volume: ")) { if (line.startsWith("Title: ")) {
volume = line.substring(8); song_info->title = line.substring(7);
}
else if (line.startsWith("Artist: ")) {
song_info->artist = line.substring(8);
} }
else if (line.equals("OK")) { else if (line.equals("OK")) {
client.stop(); client.stop();
@@ -334,9 +283,15 @@ void display_volume() {
else { else {
display_error("mpd connect failed"); display_error("mpd connect failed");
client.stop(); client.stop();
return; return 1;
} }
return 0;
}
void display_volume() {
int volume = get_volume();
display.clearDisplay(); display.clearDisplay();
display.drawBitmap(0, 0, volume_icon, 32, 32, WHITE); display.drawBitmap(0, 0, volume_icon, 32, 32, WHITE);
@@ -351,36 +306,10 @@ void display_volume() {
void display_song_info() { void display_song_info() {
WiFiClient client; WiFiClient client;
String title; song_info song_info;
String artist;
if (client.connect(MPDHOST, MPDPORT)) { if (get_song_info(&song_info)) {
Serial.println("connected"); Serial.println("Error in get_song_info");
client.print("currentsong\n");
while (client.connected() || client.available())
{
if (client.available())
{
String line = client.readStringUntil('\n');
if (line.startsWith("Title: ")) {
title = line.substring(7);
}
else if (line.startsWith("Artist: ")) {
artist = line.substring(8);
}
else if (line.equals("OK")) {
client.stop();
}
}
}
client.stop();
Serial.println("connection done");
}
else {
display_error("mpd connect failed");
client.stop();
return; return;
} }
@@ -390,8 +319,8 @@ void display_song_info() {
display.setTextColor(WHITE); display.setTextColor(WHITE);
display.setCursor(0, 0); display.setCursor(0, 0);
display.setTextWrap(false); display.setTextWrap(false);
display.println(title); display.println(song_info.title);
display.println(artist); display.println(song_info.artist);
display.display(); // Show initial text display.display(); // Show initial text
} }