cleanup
This commit is contained in:
82
icons.h
Normal file
82
icons.h
Normal 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
|
||||||
|
};
|
||||||
221
mpdclient.ino
221
mpdclient.ino
@@ -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);
|
||||||
@@ -179,17 +107,27 @@ 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) {
|
|
||||||
|
switch (flag) {
|
||||||
|
case BTN_NEXT:
|
||||||
|
Serial.println("next flag");
|
||||||
next_song();
|
next_song();
|
||||||
} else if (flag_pause) {
|
flag = BTN_NONE;
|
||||||
|
break;
|
||||||
|
case BTN_PAUSE:
|
||||||
|
Serial.println("pause flag");
|
||||||
toggle_pause();
|
toggle_pause();
|
||||||
} else if (flag_volup) {
|
flag = BTN_NONE;
|
||||||
|
break;
|
||||||
|
case BTN_VOLUP:
|
||||||
|
Serial.println("volup flag");
|
||||||
display_volume();
|
display_volume();
|
||||||
volume_up();
|
volume_up();
|
||||||
delay(10);
|
delay(10);
|
||||||
@@ -201,7 +139,10 @@ void loop() {
|
|||||||
display_volume();
|
display_volume();
|
||||||
delay(250);
|
delay(250);
|
||||||
}
|
}
|
||||||
} else if (flag_voldn) {
|
flag = BTN_NONE;
|
||||||
|
break;
|
||||||
|
case BTN_VOLDN:
|
||||||
|
Serial.println("voldn flag");
|
||||||
display_volume();
|
display_volume();
|
||||||
delay(10);
|
delay(10);
|
||||||
volume_down();
|
volume_down();
|
||||||
@@ -213,18 +154,17 @@ void loop() {
|
|||||||
display_volume();
|
display_volume();
|
||||||
delay(250);
|
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,13 +175,21 @@ 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();
|
client.stop();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Serial.print("send command \"");
|
||||||
|
Serial.print(command);
|
||||||
|
Serial.println("\" failed");
|
||||||
|
display_error("mpd connect failed");
|
||||||
|
client.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void next_song() {
|
void next_song() {
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user