Commit b8140ad6 authored by Mart Lubbers's avatar Mart Lubbers

Merge branch 'fix-curses' into 'master'

Fix curses interfaces

See merge request mlubbers/mTask!27
parents ddaf25be bf638b61
Pipeline #43915 passed with stages
in 10 minutes and 19 seconds
......@@ -33,7 +33,7 @@ linux-x64:
stage: package
script:
- apt-get update -qq
- apt-get install -yy build-essential curl
- apt-get install -yy build-essential curl libncurses-dev pkg-config libxaw7-dev libxt-dev unzip
- ./pkg_linux64.sh
artifacts:
paths:
......
......@@ -136,7 +136,13 @@ The firmware can be customized using preprocessor macros.
- CURSES\_INTERFACE
Use the experimental curses frontend (requires libncurses)
If set to `pdcurses` it will build an X11 curses application on linux.
If set to anything else it will build an ncurses terminal application on
linux and a `pdcurses` windows application on windows.
- NOMOUSE
Disables the mouse support for the curses application
#### Arduino
......
......@@ -10,6 +10,22 @@ trap "rm -rf $TARGET" EXIT
# Build the pc rts
cp rts/mtaskwifi.h{.def,}
make -f Makefile.pc -C rts
mv rts/client{,-tty}
# Build the curses rts
make CURSES_INTERFACE=yes -f Makefile.pc -C rts -B
mv rts/client{,-curses}
# Build the xcurses rts
curl -LSso PDCurses.zip\
https://sourceforge.net/projects/pdcurses/files/pdcurses/3.9/PDCurses-3.9.zip
unzip -q -d rts PDCurses.zip
(
cd rts/PDCurses-3.9/x11
./configure
make
make install
)
make CURSES_INTERFACE=pdcurses -f Makefile.pc -C rts -B
mv rts/client{,-xcurses}
# Prepare directories
mkdir -p $TARGET/{mtask-rts/dependencies,{examples,lib,doc}/mTask}
......@@ -22,7 +38,7 @@ curl -SsL $CLEANSERIALURL | tar xz -C $TARGET/lib
cp mtask-posix.prt $TARGET/examples/mTask/mTask.prt
cp -R library/* $TARGET/lib/mTask/
cp programs/*.icl $TARGET/examples/mTask/
cp rts/{Makefile.*,*.{c,h,cpp},client} $TARGET/mtask-rts/
cp rts/{Makefile.*,*.{c,h,cpp},client-*} $TARGET/mtask-rts/
cp dependencies/*.zip $TARGET/mtask-rts/dependencies
cp DEVICES.md INSTALL.md README.md $TARGET/doc
......
......@@ -9,7 +9,17 @@ trap "rm -rf clean.zip $TARGET" EXIT
# Build the pc rts
cp rts/mtaskwifi.h{.def,}
DETECTED_OS=Windows CC=x86_64-w64-mingw32-gcc make -f Makefile.pc -C rts
make DETECTED_OS=Windows CC=x86_64-w64-mingw32-gcc -f Makefile.pc -C rts
mv rts/client{,-cmd}.exe
# Build the pc pdcurses rts
curl -LSso PDCurses.zip\
https://sourceforge.net/projects/pdcurses/files/pdcurses/3.9/PDCurses-3.9.zip
unzip -q -d rts PDCurses.zip
make -C rts/PDCurses-3.9/wincon CC=x86_64-w64-mingw32-gcc
make DETECTED_OS=Windows CC=x86_64-w64-mingw32-gcc CURSES_INTERFACE=yes\
-f Makefile.pc -B -C rts
mv rts/client{,-curses}.exe
# Prepare directories
mkdir -p $TARGET/{mtask-rts/dependencies,{Examples,Libraries,Help}/mTask}
......@@ -29,7 +39,7 @@ sed -i 's/\(CleanCompilerITasks64.exe : -h\) [[:digit:]]\+/\1 512/' $TARGET/Conf
cp mtask-windows.prt $TARGET/Examples/mTask/mTask.prt
cp -R library/* $TARGET/Libraries/mTask/
cp programs/*.icl $TARGET/Examples/mTask/
cp rts/{Makefile.*,*.{c,h,cpp},client.exe} $TARGET/mtask-rts/
cp rts/{Makefile.*,*.{c,h,cpp},client-*.exe} $TARGET/mtask-rts/
cp dependencies/*.zip $TARGET/mtask-rts/dependencies
cp DEVICES.md INSTALL.md README.md $TARGET/Help/mTask
......
CFLAGS := -std=c99
CPPFLAGS := -DPC -DSTACK_CHECKING -DDEBUG -D_DEFAULT_SOURCE -ggdb -Wall -Wextra
CFLAGS += -std=c99
CPPFLAGS += -DPC -DSTACK_CHECKING -DDEBUG -D_DEFAULT_SOURCE -ggdb -Wall -Wextra
OBJS:=interpret.o task.o client.o pc.o spec.o mem.o rewrite.o\
symbols_peripherals.o symbols_spec.o
symbols_peripherals.o symbols_spec.o pc_curses.o pc_tty.o
ifeq ($(OS), Windows_NT)
DETECTED_OS?=Windows
......@@ -10,19 +10,32 @@ else
DETECTED_OS?=POSIX
endif
ifeq ($(DETECTED_OS), Windows)
PROG:=client.exe
LDLIBS+=-lws2_32
PDCURSES ?=./PDCurses-3.9
ifdef CURSES_INTERFACE
CFLAGS+=-DCURSES_INTERFACE
LDLIBS+=-lpdcurses
CFLAGS+=-DCURSES_INTERFACE
endif
ifeq ($(DETECTED_OS), Windows)
PROG:=client.exe
LDLIBS+=-lws2_32
ifdef CURSES_INTERFACE
CFLAGS+=-I$(PDCURSES)
LDLIBS+=-l:pdcurses.a -L$(PDCURSES)/wincon
endif
else
PROG:=client
ifdef CURSES_INTERFACE
CFLAGS+=$(shell pkg-config --cflags ncurses) -DCURSES_INTERFACE
LDLIBS+=$(shell pkg-config --libs ncurses)
endif
PROG:=client
ifeq ($(CURSES_INTERFACE), pdcurses)
CFLAGS+=$(shell xcurses-config --cflags)
LDLIBS+=$(shell xcurses-config --libs-static)
else
ifdef CURSES_INTERFACE
CFLAGS+=$(shell pkg-config --cflags ncurses) -DCURSES_INTERFACE
LDLIBS+=$(shell pkg-config --libs ncurses)
endif
endif
endif
all: $(PROG)
......@@ -30,7 +43,7 @@ all: $(PROG)
$(PROG): $(OBJS)
$(LINK.o) $(OBJS) $(LDLIBS) $(OUTPUT_OPTION)
%.o: %.c %.h interface.h symbols.h
%.o: %.c %.h interface.h symbols.h Makefile
$(COMPILE.c) $(OUTPUT_OPTION) $<
clean:
......
This diff is collapsed.
......@@ -12,18 +12,21 @@
#define HAVE_I2CBUTTON
#define HAVE_AIRQUALITYSENSOR
#define SC(s) s
#ifdef CURSES_INTERFACE
#define LOGLEVEL 2
#else
#define LOGLEVEL 1
#endif
//#define USE_MALLOC
#ifndef max
#define max(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
extern int gargc;
extern char **gargv;
extern jmp_buf fpe;
void killHandler(int);
#define RECOVERABLE_ERROR_CODE {\
/*Restore point for SIGFPE exceptions*/\
if (setjmp(fpe) == 1) {\
......
This diff is collapsed.
#ifndef PC_INTERFACE_H
#define PC_INTERFACE_H
#include <stdint.h>
#include <stdarg.h>
#include "symbols_peripherals.h"
void pc_write_dpin(uint16_t, bool);
void pc_read_dpin(uint16_t);
void pc_write_apin(uint16_t, uint8_t);
void pc_read_apin(uint16_t);
void pc_set_pinmode(uint16_t, uint8_t);
void pc_humidity(struct mt_DHTInfo);
void pc_temperature(struct mt_DHTInfo);
void pc_light(void);
void pc_tvoc(void);
void pc_co2(void);
void pc_lmdot(uint8_t, uint8_t, bool);
void pc_lmintensity(uint8_t);
void pc_lmclear(void);
void pc_lmdisplay(void);
void pc_msg_log(const char *, va_list);
void pc_init(void);
void pc_reset(void);
void pc_exit(void);
void pc_yield(void);
#endif
#if defined(_WIN32) || defined(__APPLE__) || defined (__linux__)\
|| defined (__unix__)
#ifndef CURSES_INTERFACE
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include "interface.h"
#include "symbols.h"
extern bool dpins[DPINS];
extern uint8_t apins[APINS];
void pc_write_dpin(uint16_t i, bool b)
{
msg_log("dwrite %d: %d\n", i, b);
}
void pc_read_dpin(uint16_t i)
{
msg_log("dread %d: %s\n", i, dpins[i] ? "true" : "false");
}
void pc_write_apin(uint16_t i, uint8_t a)
{
msg_log("awrite %d: %d\n", i, a);
}
void pc_read_apin(uint16_t i)
{
msg_log("aread %d: %u\n", i, apins[i]);
}
void pc_set_pinmode(uint16_t p, uint8_t mode)
{
msg_log("set pinmode of %d to %s\n", p,
mode == PMINPUT ? "input" :
mode == PMOUTPUT ? "output" :
"input_pullup");
}
void pc_humidity(struct mt_DHTInfo dht) { (void)dht; }
void pc_temperature(struct mt_DHTInfo dht) { (void)dht; }
void pc_light(void) {}
void pc_tvoc(void) { };
void pc_co2(void) { };
void pc_lmdot(uint8_t x, uint8_t y, bool s)
{
msg_log("ledmatrix dot: %u %u %u\n", x, y, s);
}
void pc_lmintensity(uint8_t intensity)
{
msg_log("ledmatrix intensity: %u\n", intensity);
}
void pc_lmclear() { }
void pc_lmdisplay() { }
void pc_init(void) {}
void pc_msg_log(const char *fmt, va_list ap)
{
vfprintf(stderr, fmt, ap);
}
void pc_reset(void)
{
}
void pc_exit(void)
{
}
void pc_yield(void)
{
}
#endif
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment