Projekt

Allgemein

Profil

Qt » biwak.diff

Maximilian Seesslen, 19.11.2024 19:36

Unterschiede anzeigen:

CMakeLists.txt
485 485
   )
486 486
endif()
487 487

  
488
target_compile_definitions(
489
   ${PROJECT_NAME}
490
   PUBLIC
491
      -DBIWAK_PLATFORM=${MCU_PLATFORM}
492
)
493

  
488 494
target_include_directories(
489 495
   ${PROJECT_NAME}
490 496
   PRIVATE
include/biwak/biwak.h
80 80

  
81 81
//int getSystemTicker(void);
82 82
int biwakInit();
83
   int biwakDeInit();
83
int biwakDeInit();
84 84
int biwakEventLoop();
85
int biwakExec();
85 86

  
86 87
class CFlash;
87 88
class CTimer;
include/biwak/gpio.hpp
193 193
    public:
194 194
        CGpio( EGpioPeripheral eGpioPeripheral, EGpioPin eGpioPin
195 195
              , const SGpioMode &gpioMode=gpioModeInput, int altFunc=0);
196
        CGpio( EGpioPeripheral eGpioPeripheral, EGpioPin eGpioPin
197
              , const SGpioMode &gpioMode, int altFunc, const char* label);
196 198
        ~CGpio();
197 199
        static int init( EGpioPeripheral eGpioPeripheral, EGpioPin eGpioPin
198 200
                 , const SGpioMode &gpioMode=gpioModeInput, int altFunc=0 );
include/biwak/led.hpp
65 65
      };
66 66
        
67 67
      CLed(EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin);
68
      CLed(EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin, const char* label);
68 69
      ~CLed();
69 70
      
70 71
      void eventLoop( );
include/biwak/linux/boardgui.h
7 7
#include <QLabel>
8 8
#include <QCheckBox>
9 9
#include <QPushButton>
10
#include <QTimer>
11
#include <QEvent>
10 12

  
11 13
namespace Ui {
12 14
   class CBoardGui;
......
28 30
      // QPushButton **inPushArray;
29 31
      //SButtonGroup **buttonArray;
30 32
      QSpacerItem *verticalSpacerIn;
33
      QTimer m_eventTimer;
31 34

  
32 35
      QPixmap *pixmapGraphicDisplay;
33 36

  
......
59 62
      //void slotInStateClicked(bool checked);
60 63
      void slotInStateReleased();
61 64
      void slotInStatePressed();
65
      void slotEventTimer();
62 66

  
63 67
   signals:
64 68
      void signalInputChanged( int extiIndex, int state );
65 69

  
66 70
   private:
67 71
      Ui::CBoardGui *ui;
72
   public:
73

  
74
      virtual bool event(QEvent *event) override
75
      {
76
         // The quit event has to be catched to actually exit the main process.
77
         // Signal aboutToQuit() is not emitted when using
78
         // processEvents() in a loop instead of exit().
79
         if( event->type() == QEvent::WindowDeactivate )
80
         {
81
            slotExited();
82
         }
83
         return( QMainWindow::event(event) );
84
      }
85

  
68 86
};
69 87

  
70 88
//extern CBoardGui *pBoardGui;
include/biwak/output.hpp
35 35

  
36 36
   public:
37 37
      COutput(EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin );
38
      COutput(EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin, const char* label );
38 39
      ~COutput();
39 40
      
40 41
      void switchOn();
src/led.cpp
31 31
}
32 32

  
33 33

  
34
/// \brief  Le contructeur
35
///
36
CLed::CLed(EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin, const char* label)
37
   :COutput(_eGpioPeripheral, _eGpioPin, label) //  gpioModeLed
38
{
39
   m_blinkMode=nullptr;
40
}
41

  
42

  
34 43
CLed::~CLed()
35 44
{
36 45

  
37 46
}
38 47

  
48

  
39 49
void CLed::setBlinkMode( SBlinkMode blinkMode )
40 50
{
41 51
   if( m_blinkMode == blinkMode )
......
65 75
   setValue( m_blinkState );
66 76
}
67 77

  
78

  
68 79
#if 0
69 80
/// \brief  Let the led blink
70 81
///
......
76 87
}
77 88
#endif
78 89

  
90

  
79 91
/// \brief  Handles the predefined blink modes
80 92
///
81 93
///         Has to be called cyclic
src/linux/biwak.cpp
59 59

  
60 60
//qtplatform *pQtplatform=NULL;
61 61
//QApplication a(param_argc, param_argv);
62
QApplication* pApplication=NULL;
63
#define a (*pApplication)
62
QApplication* pApplication = nullptr;
63
extern CBoardGui* pBoardGui;
64
//#define a (*pApplication)
64 65
/*
65 66
void MainWindow::eventLoop()
66 67
{
......
92 93
};
93 94
*/
94 95

  
95
int biwakInit()
96
 static void cleanup_ptr()
97
 {
98
    printf("Cleaning up\n");
99
 }
100

  
101
 int biwakInit()
