Compare commits
No commits in common. "a3e4011a70e2298b21fc374a94ceae74503c624e" and "928dc8d820a15e8e46ecdee3cb46db8514013fe5" have entirely different histories.
a3e4011a70
...
928dc8d820
|
@ -4,6 +4,3 @@
|
||||||
[submodule "libs/spdlog"]
|
[submodule "libs/spdlog"]
|
||||||
path = libs/spdlog
|
path = libs/spdlog
|
||||||
url = ssh://git@git.betalupi.com:33/mirrors-libs/spdlog.git
|
url = ssh://git@git.betalupi.com:33/mirrors-libs/spdlog.git
|
||||||
[submodule "libs/libmpdclient"]
|
|
||||||
path = libs/libmpdclient
|
|
||||||
url = ssh://git@git.betalupi.com:33/mirrors-libs/libmpdclient.git
|
|
||||||
|
|
25
Makefile
25
Makefile
|
@ -14,7 +14,7 @@ clean:
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|
||||||
|
|
||||||
libs: $(BUILD_DIR)/hid.o $(BUILD_DIR)/libmpdclient.o
|
libs: $(BUILD_DIR)/hid.o
|
||||||
|
|
||||||
.PHONY: clean all run libs
|
.PHONY: clean all run libs
|
||||||
|
|
||||||
|
@ -26,9 +26,7 @@ CPPFLAGS := -MMD -MP \
|
||||||
-Wall \
|
-Wall \
|
||||||
-I src \
|
-I src \
|
||||||
-I libs/hidapi/hidapi \
|
-I libs/hidapi/hidapi \
|
||||||
-I libs/spdlog/include \
|
-I libs/spdlog/include
|
||||||
-I libs/libmpdclient/include \
|
|
||||||
-I libs/libmpdclient/output
|
|
||||||
|
|
||||||
# udev: required by hidapi
|
# udev: required by hidapi
|
||||||
LDFLAGS := -l fftw3 -l udev
|
LDFLAGS := -l fftw3 -l udev
|
||||||
|
@ -37,7 +35,7 @@ LDFLAGS := -l fftw3 -l udev
|
||||||
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp')
|
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp')
|
||||||
# Turns src/a.cpp into build/src/a.cpp.o
|
# Turns src/a.cpp into build/src/a.cpp.o
|
||||||
SRC_OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
SRC_OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||||
LIB_OBJS := $(BUILD_DIR)/hid.o $(BUILD_DIR)/libmpdclient.o
|
LIB_OBJS := $(BUILD_DIR)/hid.o
|
||||||
OBJS = $(SRC_OBJS) $(LIB_OBJS)
|
OBJS = $(SRC_OBJS) $(LIB_OBJS)
|
||||||
# Turns build/a.cpp.o into build/a.cpp.d
|
# Turns build/a.cpp.o into build/a.cpp.d
|
||||||
DEPS := $(OBJS:.o=.d)
|
DEPS := $(OBJS:.o=.d)
|
||||||
|
@ -49,26 +47,19 @@ DEPS := $(OBJS:.o=.d)
|
||||||
### Libraries
|
### Libraries
|
||||||
|
|
||||||
# Build hidapi
|
# Build hidapi
|
||||||
|
HIDAPI_PATH := libs/hidapi
|
||||||
$(BUILD_DIR)/hid.o:
|
$(BUILD_DIR)/hid.o:
|
||||||
@mkdir -p $(BUILD_DIR)
|
@mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
@echo "Compiling hid.o"
|
@echo "Compiling hid.o"
|
||||||
@gcc -Wall -g -fpic -c \
|
@gcc -Wall -g -fpic -c \
|
||||||
-I libs/hidapi/hidapi \
|
-I $(HIDAPI_PATH)/hidapi \
|
||||||
`pkg-config libusb-1.0 --cflags` \
|
`pkg-config libusb-1.0 --cflags` \
|
||||||
libs/hidapi/linux/hid.c \
|
\
|
||||||
|
$(HIDAPI_PATH)/linux/hid.c \
|
||||||
-o $(BUILD_DIR)/hid.o
|
-o $(BUILD_DIR)/hid.o
|
||||||
|
|
||||||
|
|
||||||
# Build libmpdclient
|
|
||||||
$(BUILD_DIR)/libmpdclient.o:
|
|
||||||
@cd libs/libmpdclient && \
|
|
||||||
meson . output && \
|
|
||||||
ninja -C output
|
|
||||||
|
|
||||||
ln -s ../libs/libmpdclient/output/libmpdclient.so $(BUILD_DIR)/libmpdclient.o
|
|
||||||
|
|
||||||
|
|
||||||
### Source
|
### Source
|
||||||
|
|
||||||
# C++ build step
|
# C++ build step
|
||||||
|
@ -81,5 +72,7 @@ $(BUILD_DIR)/%.cpp.o: %.cpp
|
||||||
$(TARGET_EXEC) : $(OBJS)
|
$(TARGET_EXEC) : $(OBJS)
|
||||||
g++ $(OBJS) -o $@ $(LDFLAGS)
|
g++ $(OBJS) -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Include generated makefiles
|
# Include generated makefiles
|
||||||
-include $(DEPS)
|
-include $(DEPS)
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 7124a0ad4841a44db084bb785a6e7120bc8f0139
|
|
|
@ -18,8 +18,8 @@
|
||||||
#define KB_RESOLUTION (5 * 50)
|
#define KB_RESOLUTION (5 * 50)
|
||||||
|
|
||||||
// How many resolution steps to skip at the top and bottom.
|
// How many resolution steps to skip at the top and bottom.
|
||||||
#define BOTTOM_SKIP 100
|
#define BOTTOM_SKIP 25
|
||||||
#define TOP_SKIP 0
|
#define TOP_SKIP 50
|
||||||
|
|
||||||
// Spectrum visualizer range
|
// Spectrum visualizer range
|
||||||
#define MIN_HZ 100
|
#define MIN_HZ 100
|
||||||
|
|
20
src/main.cpp
20
src/main.cpp
|
@ -8,8 +8,6 @@
|
||||||
// For sleep
|
// For sleep
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
// MPD client
|
|
||||||
#include "mpd/client.h"
|
|
||||||
|
|
||||||
// Local files
|
// Local files
|
||||||
#include "utility/bitmap.hpp"
|
#include "utility/bitmap.hpp"
|
||||||
|
@ -52,8 +50,6 @@ const size_t width = 10;
|
||||||
const size_t height = BOTTOM_SKIP + KB_RESOLUTION + TOP_SKIP;
|
const size_t height = BOTTOM_SKIP + KB_RESOLUTION + TOP_SKIP;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
spdlog::set_level(spdlog::level::info);
|
spdlog::set_level(spdlog::level::info);
|
||||||
|
@ -94,26 +90,15 @@ int main(int argc, char *argv[]) {
|
||||||
std::chrono::steady_clock,
|
std::chrono::steady_clock,
|
||||||
std::chrono::nanoseconds
|
std::chrono::nanoseconds
|
||||||
> t = std::chrono::steady_clock::now();
|
> t = std::chrono::steady_clock::now();
|
||||||
|
//t += std::chrono::milliseconds(30);
|
||||||
|
//this_thread::sleep_until(t);
|
||||||
|
|
||||||
std::chrono::time_point<
|
|
||||||
std::chrono::steady_clock,
|
|
||||||
std::chrono::nanoseconds
|
|
||||||
> last_fifo_sync = std::chrono::steady_clock::now();
|
|
||||||
|
|
||||||
struct mpd_connection *conn = mpd_connection_new(NULL, 0, 0);
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
if (Dox.is_connected()) {
|
if (Dox.is_connected()) {
|
||||||
if (std::chrono::steady_clock::now() > t + std::chrono::milliseconds(30)) {
|
if (std::chrono::steady_clock::now() > t + std::chrono::milliseconds(30)) {
|
||||||
if (Dox.get_animation_mode() == 0x02) {
|
if (Dox.get_animation_mode() == 0x02) {
|
||||||
if (std::chrono::steady_clock::now() > last_fifo_sync + std::chrono::seconds(10)) {
|
|
||||||
mpd_run_disable_output(conn, 1);
|
|
||||||
mpd_run_enable_output(conn, 1);
|
|
||||||
last_fifo_sync = std::chrono::steady_clock::now();
|
|
||||||
spdlog::info("Synchronized fifo");
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.update();
|
buf.update();
|
||||||
fft.update(buf);
|
fft.update(buf);
|
||||||
|
|
||||||
|
@ -155,6 +140,5 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mpd_connection_free(conn);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue