mirror of
https://github.com/jtgans/g13gui.git
synced 2025-06-20 00:14:09 -04:00
cleanups: Migrate source files to appropriate dirs and fix names
This cleans things up significantly in the source tree and makes this easier to manage longer term. In the next few commits, we'll migrate the build to CMake in prep for packaging support. - Move bindings into bindings - Move system configs and misc files into etc - Move LCD apps into contrib/ - Move all source files into srcs - Rename helper extensions to match GNU extension naming, fix the #includes as well - Adjust Makefile to be less verbose and more programmatic
This commit is contained in:
parent
713b4beefc
commit
b490dd9fff
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,7 +1 @@
|
|||||||
/g13d
|
build/
|
||||||
.cproject
|
|
||||||
.project
|
|
||||||
.pydevproject
|
|
||||||
*.o
|
|
||||||
pbm2lpbm
|
|
||||||
.settings/*
|
|
||||||
|
64
Makefile
64
Makefile
@ -1,52 +1,42 @@
|
|||||||
all: g13d pbm2lpbm
|
CXXFLAGS := $(CXXFLAGS) -DBOOST_LOG_DYN_LINK=1 -std=c++0x
|
||||||
|
LIBS := -lusb-1.0 -lboost_program_options -lboost_log -lboost_system -lpthread
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
|
||||||
FLAGS=$(CXXFLAGS) -DBOOST_LOG_DYN_LINK -std=c++0x
|
G13D_SRCS := \
|
||||||
LIBS=-lusb-1.0 -lboost_log -lboost_log_setup-mt -lboost_thread -lboost_system-mt -lpthread
|
src/g13.cc \
|
||||||
|
src/g13_fonts.cc \
|
||||||
|
src/g13_keys.cc \
|
||||||
|
src/g13_lcd.cc \
|
||||||
|
src/g13_log.cc \
|
||||||
|
src/g13_main.cc \
|
||||||
|
src/g13_stick.cc \
|
||||||
|
src/helper.cc
|
||||||
|
|
||||||
g13.o: g13.h helper.hpp g13.cc
|
G13D_OBJS := $(patsubst src/%.cc,build/%.o,$(G13D_SRCS))
|
||||||
g++ $(FLAGS) -c g13.cc
|
|
||||||
|
|
||||||
g13_main.o: g13.h helper.hpp g13_main.cc
|
all: build build/g13d build/pbm2lpbm
|
||||||
g++ $(FLAGS) -c g13_main.cc
|
|
||||||
|
|
||||||
|
build:
|
||||||
|
mkdir -p build
|
||||||
|
|
||||||
g13_log.o: g13.h helper.hpp g13_log.cc
|
build/g13d: $(G13D_OBJS) | build
|
||||||
g++ $(FLAGS) -c g13_log.cc
|
$(CXX) $(G13D_OBJS) -o build/g13d $(LIBS)
|
||||||
|
|
||||||
g13_fonts.o: g13.h helper.hpp g13_fonts.cc
|
build/pbm2lpbm: src/pbm2lpbm.c | build
|
||||||
g++ $(FLAGS) -c g13_fonts.cc
|
$(CXX) $(CXXFLAGS) src/pbm2lpbm.c -o build/pbm2lpbm
|
||||||
|
|
||||||
g13_lcd.o: g13.h helper.hpp g13_lcd.cc
|
build/%.o: src/%.cc
|
||||||
g++ $(FLAGS) -c g13_lcd.cc
|
$(CXX) -c -o $@ $< $(CXXFLAGS)
|
||||||
|
|
||||||
g13_stick.o: g13.h helper.hpp g13_stick.cc
|
|
||||||
g++ $(FLAGS) -c g13_stick.cc
|
|
||||||
|
|
||||||
g13_keys.o: g13.h helper.hpp g13_keys.cc
|
|
||||||
g++ $(FLAGS) -c g13_keys.cc
|
|
||||||
|
|
||||||
helper.o: helper.hpp helper.cpp
|
|
||||||
g++ $(FLAGS) -c helper.cpp
|
|
||||||
|
|
||||||
|
|
||||||
g13d: g13_main.o g13.o g13_log.o g13_fonts.o g13_lcd.o g13_stick.o g13_keys.o helper.o
|
|
||||||
g++ -o g13d -std=c++0x \
|
|
||||||
g13_main.o g13.o g13_log.o g13_fonts.o g13_lcd.o g13_stick.o g13_keys.o helper.o \
|
|
||||||
-lusb-1.0 -lboost_program_options \
|
|
||||||
-lboost_log \
|
|
||||||
-lboost_system -lpthread
|
|
||||||
|
|
||||||
pbm2lpbm: pbm2lpbm.c
|
|
||||||
g++ -o pbm2lpbm pbm2lpbm.c
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f g13 pbm2lpbm
|
rm -rf build
|
||||||
|
|
||||||
install:
|
install: build/g13d build/pbm2lpbm
|
||||||
install -d ${HOME}/.local/bin
|
install -d ${HOME}/.local/bin
|
||||||
install -m700 -d ${HOME}/.local/var/g13d
|
install -m700 -d ${HOME}/.local/var/g13d
|
||||||
install -d ${HOME}/.config/systemd/user
|
install -d ${HOME}/.config/systemd/user
|
||||||
cat g13d.service |sed "s,@HOME@,${HOME},g" > ${HOME}/.config/systemd/user/g13d.service
|
cat etc/g13d.service |sed "s,@HOME@,${HOME},g" > ${HOME}/.config/systemd/user/g13d.service
|
||||||
install -m755 g13d ${HOME}/.local/bin/g13d
|
install -m755 build/g13d ${HOME}/.local/bin/g13d
|
||||||
|
install -m755 build/pbm2lpbm ${HOME}/.local/bin/pbm2lpbm
|
||||||
|
|
||||||
.PHONY: all clean install
|
.PHONY: all clean install
|
||||||
|
47
contrib/g13_test.py
Executable file
47
contrib/g13_test.py
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
"""
|
||||||
|
simple test script to update G13 LCD with temperature values from lm-sensors
|
||||||
|
"""
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
def doCmd(*cmd):
|
||||||
|
# print("cmd = %r" % (cmd,))
|
||||||
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
out, err = p.communicate()
|
||||||
|
return out #, err
|
||||||
|
|
||||||
|
|
||||||
|
def get_sensors():
|
||||||
|
sensor_lines = doCmd('sensors').split('\n')
|
||||||
|
print("sensor_lines = %r" % (sensor_lines,))
|
||||||
|
temp_re = re.compile(r'''([a-zA-Z])[a-zA-Z s]+([0-9])\:\s*\+([0-9.]+)[\xc2\xb0C]*C.*''')
|
||||||
|
|
||||||
|
temps = []
|
||||||
|
for line in sensor_lines:
|
||||||
|
m = temp_re.match(line)
|
||||||
|
if m:
|
||||||
|
tag, index, value = m.groups()
|
||||||
|
print("%s%s = %s" % (tag, index, value))
|
||||||
|
# temps.append("%s%s:%s" % (tag, index, value))
|
||||||
|
temps.append("%s" % (value,))
|
||||||
|
# else:
|
||||||
|
# print("failed to match %r" % (line,))
|
||||||
|
|
||||||
|
with open('/home/jtgans/.local/var/g13d/in', 'w') as p:
|
||||||
|
p.write('pos 0 0 \n')
|
||||||
|
p.write('out %s\n' % (' '.join(temps)))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
while True:
|
||||||
|
get_sensors()
|
||||||
|
time.sleep(1.0)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Before Width: | Height: | Size: 335 KiB After Width: | Height: | Size: 335 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
41
g13_test.py
41
g13_test.py
@ -1,41 +0,0 @@
|
|||||||
#!/usr/bin/python2.7
|
|
||||||
import subprocess, re, os, time
|
|
||||||
|
|
||||||
# simple test script to update G13 LCD with temperature values from lm-sensors
|
|
||||||
|
|
||||||
def doCmd( *cmd ):
|
|
||||||
#print( "cmd = %r" % (cmd,) )
|
|
||||||
p = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
|
|
||||||
out, err = p.communicate()
|
|
||||||
return out #, err
|
|
||||||
|
|
||||||
def get_sensors():
|
|
||||||
sensor_lines = doCmd( 'sensors' ).split('\n')
|
|
||||||
print( "sensor_lines = %r" % (sensor_lines,) )
|
|
||||||
temp_re = re.compile( r'''([a-zA-Z])[a-zA-Z s]+([0-9])\:\s*\+([0-9.]+)[\xc2\xb0C]*C.*''' )
|
|
||||||
|
|
||||||
temps = []
|
|
||||||
for line in sensor_lines:
|
|
||||||
m = temp_re.match(line)
|
|
||||||
if m:
|
|
||||||
tag, index, value = m.groups()
|
|
||||||
print( "%s%s = %s" % (tag, index, value))
|
|
||||||
#temps.append( "%s%s:%s" % (tag, index, value) )
|
|
||||||
temps.append( "%s" % (value,) )
|
|
||||||
# else:
|
|
||||||
# print( "failed to match %r" % (line,))
|
|
||||||
|
|
||||||
|
|
||||||
with open( '/tmp/g13-0', 'w') as p:
|
|
||||||
p.write( 'pos 0 0 \n' )
|
|
||||||
p.write( 'out %s\n' % (' '.join(temps)) )
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
while 1:
|
|
||||||
get_sensors()
|
|
||||||
time.sleep(1.0)
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
#define __G13_H__
|
#define __G13_H__
|
||||||
|
|
||||||
|
|
||||||
#include "helper.hpp"
|
#include "helper.h"
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
@ -26,7 +26,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "helper.hpp"
|
#include "helper.h"
|
||||||
|
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue
Block a user