96 102
{
97
   /*
103
   printf( "\n" );
104
   printf( "0x%p\n", QApplication::instance());
98 105
   pApplication=new QApplication(param_argc, param_argv);
106

  
99 107
   pBoardGui=new CBoardGui;
100 108
   pBoardGui->show();
109
   pApplication->setQuitOnLastWindowClosed(true);
101 110

  
102
   pArbiter=new CArbiter(pBoardGui);
111
   printf( "0x%p\n", QApplication::instance());
112
   printf( "0x%p\n", pApplication);
113
   qAddPostRoutine(cleanup_ptr);
114
   //if( qApp() != pApplication )
115
   //{
116
   //   exit(22);
117
  // }
103 118

  
104
   QObject::connect(&a, SIGNAL(aboutToQuit()), pBoardGui, SLOT(slotExited()));
119
   /*
120
   pArbiter=new CArbiter(pBoardGui);
105 121
   */
122
   //QObject::connect(&pApplication, SIGNAL(aboutToQuit()), pBoardGui, SLOT(slotExited()));
123

  
106 124
   return(0);
107 125
}
108 126

  
109 127

  
110 128
int biwakEventLoop()
111 129
{
112
   /*
113
   if(a.hasPendingEvents())
114
      a.processEvents();
130
   QCoreApplication::processEvents();
115 131

  
116
   if(qpf.doExit)
132
   // closingDown() is not working. Application has to indicate quit via
133
   // catching event.
134
   if( pApplication->closingDown() )
117 135
   {
118 136
      //delete pApplication;  // must not delete after quit
137
      printf("Closing down\n");
119 138
      pApplication = NULL;
120
      return(1);
139
      exit(1);
121 140
   }
122
   */
123 141

  
124 142
   logEventLoop();
125 143
   #if IS_ENABLED( BIWAK_LOG_HEARTBEAT )
126 144
      logHeartBeat( ELogCategory::Loop );
127 145
   #endif
128 146

  
147
   //pApplication->exec();
148
   //exit(23);
149

  
129 150
   return(0);
130 151
}
131 152

  
153
int biwakExec()
154
{
155
   return( pApplication->exec() );
156
}
132 157

  
158
#if 0
133 159
void checkBootLoader()
134 160
{
135 161
   return;
136 162
}
137

  
163
#endif
138 164

  
139 165
void setStdio(CIOStream *io)
140 166
{
141 167
   // Does not make much sense in linux? The printf should end up in a Qt widget
142 168
};
143 169

  
144

  
145 170
#endif
146 171

  
147 172

  
src/linux/boardgui.cpp
4 4
#include <QSpinBox>
5 5
#include <QPushButton>
6 6
#include <QLabel>
7
#include <biwak/biwak.h>
7 8

  
8 9
#include <lepto/log.h>
9 10

  
......
85 86
   pixmapGraphicDisplay=new QPixmap( 128, 128);
86 87
   pixmapGraphicDisplay->fill( Qt::black );
87 88
   ui->graphicDisplay->setPixmap( *pixmapGraphicDisplay );
89

  
90
   connect(QApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(slotExited()));
91
   connect(&m_eventTimer, SIGNAL(timeout()), this, SLOT(slotEventTimer()));
92
   connect(this, SIGNAL( destroyed(QObject *obj)), this, SLOT(slotExited()));
93

  
94
   m_eventTimer.start(10);
88 95
}
89 96

  
90 97

  
......
146 153

  
147 154
void CBoardGui::slotExited()
148 155
{
149
   lInfo ( "doExit!" );
156
   printf ( "CBoardGui::doExit!\n" );
150 157
   doExit=true;
151 158

  
152 159
   exit(0);
......
244 251
   slotInStateChanged( false);
245 252
}
246 253

  
254
void CBoardGui::slotEventTimer()
255
{
256
   // biwakEventLoop();
257
   // printf(".");
258
   // fflush(stdout);
259
}
247 260

  
248 261
QLabel *CBoardGui::getGraphicDispay()
249 262
{
src/linux/gpio.cpp
42 42

  
43 43
public:
44 44
   CGpioDimpl( EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin
45
               , const SGpioMode &gpioMode, int altFunc=0 )
45
               , const SGpioMode &gpioMode, int altFunc=0, const char* label="?" )
46 46
   {
47 47
      Ui::CBoardGui *ui=CBoardGui::getInstanceUi();
48 48

  
......
87 87
               break;
88 88
         }
89 89

  
90
         m_checkBox->setText( QString("%1%2").arg(type).arg(ioCounter) );
90
         m_checkBox->setText( QString("%1%2 %3").arg(type).arg(ioCounter).arg(label) );
91 91
      }
92 92
      ioCounter++;
93 93
   }
......
102 102

  
103 103
CGpio::CGpio(EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin
104 104
          , const SGpioMode &gpioMode, int altFunc)
105
   :CGpio(_eGpioPeripheral, _eGpioPin, gpioMode, altFunc, "?")
106
{
107

  
108
}
109

  
110
CGpio::CGpio(EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin
111
          , const SGpioMode &gpioMode, int altFunc, const char* label)
105 112
{
106 113
#if 1
107 114
   m_eGpioPeripheral=_eGpioPeripheral;
......
109 116

  
110 117
   m_value=false;
111 118

  
112
   m_pDimpl=new CGpioDimpl(_eGpioPeripheral, _eGpioPin, gpioMode);
119
   m_pDimpl=new CGpioDimpl(_eGpioPeripheral, _eGpioPin, gpioMode, altFunc, label);
113 120
#endif
114 121
   return;
115 122
};
src/output.cpp
35 35
{
36 36
}
37 37

  
38
COutput::COutput( EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin, const char* label )
39
   :CGpio(_eGpioPeripheral, _eGpioPin, gpioModeOutput, 0, label)
40
{
41
}
42

  
38 43
COutput::~COutput()
39 44
{
40 45

  
(3-3/6)