Compare commits

..

No commits in common. "a3e4011a70e2298b21fc374a94ceae74503c624e" and "928dc8d820a15e8e46ecdee3cb46db8514013fe5" have entirely different histories.

5 changed files with 13 additions and 40 deletions

3
.gitmodules vendored
View File

@ -4,6 +4,3 @@
[submodule "libs/spdlog"]
path = libs/spdlog
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

View File

@ -14,7 +14,7 @@ clean:
@echo ""
libs: $(BUILD_DIR)/hid.o $(BUILD_DIR)/libmpdclient.o
libs: $(BUILD_DIR)/hid.o
.PHONY: clean all run libs
@ -26,9 +26,7 @@ CPPFLAGS := -MMD -MP \
-Wall \
-I src \
-I libs/hidapi/hidapi \
-I libs/spdlog/include \
-I libs/libmpdclient/include \
-I libs/libmpdclient/output
-I libs/spdlog/include
# udev: required by hidapi
LDFLAGS := -l fftw3 -l udev
@ -37,7 +35,7 @@ LDFLAGS := -l fftw3 -l udev
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp')
# Turns src/a.cpp into build/src/a.cpp.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)
# Turns build/a.cpp.o into build/a.cpp.d
DEPS := $(OBJS:.o=.d)
@ -49,26 +47,19 @@ DEPS := $(OBJS:.o=.d)
### Libraries
# Build hidapi
HIDAPI_PATH := libs/hidapi
$(BUILD_DIR)/hid.o:
@mkdir -p $(BUILD_DIR)
@echo "Compiling hid.o"
@gcc -Wall -g -fpic -c \
-I libs/hidapi/hidapi \
-I $(HIDAPI_PATH)/hidapi \
`pkg-config libusb-1.0 --cflags` \
libs/hidapi/linux/hid.c \
\
$(HIDAPI_PATH)/linux/hid.c \
-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
# C++ build step
@ -81,5 +72,7 @@ $(BUILD_DIR)/%.cpp.o: %.cpp
$(TARGET_EXEC) : $(OBJS)
g++ $(OBJS) -o $@ $(LDFLAGS)
# Include generated makefiles
-include $(DEPS)

@ -1 +0,0 @@
Subproject commit 7124a0ad4841a44db084bb785a6e7120bc8f0139

View File

@ -18,8 +18,8 @@
#define KB_RESOLUTION (5 * 50)
// How many resolution steps to skip at the top and bottom.
#define BOTTOM_SKIP 100
#define TOP_SKIP 0
#define BOTTOM_SKIP 25
#define TOP_SKIP 50
// Spectrum visualizer range
#define MIN_HZ 100

View File

@ -8,8 +8,6 @@
// For sleep
#include <chrono>
#include <thread>
// MPD client
#include "mpd/client.h"
// Local files
#include "utility/bitmap.hpp"
@ -52,8 +50,6 @@ const size_t width = 10;
const size_t height = BOTTOM_SKIP + KB_RESOLUTION + TOP_SKIP;
int main(int argc, char *argv[]) {
spdlog::set_level(spdlog::level::info);
@ -94,26 +90,15 @@ int main(int argc, char *argv[]) {
std::chrono::steady_clock,
std::chrono::nanoseconds
> 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) {
if (Dox.is_connected()) {
if (std::chrono::steady_clock::now() > t + std::chrono::milliseconds(30)) {
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();
fft.update(buf);
@ -155,6 +140,5 @@ int main(int argc, char *argv[]) {
}
}
mpd_connection_free(conn);
return 0;
}