almost ready to merge into master
[avrdudequi:avrdudequi.git] / mcu.h
1 /***************************************************************************
2  *   Copyright (C) 2011 by Maurilio                                        *
3  *   mau_ri_tec@yahoo.it                                                   *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21
22 #ifndef MCU_H
23 #define MCU_H
24
25 #include <QComboBox>
26 #include <QObject>
27 #include <QtUiTools>
28 #include <QCheckBox>
29 #include <QGroupBox>
30 #include "fusebyte.h"
31 #include "lockbit.h"
32 #include "mtfusearray.h"
33
34 class Mcu : public QObject
35 {
36     Q_OBJECT
37
38 public:
39     static Mcu *instance() {
40         if (!m_instance)
41             m_instance = new Mcu;
42         return m_instance;
43     }
44
45     ~Mcu();
46     void fillMcu(QComboBox *cBoxMcu);
47     QString getMcu();
48     QList<QMap<QString, QString> > getAllFuse();
49     QString readAllFuse();
50     QString getBackEnd() { return backEnd; }
51     void setFuses(QMap<QString, QString> &);
52     void loadEmptyWidget();
53     void setLockBit(QMap<QString, QString> &);
54     bool asEEprom();
55     void loadEEpromFile(const QString &fileName);
56     bool saveEEpromFile(const QString &fileName);
57
58 private:
59     static Mcu *m_instance;
60     Mcu();
61
62     void setLFWidget();
63     void setHFWidget();
64     void setEFWidget();
65
66
67     QComboBox *_cBoxMcu;
68     QUiLoader *uiLoader;
69     QWidget *mcuWidget;
70     bool thereIsMcuWidget;
71     QComboBox *cBoxLowFuse;
72     QComboBox *cBoxHighFuse;
73     QComboBox *cBoxExtendedFuse;
74     QTabWidget *tabWidget;
75
76     QGroupBox  *gBoxLFuse;
77     QGroupBox  *gBoxHFuse;
78     QGroupBox  *gBoxEFuse;
79     QObjectList objList;
80
81     QGroupBox *gBoxLock;
82
83     MtFuseArray lowFuses;
84     MtFuseArray highFuses;
85     MtFuseArray extendedFuses;
86
87     MtFuseArray lockByte;
88
89     uint nBitLowFuse;
90     uint nBitHighFuse;
91     uint nBitExtendedFuse;
92     uint cBoxLFuseMask;
93     uint cBoxHFuseMask;
94     uint cBoxEFuseMask;
95
96     QString backEnd;
97     QString backend_arg_low;
98     QString backend_arg_high;
99     QString backend_arg_extended;
100
101     QString backend_arg_lock;
102
103     QComboBox *cBoxLockBit;
104     uint cBoxLockBitMask;
105
106     LockBit *lockBit;
107     FuseByte *fuseByte;
108
109
110     //EEpromEditor *eepromEditor;
111     uint eepromSize;
112
113
114     void resetPointer();
115
116
117 signals:
118     void currentWidgetChanged(QWidget *mcuWidget);
119
120 public slots:
121     void change(int);
122     void cBoxLowFuseIndexChanged(int);
123     void cBoxHighFuseIndexChanged(int);
124     void cBoxExtendedFuseIndexChanged(int);
125
126 private slots:
127     void gBoxLFuseContentsChanged(bool);
128     void gBoxHFuseContentsChanged(bool);
129     void gBoxEFuseContentsChanged(bool);
130 };
131
132 #endif // MCU_H