File indexing completed on 2021-12-21 13:14:18

0001 /*
0002  * This file is part of KDevelop project
0003  * Copyright 2016 Patrick José Pereira <patrickelectric@gmail.com>
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU Library General Public License as
0007  * published by the Free Software Foundation; either version 2 of the
0008  * License, or (at your option) any later version.
0009  *
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public
0016  * License along with this program; if not, write to the
0017  * Free Software Foundation, Inc.,
0018  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #pragma once
0022 
0023 #include <QString>
0024 #include <QStringList>
0025 #include <QHash>
0026 #include <QFile>
0027 #include <QMap>
0028 #include <QLoggingCategory>
0029 
0030 Q_DECLARE_LOGGING_CATEGORY(BoMsg)
0031 
0032 //class QFile;
0033 
0034 class BoardInfo
0035 {
0036 public:
0037     void printData();
0038 
0039     // Board
0040 
0041     QStringList m_name;
0042     QStringList m_vid;
0043     QStringList m_pid;
0044 
0045     // Upload
0046 
0047     QStringList m_upTool;
0048     QStringList m_upProtocol;
0049     QStringList m_upMaxSize;
0050     QStringList m_upMaxDataSize;
0051     QStringList m_upSpeed;
0052     QStringList m_upDisableFlush;
0053     QStringList m_upUse1k2bpsTouch;
0054     QStringList m_upWaitForUploadPort;
0055 
0056     // Boot loader
0057 
0058     QStringList m_blTool;
0059     QStringList m_blLowFuses;
0060     QStringList m_blHighFuses;
0061     QStringList m_blExtendedFuses;
0062     QStringList m_blFile;
0063     QStringList m_blNoblink;
0064     QStringList m_blUnlockBits;
0065     QStringList m_blLockBits;
0066 
0067     // Build
0068 
0069     QStringList m_bMcu;
0070     QStringList m_bFcpu;
0071     QStringList m_bVid;
0072     QStringList m_bPid;
0073     QStringList m_bUsbProduct;
0074     QStringList m_bBoard;
0075     QStringList m_bCore;
0076     QStringList m_bVariant;
0077     QStringList m_bExtraFlags;
0078 
0079     QStringList m_upMaxSizeKb;
0080     QStringList m_upMaxDataSizeKb;
0081     QStringList m_freqHz;
0082 
0083     // Not an Option
0084     QStringList m_NaO;
0085 
0086 };
0087 
0088 /**
0089  * @brief A class to help deal with boards.txt
0090  *
0091  */
0092 class Board
0093 {
0094 public:
0095     static  Board& instance();
0096 
0097     QMap<QString, BoardInfo> m_boards;
0098 
0099     QStringList m_boardList;
0100     QStringList m_boardNameList;
0101     void update();
0102     QString getIdFromName(QString _name);
0103 
0104 private:
0105     Board& operator = (Board& other) = delete;
0106     Board(const Board& other) = delete;
0107     Board();
0108     ~Board();
0109 
0110     void load();
0111     QString Freq2FreqHz(QString freq);
0112 
0113     bool m_arduinoFolderFail;
0114     bool m_listed;
0115     QFile* m_arduinoFolder;
0116 };