2020import QtQuick 2.0
2121import QtQuick.Controls 1.1
2222import QtQuick.Controls.Styles 1.1
23+ import "Functions.js" as Functions
2324
24- Rectangle {
25+ Item {
2526 property string defaultFunction: " GPIO" // function when cape is not loded
2627 property var functions: [" GPIO" , " I2C" , " UART" ] // pinmux functions
2728 property var info: [" gpio1_0" , " gpio1_0" , " i2c1_cs" , " uart0_sck" ] // info to default function and pinmux functions
@@ -36,30 +37,35 @@ Rectangle {
3637 property var gpioDirections: [" unmodified" , " in" , " out" ]
3738 property string gpioValue: " unmodified" // startup gpio value
3839 property var gpioValues: [" unmodifed" , " low" , " high" ]
39- property int number: 0 // number of the pin
40+ property int pinNumber: 0 // number of the pin
41+ property int portNumber: 0
42+ property int pruPinNumber: 0
43+ property int kernelPinNumber: 0
4044 property var colorMap: [[" GPIO" , " red" ], [" I2C" , " blue" ], [" UART" , " green" ]] // current avtive color map
4145 property alias numberVisible: numberText .visible // visibility of the number
4246 property string description: " Test" // descriptive text for the pin
4347 property bool editable: getEditable () // editability of the pin
4448 property var textInput: leftTextInput .visible ? leftTextInput: rightTextInput // currently active text input
4549 property string infoText: getInfoText () // info text for the pin
4650 property int configMode: 0 // active config mode: 0=function, 1=gpio dir, 2=gpio value
47- property double uneditableOpacitiy: (configMode == 0 )? 1.0 : 0.2
51+ property double uneditableOpacitiy: (configMode == 0 )? (displayUneditablePins? 1.0 : 0.1 ): 0.2
52+ property bool rightSide: ((main .pinNumber % 2 ) == 0 )
53+
54+ property bool displayUneditablePins: true
55+
4856
4957 signal previewEntered (string type)
5058 signal previewExited ()
5159
5260 id: main
5361 width: 100
5462 height: 62
55- color: getColor ()
56- opacity: (editable || previewActive || (previewEnabled && previewType == " " ))? 1.0 : uneditableOpacitiy
5763
5864 function getEditable () {
5965 switch (configMode) {
6066 case 0 : return pinmuxActive
61- case 1 : return (type === " gpio" )
62- case 2 : return ((type === " gpio" ) && (gpioDirection === " out" ))
67+ case 1 : return (( type === " gpio" ) || (type === " gpio_pu " ) || (type === " gpio_pd " ) )
68+ case 2 : return ((( type === " gpio" ) || (type === " gpio_pu " ) || (type === " gpio_pd " ) ) && (gpioDirection === " out" ))
6369 default : return false
6470 }
6571 }
@@ -123,13 +129,44 @@ Rectangle {
123129 return false ;
124130 }
125131
132+ ToolTip {
133+ anchors .left : rightSide? parent .right : undefined
134+ anchors .leftMargin : parent .width * 0.8
135+ anchors .right : ! rightSide? parent .left : undefined
136+ anchors .rightMargin : anchors .leftMargin
137+ width: childrenRect .width + main .width
138+ height: childrenRect .height + main .width
139+ color: " white"
140+ border .color : " black"
141+
142+ visible: (comboBox .hovered || mouseArea .containsMouse ) && ! (previewEnabled && (previewType == " " ))
143+ z: 1000
144+
145+ Text {
146+ x: main .width / 2
147+ y: main .width / 2
148+ font .pixelSize : rightInfoText .font .pixelSize
149+ text: " <b>P" + portNumber + " _" + pinNumber + " </b><br>" +
150+ infoText + " (" + (pinmuxActive? type: defaultFunction) + " )" +
151+ ((kernelPinNumber != 0 )? " <br>" + qsTr (" Kernel Pin: " ) + kernelPinNumber: " " ) +
152+ ((pruPinNumber != 0 )? " <br>" + qsTr (" PRU Pin; " ) + pruPinNumber: " " )
153+ }
154+ }
155+
156+ Rectangle {
157+ id: pinRect
158+ anchors .fill : parent
159+ color: getColor ()
160+ opacity: (editable || previewActive || (previewEnabled && previewType == " " ))? 1.0 : uneditableOpacitiy
161+ }
162+
126163 Text {
127164 id: numberText
128165 anchors .fill : parent
129- color: " white"
166+ color: (( pinRect . opacity > 0.5 ) && ( pinRect . color . r + pinRect . color . g + pinRect . color . b ) < 2.0 ) ? " white" : " black "
130167 horizontalAlignment: Text .AlignHCenter
131168 verticalAlignment: Text .AlignVCenter
132- text: main .number
169+ text: main .pinNumber
133170 font .bold : true
134171 font .pixelSize : parent .width * 0.6
135172 }
@@ -226,11 +263,12 @@ Rectangle {
226263 anchors .verticalCenter : parent .verticalCenter
227264 anchors .left : parent .right
228265 anchors .leftMargin : parent .width * 0.8
229- width: parent .width * 6
266+ width: parent .width * 8
230267 horizontalAlignment: TextInput .AlignLeft
231268 font .pixelSize : parent .width * 0.9
232- visible: ! previewActive && (( main .number % 2 ) == 0 )
269+ visible: ! previewActive && main .rightSide
233270 readOnly: ! main .editable
271+ selectByMouse: true
234272
235273 MouseArea {
236274 anchors .fill : parent
@@ -261,20 +299,21 @@ Rectangle {
261299 width: rightTextInput .width
262300 horizontalAlignment: rightTextInput .horizontalAlignment
263301 font: rightTextInput .font
264- visible: previewActive && (( main .number % 2 ) == 0 )
302+ visible: previewActive && main .rightSide
265303 text: main .infoText
266304 }
267305
268306 TextInput {
269307 id: leftTextInput
270308 anchors .verticalCenter : parent .verticalCenter
271309 anchors .right : parent .left
272- anchors .rightMargin : parent . width * 0.8
273- width: parent .width * 6
310+ anchors .rightMargin : rightTextInput . anchors . leftMargin
311+ width: rightTextInput .width
274312 horizontalAlignment: TextInput .AlignRight
275- font .pixelSize : parent . width * 0.9
276- visible: ! previewActive && (( main .number % 2 ) == 1 )
313+ font .pixelSize : rightTextInput . font . pixelSize
314+ visible: ! previewActive && ! main .rightSide
277315 readOnly: ! main .editable
316+ selectByMouse: true
278317
279318 MouseArea {
280319 anchors .fill : parent
@@ -305,15 +344,16 @@ Rectangle {
305344 width: leftTextInput .width
306345 horizontalAlignment: leftTextInput .horizontalAlignment
307346 font: leftTextInput .font
308- visible: previewActive && (( main .number % 2 ) == 1 )
347+ visible: previewActive && ! main .rightSide
309348 text: main .infoText
310349 }
311350
312351 MouseArea {
352+ id: mouseArea
313353 anchors .fill : parent
314354 cursorShape: main .editable ? Qt .PointingHandCursor : Qt .ArrowCursor
315- enabled: previewEnabled && (previewType == " " )
316- hoverEnabled: true
355+ enabled: ( previewEnabled && (previewType == " " )) || ! editable
356+ hoverEnabled: enabled
317357 onHoveredChanged: {
318358 if (containsMouse)
319359 {
0 commit comments