aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/CMakeLists.txt
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-20 15:31:14 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 15:55:03 +0100
commit04b7efcdd1a8dfdf461c78d083aabee5445e54bd (patch)
treeccb146ebee3324b2e220430d476b1d9addaa451c /low-can-binding/CMakeLists.txt
parent47322aceac11e3142af4339260a74ccfba675e17 (diff)
can-bus: Use configuration from JSON file
Use configuration from JSON file instead of the old INI file. Now all configuration files lies within the binding tree. Bug-AGL: SPEC-2988 Change-Id: Id986d19751db958ad5cf3b7f2b2c5443d4ceb062 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/CMakeLists.txt')
-rw-r--r--low-can-binding/CMakeLists.txt1
1 files changed, 0 insertions, 1 deletions
diff --git a/low-can-binding/CMakeLists.txt b/low-can-binding/CMakeLists.txt
index bd304dc9..cba07bf5 100644
--- a/low-can-binding/CMakeLists.txt
+++ b/low-can-binding/CMakeLists.txt
@@ -58,7 +58,6 @@ PROJECT_TARGET_ADD(low-can)
utils/socketcan.cpp
#utils/socketcan-raw.cpp
utils/socketcan-bcm.cpp
- utils/config-parser.cpp
utils/converter.cpp
)
81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/**
  Source : inspired by https://www.kdab.com/qt-input-method-virtual-keyboard/
  */

#include "Keyboard.h"

#include <QWidget>
#include <QRect>
#include <QString>
#include <QSignalMapper>
#include <QPushButton>
#include <QImageReader>

#define NEXT_ROW_MARKER '\0'

#define SIZE_FACTOR 1       /* looks nice on AGL demo */
//#define SIZE_FACTOR 0.5   /* looks nice on PC build */

#define OFFSET_H        ( 78 * SIZE_FACTOR )
#define KEY_WIDTH       ( 78 * SIZE_FACTOR )
#define KEY_HEIGHT      ( 94 * SIZE_FACTOR )
#define MARGIN_H        ( 12 * SIZE_FACTOR )
#define MARGIN_V        ( 18 * SIZE_FACTOR )
#define SPACE_BAR_WIDTH ( 502 * SIZE_FACTOR )

struct KeyboardLayoutEntry
{
    int key;
    const char *image;
};

static KeyboardLayoutEntry keyboardLayout[] = {
    { '1' , "1.png" },
    { '2' , "2.png" },
    { '3' , "3.png" },
    { '4' , "4.png" },
    { '5' , "5.png" },
    { '6' , "6.png" },
    { '7' , "7.png" },
    { '8' , "8.png" },
    { '9' , "9.png" },
    { '0' , "0.png" },
    { NEXT_ROW_MARKER, NULL },
    { 'q' , "Q.png" },
    { 'w' , "W.png" },
    { 'e' , "E.png" },
    { 'r' , "R.png" },
    { 't' , "T.png" },
    { 'y' , "Y.png" },
    { 'u' , "U.png" },
    { 'i' , "I.png" },
    { 'o' , "O.png" },
    { 'p' , "P.png" },
    { NEXT_ROW_MARKER, NULL },
    { 'a' , "A.png" },
    { 's' , "S.png" },
    { 'd' , "D.png" },
    { 'f' , "F.png" },
    { 'g' , "G.png" },
    { 'h' , "H.png" },
    { 'j' , "J.png" },
    { 'k' , "K.png" },
    { 'l' , "L.png" },
    { NEXT_ROW_MARKER, NULL },
    { 'z' , "Z.png" },
    { 'x' , "X.png" },
    { 'c' , "C.png" },
    { 'v' , "V.png" },
    { 'b' , "B.png" },
    { 'n' , "N.png" },
    { 'm' , "M.png" },
    { '!' , "exclam.png" },
    { '\b',"back.png" },
    { NEXT_ROW_MARKER, NULL },
    { '\'',"apostrophe.png" },
    { '&' , "et.png" },
    { ' ' , "space.png" },
    { '-' , "minus.png" },
    { '/' , "slash.png" }
};

const static int layoutSize = (sizeof(keyboardLayout) /
                               sizeof(KeyboardLayoutEntry));

Keyboard::Keyboard(QRect r, QWidget *parent):QWidget(parent),background(parent),
    rect(QRect(r.x() + (r.width()-(r.width()*SIZE_FACTOR))/2, r.y(), r.width()*SIZE_FACTOR, r.height()*SIZE_FACTOR)),
    mapper(new QSignalMapper(this))
{
    int nbRowMarkers = 1;
    for (int i = 0; i < layoutSize; ++i)
        if (keyboardLayout[i].key == NEXT_ROW_MARKER)
            nbRowMarkers++;

    connect(mapper, SIGNAL(mapped(int)), SLOT(buttonClicked(int)));

    int row = 0;
    int offset_h = KEY_WIDTH;
    int offset_v = (rect.height() - (KEY_HEIGHT*nbRowMarkers + MARGIN_V*(nbRowMarkers-1))) / 2;

    background.setGeometry(rect);
    QImageReader reader(QString(":/images/background.png"));
    background.setPixmap(QPixmap::fromImage(reader.read()).scaled(rect.width(), rect.height(), Qt::IgnoreAspectRatio));

    background.show();

    for (int i = 0; i < layoutSize; ++i)
    {
        int key_width = KEY_WIDTH;
        if (keyboardLayout[i].key == NEXT_ROW_MARKER)
        {
            row++;
            offset_h = OFFSET_H;
            if (row == 2)
                offset_h += (KEY_WIDTH + MARGIN_H)/2;
            else if (row == 3)
                offset_h += (KEY_WIDTH + MARGIN_H);
            offset_v += (KEY_HEIGHT+MARGIN_V);
            continue;
        }
        else if (keyboardLayout[i].key ==  ' ')
        {
            key_width = SPACE_BAR_WIDTH;
        }

        QPushButton *button = new QPushButton(QIcon(tr(":/images/")+QString(keyboardLayout[i].image)), tr(""), &background);
        button->setMinimumSize(QSize(key_width, KEY_HEIGHT));
        button->setMaximumSize(QSize(key_width, KEY_HEIGHT));
        button->setIconSize(button->size());
        /* geometry of button is relative to its parent, ie 'background' : */
        button->setGeometry(QRect(offset_h, offset_v, button->width(), button->height()));
        button->show();

        mapper->setMapping(button, keyboardLayout[i].key);
        connect(button, SIGNAL(clicked()), mapper, SLOT(map()));

        offset_h += (key_width+MARGIN_H);
    }
}

void Keyboard::buttonClicked(int key)
{
    if (key == '\b') /* backspace */
        emit specialKeyClicked(key);
    else
        emit keyClicked(QString(key));
}

Keyboard::~Keyboard()
{
    disconnect();
    delete mapper;
}