Skip to content

Commit

Permalink
Fix #133 (#134)
Browse files Browse the repository at this point in the history
Fix #133
  • Loading branch information
Eeems authored Jan 4, 2021
1 parent fa83f22 commit 59074e4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 deletions.
14 changes: 12 additions & 2 deletions applications/system-service/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <QCommandLineParser>
#include <QGuiApplication>

#include <cstdlib>

Expand Down Expand Up @@ -40,11 +41,21 @@ void onExit(){
}
}

const char *qt_version = qVersion();

int main(int argc, char *argv[]){
if (strcmp(qt_version, QT_VERSION_STR) != 0){
qDebug() << "Version mismatch, Runtime: " << qt_version << ", Build: " << QT_VERSION_STR;
}
#ifdef __arm__
// Setup epaper
qputenv("QMLSCENE_DEVICE", "epaper");
qputenv("QT_QPA_PLATFORM", "epaper:enable_fonts");
#endif
atexit(onExit);
signal(SIGTERM, unixSignalHandler);
signal(SIGKILL, unixSignalHandler);
QCoreApplication app(argc, argv);
QGuiApplication app(argc, argv);
app.setOrganizationName("Eeems");
app.setOrganizationDomain(OXIDE_SERVICE);
app.setApplicationName("tarnish");
Expand All @@ -54,7 +65,6 @@ int main(int argc, char *argv[]){
parser.addHelpOption();
parser.applicationDescription();
parser.addVersionOption();

parser.process(app);

const QStringList args = parser.positionalArguments();
Expand Down
49 changes: 14 additions & 35 deletions applications/system-service/screenapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
#include <QObject>
#include <QDebug>
#include <QFile>
#include <QPainter>

#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <epframebuffer.h>

#include "apibase.h"
#include "mxcfb.h"
Expand Down Expand Up @@ -48,44 +50,21 @@ class ScreenAPI : public APIBase {

Q_INVOKABLE bool drawFullscreenImage(QString path){
if(!QFile(path).exists()){
qDebug() << "Can't find image" << path;
return false;
}
int width, height, channels;
auto decoded = (uint32_t*)stbi_load(path.toStdString().c_str(), &width, &height, &channels, 4);
int fd = open("/dev/fb0", O_RDWR);
auto ptr = (remarkable_color*)mmap(NULL, RDISPLAYSIZE, PROT_WRITE, MAP_SHARED, fd, 0);
auto src = decoded;
for(int j = 0; j < height; j++){
if(j >= RDISPLAYHEIGHT){
break;
}
for(int i = 0; i < width; i++){
if(i >= RDISPLAYWIDTH){
break;
}
if(src[i] != 0){
ptr[i] = (remarkable_color)src[i];
}
}
ptr += RDISPLAYWIDTH;
src += width;
QImage img(path);
if(img.isNull()){
qDebug() << "Image data invalid" << path;
return false;
}
mxcfb_update_data update_data;
mxcfb_rect update_rect;
update_rect.top = 0;
update_rect.left = 0;
update_rect.width = DISPLAYWIDTH;
update_rect.height = DISPLAYHEIGHT;
update_data.update_marker = 0;
update_data.update_region = update_rect;
update_data.waveform_mode = WAVEFORM_MODE_AUTO;
update_data.update_mode = UPDATE_MODE_FULL;
update_data.dither_mode = EPDC_FLAG_USE_DITHERING_MAX;
update_data.temp = TEMP_USE_REMARKABLE_DRAW;
update_data.flags = 0;
ioctl(fd, MXCFB_SEND_UPDATE, &update_data);
free(decoded);
close(fd);
auto size = EPFrameBuffer::framebuffer()->size();
QRect rect(0, 0, size.width(), size.height());
QPainter painter(EPFrameBuffer::framebuffer());
painter.drawImage(rect, img);
painter.end();
EPFrameBuffer::sendUpdate(rect, EPFrameBuffer::HighQualityGrayscale, EPFrameBuffer::FullUpdate, true);
EPFrameBuffer::waitForLastUpdate();
return true;
}

Expand Down
1 change: 0 additions & 1 deletion applications/system-service/tarnish.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
QT -= gui
QT += dbus

CONFIG += c++11 console
Expand Down

0 comments on commit 59074e4

Please sign in to comment.