-
Notifications
You must be signed in to change notification settings - Fork 0
/
myobject1.cpp
2439 lines (2295 loc) · 76.2 KB
/
myobject1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "myobject1.h"
#include <QBluetoothAddress>
#include <QtQuick/QQuickView>
#include <QQmlApplicationEngine>
//#include <QtQuick/QQuickItem>
#include <QDir>
MyObject1::MyObject1(QObject *parent) : QObject(parent)
{
myApp = new MyAppGui();
//Initialize combo boxes
m_comboListBacklight.clear();
m_comboListBacklight.insert(0, "OFF");
m_comboListBacklight.insert(1, "Red");
m_comboListBacklight.insert(2, "Blue");
m_comboListBacklight.insert(3, "Green");
m_comboListBacklight.insert(4, "Red/Blue"); //purple
m_comboListBacklight.insert(5, "Red/Green"); //Orange?
m_comboListBacklight.insert(6, "Blue/Green"); //Yellow?
m_comboListBacklight.insert(7, "White");
m_comboListTrickMode1.clear();
m_comboListTrickMode1.insert(0, "OFF");
m_comboListTrickMode1.insert(1, "Jump to Song");
//m_comboListTrickMode1.insert(2, "Momentary new Song");
//m_comboListTrickMode1.insert(3, "Latch Add Loop");
//m_comboListTrickMode1.insert(4, "Momentary Add Loop");
m_comboListTrickMode1.insert(2, "Latch Footswitch");
m_comboListTrickMode1.insert(3, "Momentary Footswitch");
//m_comboListTrickMode1.insert(7, "Send MIDI Msg");
m_comboListTrickMode2.clear();
m_comboListTrickMode2.insert(0, "OFF");
m_comboListTrickMode2.insert(1, "Jump to Song");
//m_comboListTrickMode2.insert(2, "Momentary new Song");
//m_comboListTrickMode2.insert(3, "Latch Add Loop");
//m_comboListTrickMode2.insert(4, "Momentary Add Loop");
m_comboListTrickMode2.insert(2, "Latch Footswitch");
m_comboListTrickMode2.insert(3, "Momentary Footswitch");
//m_comboListTrickMode2.insert(7, "Send MIDI Msg");
m_strStatus = "Status: Waiting for connect...";
// ////////////////////////////////////////////////////////
//temp - load dummy config for testing
//loadDummyConfig();
}
void MyObject1::foo(QString MAC, QString name)
{
QBluetoothAddress macAddr = QBluetoothAddress(MAC);
QBluetoothDeviceInfo remoteDevice(macAddr, name, 0);
// new QLowEnergyController(this);
bleCentral = QLowEnergyController::createCentral(remoteDevice, this);//->connectToDevice();
bleCentral->connectToDevice();
connect(bleCentral, SIGNAL(connected()), this, SLOT(bleConnected()));
}
void MyObject1::bleConnected()
{
qDebug() << "bleConnected()";
m_strStatus = "Status: Device connected...";
bleCentral->discoverServices();
connect(bleCentral, SIGNAL(serviceDiscovered(QBluetoothUuid)), this, SLOT(addService(QBluetoothUuid)));
connect(bleCentral, SIGNAL(discoveryFinished()), this, SLOT(discoveryDone()));
}
void MyObject1::addService(QBluetoothUuid uuid)
{
qDebug() << uuid.toString();
//QList<QBluetoothUuid> QLowEnergyController::services() const
//QList<QBluetoothUuid> bleServiceList = bleCentral->services();
//SERVICE (0): 713d0000-503e-4c75-ba94-3148f18d941e
//Characteristics:
//READ (2): 713d0002-503e-4c75-ba94-3148f18d941e
//WRITE (3): 713d0003-503e-4c75-ba94-3148f18d941e
QString uuid2 = "{713d0000-503e-4c75-ba94-3148f18d941e}";
if(uuid.toString() != uuid2) return;
service = bleCentral->createServiceObject(uuid, this);
if(!service)
{
qDebug() << "Couldn't create the service";
return;
}
qDebug() << "Service Created: " << uuid2;
m_strStatus = "Status: Getting Device Info...";
emit ConfigChanged();
}
void MyObject1::discoveryDone()
{
qDebug() << "discoveryDone()";
//get characteristics
service->discoverDetails();
connect(service, SIGNAL(stateChanged(QLowEnergyService::ServiceState)), this, SLOT(bleServiceChanged(QLowEnergyService::ServiceState)) );
}
void MyObject1::bleServiceChanged(QLowEnergyService::ServiceState a)
{
qDebug() << "bleServiceChanged()";
//get the List of recently discovered characteristics
bleIncludedChars = service->characteristics();
//From: https://stackoverflow.com/questions/42647587/qt-ble-for-android-cannot-read-value-of-characteristic-for-custom-service
foreach(QLowEnergyCharacteristic c, service->characteristics()){
QLowEnergyDescriptor d = c.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
if(!c.isValid()){
continue;
}
if(c.properties() & QLowEnergyCharacteristic::Notify)
{ // enable notification
qDebug() << "enable notification";
service->writeDescriptor(d, QByteArray::fromHex("0100"));
}
if(c.properties() & QLowEnergyCharacteristic::Indicate)
{ // enable indication
qDebug() << "enable indication";
service->writeDescriptor(d, QByteArray::fromHex("0200"));
}
}
//look for the correct values
for(int i=0;i<bleIncludedChars.length();i++)
{
qDebug() << bleIncludedChars.value(i).uuid().toString();
if(bleIncludedChars.value(i).uuid().toString() == "{713d0002-503e-4c75-ba94-3148f18d941e}")
{
qDebug() << "Read @ (bleIncludedChars.value(" << i << ")";
bleReadReady = true;
}
if(bleIncludedChars.value(i).uuid().toString() == "{713d0003-503e-4c75-ba94-3148f18d941e}")
{
qDebug() << "Write @ (bleIncludedChars.value(" << i << ")";
bleWriteReady = true;
}
}
if( (bleWriteReady == false) || (bleWriteReady == false))
{
qDebug() << "did not find both read and write chars";
return;
}
/*
if(bleWriteReady == true)
{
qDebug() << "Found Write Characteristic";
//Temp; get status
QByteArray data = "$b0000F\r";
service->writeCharacteristic(bleIncludedChars.value(1), data, QLowEnergyService::WriteWithoutResponse);
//can't create one, have to use the one the service gave us
//QLowEnergyCharacteristic writeChar;
//QString uuid = "{713d0003-503e-4c75-ba94-3148f18d941e}";
//writeChar.uuid() = QBluetoothUuid(uuid);
//service->writeCharacteristic(writeChar, data, QLowEnergyService::WriteWithoutResponse);
//no response expected!!
//connect(service, SIGNAL(characteristicWritten(QLowEnergyCharacteristic, QByteArray)), this, SLOT(dataWritten(QLowEnergyCharacteristic, QByteArray)));
}
*/
if(bleReadReady == true)
{
qDebug() << "Found Read Characteristic - starting to read";
//to do: start timer here?
//connect(service, SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)), this, SLOT(dataReadCB(QLowEnergyCharacteristic, QByteArray)));
//https://stackoverflow.com/questions/42651989/qt-ble-for-android-characteristic-update-does-not-trigger-characteristicchanged
connect(service, SIGNAL(characteristicChanged(QLowEnergyCharacteristic, QByteArray)), this, SLOT(dataReadCB(QLowEnergyCharacteristic, QByteArray)));
service->readCharacteristic(bleIncludedChars.value(0));
}
connect(this, SIGNAL(recdBLEdata(QByteArray)), myApp, SLOT(parseInData(QByteArray)) );
connect(myApp, SIGNAL(writeBLEdata(QByteArray)), this, SLOT(writeData(QByteArray)) );
connect(myApp, SIGNAL(SongComplete()), this, SLOT(updateSongDisplay()) );
connect(myApp, SIGNAL(ConfigComplete()), this, SLOT(updateConfigDisplay()) );
/*
//Start timer to read serial data from motor
m_timerBLE = new QTimer(this);
connect(m_timerBLE, SIGNAL(timeout()), this, SLOT(readBLE()));
m_timerBLE->start(2000); //mSec
*/
//m_strStatus = "Status: Connected!! Getting pedal config...";
m_strStatus = "Status: BLE active......";
//myApp->sendStatus();
myApp->sendRequestForConfigBlock();
}
void MyObject1::readBLE(void)
{
qDebug() << "readBLE(): readCharacteristic <- " << bleIncludedChars.value(0).uuid().toString();
service->readCharacteristic(bleIncludedChars.value(0));
}
void MyObject1::dataReadCB(QLowEnergyCharacteristic c, QByteArray data)
{
qDebug() << "dataRead()";
qDebug() << "data in: " << data;
m_RecvData = data;
//parseInData(data);
emit recdBLEdata(m_RecvData);
//emit SongChanged(); //temp?? Where should I put this round about way of updating data Qt? This is the ONLY place it works, but NOT CORRECT!!
/*
if(m_strStatus != "Status: BLE active......") m_strStatus = "Status: BLE active......";
else m_strStatus != "Status: BLE active... ";
emit ConfigChanged();
*/
//temp -= READ AGAIN
//to do: this should be called on a timer?
service->readCharacteristic(bleIncludedChars.value(0));
}
void MyObject1::writeData(QByteArray data)
{
//called externally to write data to the device.. THIS IS THE ONE!
qDebug() << "writeData()";
qDebug() << "data out: " << data;
if(bleWriteReady == true)
service->writeCharacteristic(bleIncludedChars.value(1), data, QLowEnergyService::WriteWithoutResponse);
else
qDebug() << "No Write Characteristic was discovered";
}
// //////////////////////////////////////////////////////////////////////////////////////////////////
// SONG SCREEN OBJECTS
void MyObject1::updateSongDisplay(void)
{
//aint Qt awesome!!
emit SongChanged();
updateComboBoxes();
emit comboListChanged();
/* NOTHING WORKED
//change background color
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///scanner.qml")));
QMetaObject::invokeMethod(engine.rootObjects().first(), "changeColor");
*/
/*
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///scanner.qml")));
QQuickItem *item = engine.rootObjects().at(0)->findChild<QQuickItem*>("rectSongWindow");
if (item){
if(myApp->ramSong.lcdBacklight == BACKLIGHT_RED) item->setProperty("color", QColor(Qt::yellow));
else if(myApp->ramSong.lcdBacklight == BACKLIGHT_BLUE) item->setProperty("color", QColor(Qt::yellow));
else if(myApp->ramSong.lcdBacklight == BACKLIGHT_GREEN) item->setProperty("color", QColor(Qt::yellow));
else if(myApp->ramSong.lcdBacklight == BACKLIGHT_REDBLUE) item->setProperty("color", QColor(Qt::yellow));
else if(myApp->ramSong.lcdBacklight == BACKLIGHT_REDGREEN) item->setProperty("color", QColor(Qt::yellow));
else if(myApp->ramSong.lcdBacklight == BACKLIGHT_BLUEGREEN) item->setProperty("color", QColor(Qt::yellow));
else if(myApp->ramSong.lcdBacklight == BACKLIGHT_WHITE) item->setProperty("color", QColor(Qt::yellow));
}
*/
}
void MyObject1::updateSongDevice(void)
{
myApp->UpdateSongToDevice();
updateComboBoxes();
emit comboListChanged();
}
void MyObject1::selectNextSong(void)
{
myApp->gotoNextSong();
updateComboBoxes();
emit comboListChanged();
emit ConfigChanged();
}
void MyObject1::selectPreviousSong(void)
{
myApp->gotoPreviousSong();
updateComboBoxes();
emit comboListChanged();
emit ConfigChanged();
}
void MyObject1::saveSong(void)
{
/*
typedef struct
{
unsigned char isFilled; // this song has been programmed, or is empty=0xff (default flash erase value)
unsigned char name[32]; //name the song... slow select?
unsigned char partname[32]; // part (solo, bridge chorus, verse, etc.) of the song.... rapid select
unsigned char midiMessage1[SIZE_OF_MIDI_MSG]; //MIDI messages, Chan & Program .. for "program change" messages to MIDI pedals, etc.
//unsigned char midiMessage2[SIZE_OF_MIDI_MSG]; //MIDI messages, Chan & Program .. for "program change" messages to MIDI pedals, etc.
//unsigned char midiMessage3[SIZE_OF_MIDI_MSG]; //MIDI messages, Chan & Program .. for "program change" messages to MIDI pedals, etc.
//unsigned char midiMessage4[SIZE_OF_MIDI_MSG]; //MIDI messages, Chan & Program .. for "program change" messages to MIDI pedals, etc.
unsigned char midiMsgMode; //describe when to send msg, at song load? on trick button press? probably only those two?
unsigned char matrix[12]; //twelve bytes to setup up the Matrix
unsigned char footswitch; //state of 6 footswitches
unsigned char trickMode[3]; //Solo/Boost/Trick button - what is doing?
unsigned char trickData[3]; //Solo/Boost/Trick button - any data that needs to be stored (song, loop, fsw, etc.)
unsigned char lcdBacklight; //4-5 bits of RGB backlight control (different color for each song) - solo mode??pulse color? throbber?
unsigned char Dummy[2]; //add bytes to ensure Size is divisable by 4. 99/4=24.75 so add 1
} SONG;
*/
//QString filename = "data.txt";//(QString)myApp->ramSong.name;// + myApp->ramSong.partname + ".txt";
QString str1= (const char*)myApp->ramSong.name;
QString str2= (const char*)myApp->ramSong.partname;
QString filename= str1 + "_" + str2 + ".dat";
QFile file(filename);
if (file.open(QIODevice::ReadWrite))
{
QDataStream stream(&file);
unsigned int i;
stream << myApp->ramSong.isFilled;
for(i=0; i<sizeof(myApp->ramSong.name);i++)
{
stream << myApp->ramSong.name[i];
}
for(i=0; i<sizeof(myApp->ramSong.partname);i++)
{
stream << myApp->ramSong.partname[i];
}
for(i=0; i<sizeof(myApp->ramSong.midiMessage1);i++)
{
stream << myApp->ramSong.midiMessage1[i];
}
stream << myApp->ramSong.midiMsgMode;
for(i=0; i<sizeof(myApp->ramSong.matrix);i++)
{
stream << myApp->ramSong.matrix[i];
}
stream << myApp->ramSong.footswitch;
for(i=0; i<sizeof(myApp->ramSong.trickMode);i++)
{
stream << myApp->ramSong.trickMode[i];
}
for(i=0; i<sizeof(myApp->ramSong.trickData);i++)
{
stream << myApp->ramSong.trickData[i];
}
stream << myApp->ramSong.lcdBacklight;
for(i=0; i<sizeof(myApp->ramSong.Dummy);i++)
{
stream << myApp->ramSong.Dummy[i];
}
}
}
void MyObject1::restoreSong(QString filename)
{
QFile file;//(filename);
QString path = filename.right( filename.length() - 7 ); //remove "file://"
int last = path.lastIndexOf('/', -1, Qt::CaseInsensitive);
QString dir = path.left( path.length() - (path.length() - last) );
QDir::setCurrent(dir);
QString fileName = path.right(path.length() - last - 1);
file.setFileName(fileName);
file.setTextModeEnabled(true);
if (file.open(QIODevice::ReadWrite))
{
QDataStream stream(&file);
unsigned int i;
stream >> myApp->ramSong.isFilled;
for(i=0; i<sizeof(myApp->ramSong.name);i++)
{
stream >> myApp->ramSong.name[i];
}
for(i=0; i<sizeof(myApp->ramSong.partname);i++)
{
stream >> myApp->ramSong.partname[i];
}
for(i=0; i<sizeof(myApp->ramSong.midiMessage1);i++)
{
stream >> myApp->ramSong.midiMessage1[i];
}
stream >> myApp->ramSong.midiMsgMode;
for(i=0; i<sizeof(myApp->ramSong.matrix);i++)
{
stream >> myApp->ramSong.matrix[i];
}
stream >> myApp->ramSong.footswitch;
for(i=0; i<sizeof(myApp->ramSong.trickMode);i++)
{
stream >> myApp->ramSong.trickMode[i];
}
for(i=0; i<sizeof(myApp->ramSong.trickData);i++)
{
stream >> myApp->ramSong.trickData[i];
}
stream >> myApp->ramSong.lcdBacklight;
for(i=0; i<sizeof(myApp->ramSong.Dummy);i++)
{
stream >> myApp->ramSong.Dummy[i];
}
}
updateSongDisplay();
}
QString MyObject1::getSongName(void) const
{
QString str = "Loading..";
if(myApp)
{
if(myApp->isInitialized == 1)
{
str = QString(QByteArray((char*)myApp->ramSong.name));
}
}
return str;
}
void MyObject1::onSongNameChanged(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
QByteArray array = str.toLocal8Bit();
char* buffer = array.data();
buffer[str.length()] = 0; //ensure it ends with NULL
strcpy((char*)myApp->ramSong.name, buffer );
}
}
}
QString MyObject1::getPartName(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
str = QString(QByteArray((char*)myApp->ramSong.partname));
}
}
return str;
}
void MyObject1::onSongPartNameChanged(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
QByteArray array = str.toLocal8Bit();
char* buffer = array.data();
buffer[str.length()] = 0; //ensure it ends with NULL
strcpy((char*)myApp->ramSong.partname, buffer );
}
}
}
QString MyObject1::getMidiMsg1(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
QString temp = QString(QByteArray((char*)myApp->ramSong.midiMessage1));
str = temp.mid(0, SIZE_OF_MIDI_MSG);
}
}
return str;
}
void MyObject1::onMidiMsg1Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
QByteArray array = str.toLocal8Bit();
char* buffer = array.data();
buffer[SIZE_OF_MIDI_MSG] = 0; //force to size of MIDI msg
strcpy((char*)myApp->ramSong.midiMessage1, buffer );
}
}
}
/*
QString MyObject1::getMidiMsg2(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
QString temp = QString(QByteArray((char*)myApp->ramSong.midiMessage2));
str = temp.mid(0, 2);
}
}
return str;
}
void MyObject1::onMidiMsg2Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
QByteArray array = str.toLocal8Bit();
char* buffer = array.data();
buffer[SIZE_OF_MIDI_MSG] = 0; //force to size of MIDI msg
strcpy((char*)myApp->ramSong.midiMessage2, buffer );
}
}
}
QString MyObject1::getMidiMsg3(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
QString temp = QString(QByteArray((char*)myApp->ramSong.midiMessage3));
str = temp.mid(0, 2);
}
}
return str;
}
void MyObject1::onMidiMsg3Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
QByteArray array = str.toLocal8Bit();
char* buffer = array.data();
buffer[SIZE_OF_MIDI_MSG] = 0; //force to size of MIDI msg
strcpy((char*)myApp->ramSong.midiMessage3, buffer );
}
}
}
QString MyObject1::getMidiMsg4(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
QString temp = QString(QByteArray((char*)myApp->ramSong.midiMessage4));
str = temp.mid(0, 2);
}
}
return str;
}
void MyObject1::onMidiMsg4Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
QByteArray array = str.toLocal8Bit();
char* buffer = array.data();
buffer[SIZE_OF_MIDI_MSG] = 0; //force to size of MIDI msg
strcpy((char*)myApp->ramSong.midiMessage4, buffer );
}
}
}
*/
/*
QString MyObject1::getMidiMode(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.midiMsgMode);
str = QString(c);
}
}
return str;
}
void MyObject1::onMidiModeChanged(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
int val = str.toInt();
myApp->ramSong.midiMsgMode = val;
}
}
}
*/
QString MyObject1::getFswSongConfig(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.footswitch);
str = QString(c);
}
}
return str;
}
int MyObject1::isFswSongConfig1(void) const
{
int n = 0;
if(myApp)
{
if(myApp->isInitialized == 1)
{
if ( (myApp->ramSong.footswitch & 0x01) != 0)
{
n = 2; //used as "state" to checkbox.. tells GUI to check that checkbox
}
}
}
return n;
}
int MyObject1::isFswSongConfig2(void) const
{
int n = 0;
if(myApp)
{
if(myApp->isInitialized == 1)
{
if ( (myApp->ramSong.footswitch & 0x02) != 0)
{
n = 2; //used as "state" to checkbox.. tells GUI to check that checkbox
}
}
}
return n;
}
int MyObject1::isFswSongConfig3(void) const
{
int n = 0;
if(myApp)
{
if(myApp->isInitialized == 1)
{
if ( (myApp->ramSong.footswitch & 0x04) != 0)
{
n = 2; //used as "state" to checkbox.. tells GUI to check that checkbox
}
}
}
return n;
}
int MyObject1::isFswSongConfig4(void) const
{
int n = 0;
if(myApp)
{
if(myApp->isInitialized == 1)
{
if ( (myApp->ramSong.footswitch & 0x08) != 0)
{
n = 2; //used as "state" to checkbox.. tells GUI to check that checkbox
}
}
}
return n;
}
int MyObject1::isFswSongConfig5(void) const
{
int n = 0;
if(myApp)
{
if(myApp->isInitialized == 1)
{
if ( (myApp->ramSong.footswitch & 0x10) != 0)
{
n = 2; //used as "state" to checkbox.. tells GUI to check that checkbox
}
}
}
return n;
}
int MyObject1::isFswSongConfig6(void) const
{
int n = 0;
if(myApp)
{
if(myApp->isInitialized == 1)
{
if ( (myApp->ramSong.footswitch & 0x20) != 0)
{
n = 2; //used as "state" to checkbox.. tells GUI to check that checkbox
}
}
}
return n;
}
void MyObject1::onSongFswChanged(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
int val = str.toInt();
myApp->ramSong.footswitch = val;
}
}
}
/*
QString MyObject1::getTrickMode(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.trickMode[0]);
str = QString(c);
}
}
return str;
}
*/
void MyObject1::onTrickMode1Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
//To DO: compare text? send the combo index instead of text?
int val = str.toInt();
myApp->ramSong.trickMode[0] = val;
}
}
}
void MyObject1::onTrickMode2Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
int val = str.toInt();
myApp->ramSong.trickMode[1] = val;
}
}
}
QString MyObject1::getTrickData1(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.trickData[0]);
str = QString(c);
}
}
return str;
}
void MyObject1::onTrickData1Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
int val = str.toInt();
myApp->ramSong.trickData[0] = val;
}
}
}
QString MyObject1::getTrickData2(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.trickData[1]);
str = QString(c);
}
}
return str;
}
void MyObject1::onTrickData2Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
int val = str.toInt();
myApp->ramSong.trickData[1] = val;
}
}
}
/*
QString MyObject1::getSongBacklight(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.lcdBacklight);
str = QString(c);
}
}
return str;
}
*/
void MyObject1::onSongBacklightChanged(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
//int val = str.toInt();
/*
#define BACKLIGHT_RED 48
#define BACKLIGHT_BLUE 03
#define BACKLIGHT_GREEN 12
#define BACKLIGHT_REDBLUE 51
#define BACKLIGHT_REDGREEN 60
#define BACKLIGHT_BLUEGREEN 15
#define BACKLIGHT_WHITE 0x3f
m_comboListBacklight.clear();
m_comboListBacklight.insert(0, "OFF");
m_comboListBacklight.insert(1, "Red");
m_comboListBacklight.insert(2, "Blue");
m_comboListBacklight.insert(3, "Green");
m_comboListBacklight.insert(4, "Red/Blue"); //purple
m_comboListBacklight.insert(5, "Red/Green"); //Orange?
m_comboListBacklight.insert(6, "Blue/Green"); //Yellow?
m_comboListBacklight.insert(7, "White");
*/
int val = BACKLIGHT_RED;
if(str == "Red") val = BACKLIGHT_RED;
else if(str == "Blue") val = BACKLIGHT_BLUE;
else if(str == "Green") val = BACKLIGHT_GREEN;
else if(str == "Red/Blue") val = BACKLIGHT_REDBLUE;
else if(str == "Red/Green") val = BACKLIGHT_REDGREEN;
else if(str == "Blue/Green") val = BACKLIGHT_BLUEGREEN;
else if(str == "White") val = BACKLIGHT_WHITE;
myApp->ramSong.lcdBacklight = val;
}
}
}
QString MyObject1::getMatrix0(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.matrix[0]);
str = QString(c);
}
}
return str;
}
void MyObject1::onMatrix0Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
int val = str.toInt();
if(val == 0) myApp->ramSong.matrix[0] = 0x00;
else if(val == 1) myApp->ramSong.matrix[0] = 0x01;
else if(val == 2) myApp->ramSong.matrix[0] = 0x02;
else if(val == 3) myApp->ramSong.matrix[0] = 0x04;
else if(val == 4) myApp->ramSong.matrix[0] = 0x08;
else if(val == 5) myApp->ramSong.matrix[0] = 0x10;
else if(val == 6) myApp->ramSong.matrix[0] = 0x20;
else if(val == 7) myApp->ramSong.matrix[0] = 0x40;
else if(val == 8) myApp->ramSong.matrix[0] = 0x80;
}
}
}
QString MyObject1::getMatrix1(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.matrix[1]);
str = QString(c);
}
}
return str;
}
void MyObject1::onMatrix1Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
int val = str.toInt();
if(val == 0) myApp->ramSong.matrix[1] = 0x00;
else if(val == 1) myApp->ramSong.matrix[1] = 0x01;
//else if(val == 2) myApp->ramSong.matrix[1] = 0x02;
else if(val == 2) myApp->ramSong.matrix[1] = 0x04;
else if(val == 3) myApp->ramSong.matrix[1] = 0x08;
else if(val == 4) myApp->ramSong.matrix[1] = 0x10;
else if(val == 5) myApp->ramSong.matrix[1] = 0x20;
else if(val == 6) myApp->ramSong.matrix[1] = 0x40;
else if(val == 7) myApp->ramSong.matrix[1] = 0x80;
}
}
}
QString MyObject1::getMatrix2(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.matrix[2]);
str = QString(c);
}
}
return str;
}
void MyObject1::onMatrix2Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
int val = str.toInt();
if(val == 0) myApp->ramSong.matrix[2] = 0x00;
else if(val == 1) myApp->ramSong.matrix[2] = 0x01;
else if(val == 2) myApp->ramSong.matrix[2] = 0x02;
//else if(val == 3) myApp->ramSong.matrix[2] = 0x04;
else if(val == 3) myApp->ramSong.matrix[2] = 0x08;
else if(val == 4) myApp->ramSong.matrix[2] = 0x10;
else if(val == 5) myApp->ramSong.matrix[2] = 0x20;
else if(val == 6) myApp->ramSong.matrix[2] = 0x40;
else if(val == 7) myApp->ramSong.matrix[2] = 0x80;
}
}
}
QString MyObject1::getMatrix3(void) const
{
QString str = "";
if(myApp)
{
if(myApp->isInitialized == 1)
{
char c[10];
sprintf(c,"%d", myApp->ramSong.matrix[3]);
str = QString(c);
}
}
return str;
}
void MyObject1::onMatrix3Changed(QString str)
{
if(myApp)
{
if(myApp->isInitialized == 1)
{
int val = str.toInt();
if(val == 0) myApp->ramSong.matrix[3] = 0x00;
else if(val == 1) myApp->ramSong.matrix[3] = 0x01;
else if(val == 2) myApp->ramSong.matrix[3] = 0x02;
else if(val == 3) myApp->ramSong.matrix[3] = 0x04;
//else if(val == 4) myApp->ramSong.matrix[3] = 0x08;
else if(val == 4) myApp->ramSong.matrix[3] = 0x10;