-
Notifications
You must be signed in to change notification settings - Fork 0
/
LIS3DHconfigtool.py
executable file
·1485 lines (1114 loc) · 60.5 KB
/
LIS3DHconfigtool.py
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
#!/usr/bin/env python3
"""LIS3DHconfigtool, configuration tool to help manually
configure the registers of an LIS3DH accelerometer
created December 9, 2018
modified December 21, 2018
modified January 7, 2019 - Added save and open file options, also added
note edit option"""
"""
Copyright 2018, 2019 Owain Martin
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from tkinter import *
import tkinter.filedialog
import pickle, os
class LIS3DHConfigGui:
def __init__(self, master):
#-------- accelerometer set up ---------------
# set up registers to match default value
self.CTRL_REG1 = 0x07
self.CTRL_REG2 = 0x00
self.CTRL_REG3 = 0x00
self.CTRL_REG4 = 0x00
self.CTRL_REG5 = 0x00
self.CTRL_REG6 = 0x00
self.TEMP_CFG_REG = 0x00
self.FIFO_CTRL_REG = 0x00
self.INT1_CFG = 0x00
self.INT1_THS = 0x00
self.INT1_DURATION = 0x00
self.CLICK_CFG = 0x00
self.CLICK_THS = 0x00
self.TIME_LIMIT = 0x00
self.TIME_LATENCY = 0x00
self.TIME_WINDOW = 0x00
# misc variable declarations
self.adc = StringVar(value = 'off') # ADC enable/disable
self.bdu = StringVar(value = 'off') # Block Data Update - BDU
self.endian = StringVar(value = 'little')
self.fourD = StringVar(value = 'off') # 4D detection enable (default is 6D)
self.intLevel = StringVar(value = 'high') # interrupt active level
self.latch = StringVar(value = 'off') # interrupt latch
self.odr = IntVar(value = 50)
self.powerMode = StringVar(value = 'Off')
self.resolution = StringVar(value = 'low')
self.scale = IntVar(value = 2)
self.temperature = StringVar(value = 'off') # On board temperature sensor reading enable/disable
self.xAxis = StringVar(value = 'on')
self.yAxis = StringVar(value = 'on')
self.zAxis = StringVar(value = 'on')
# FIFO variables
self.fifoEnable = StringVar(value = 'off')
self.fifoMode = StringVar(value = 'bypass')
self.fifoThreshold = IntVar(value = 0)
# High pass filter variables
self.hpfMode= StringVar(value = 'normalreset')
self.hpfCutOff = IntVar(value = 0)
self.hpfFDS = StringVar(value = 'off')
self.hpfClick = StringVar(value = 'off')
self.hpfIS2 = StringVar(value = 'off')
self.hpfIS1 = StringVar(value = 'off')
# int1 variables - CTRL_REG3
self.int1_aoi1 =IntVar(value = 0)
self.int1_aoi2 =IntVar(value = 0)
self.int1_click =IntVar(value = 0)
self.int1_drdy1 =IntVar(value = 0)
self.int1_drdy2 =IntVar(value = 0)
self.int1_wtm =IntVar(value = 0)
self.int1_overrun =IntVar(value = 0)
# int1 config variables - INT1_CFG
self.int1_aoi = IntVar(value = 0)
self.int1_d6 = IntVar(value = 0)
self.int1_zh = IntVar(value = 0)
self.int1_zl = IntVar(value = 0)
self.int1_yh = IntVar(value = 0)
self.int1_yl = IntVar(value = 0)
self.int1_xh = IntVar(value = 0)
self.int1_xl = IntVar(value = 0)
self.int1_duration = IntVar(value = 0)
self.int1_threshold = IntVar(value = 0)
# click config variables - CLICK_CFG
self.click_zd = IntVar(value = 0)
self.click_zs = IntVar(value = 0)
self.click_yd = IntVar(value = 0)
self.click_ys = IntVar(value = 0)
self.click_xd = IntVar(value = 0)
self.click_xs = IntVar(value = 0)
self.click_threshold = IntVar(value = 0)
self.click_timelimit = IntVar(value = 0)
self.click_timelatency = IntVar(value = 0)
self.click_timewindow = IntVar(value = 0)
self.regValueText = StringVar()
self.notesText = StringVar(value = "Put some insightful information here to help the user along.\n\n This is also a space for the user to add their own notes.")
self.load_data() # load autosavesettings - i.e. last used settings
#------------ GUI set up --------------------------
fgColour = 'green'
# menu bar set up
mainMenu = Menu(master, tearoff=0)
fileMenu = Menu(mainMenu, tearoff = 0)
fileMenu.add_command(label = 'Save', command = self.save_to_file)
fileMenu.add_command(label = 'Open', command = self.load_from_file)
fileMenu.add_separator()
fileMenu.add_command(label = 'TEMPLATES', command = self.load_from_template)
fileMenu.add_separator()
fileMenu.add_command(label = 'Exit', command = self.exit_tool)
editMenu = Menu(mainMenu, tearoff = 0)
editMenu.add_command(label = 'Notes', command = self.edit_note)
mainMenu.add_cascade(label = 'File', menu = fileMenu)
mainMenu.add_cascade(label = 'Edit', menu = editMenu)
master.config(menu = mainMenu)
# set up main options frame area
self.optionFrame = LabelFrame(master, text = 'LIS3DH Options', fg = fgColour)
self.optionFrame.grid(row = 0, column = 0, rowspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
# set up power mode options
self.pwrModeOptionsFrame = LabelFrame(self.optionFrame, text = 'Power Mode Options', fg = fgColour)
self.pwrModeOptionsFrame.grid(row = 0, column = 0, padx= 5, pady= 5, sticky = (N,S,W,E))
pmButton1 = Radiobutton(self.pwrModeOptionsFrame,text = 'Normal',variable = self.powerMode, value = 'Normal'
,command = self.set_ODR, fg = fgColour)
pmButton1.grid(row = 0, column = 0)
pmButton2 = Radiobutton(self.pwrModeOptionsFrame,text = 'Low',variable = self.powerMode, value = 'Low'
,command = self.set_ODR, fg = fgColour)
pmButton2.grid(row = 0, column = 1)
pmButton3 = Radiobutton(self.pwrModeOptionsFrame,text = 'Off',variable = self.powerMode, value = 'Off'
,command = self.set_ODR, fg = fgColour)
pmButton3.grid(row = 0, column = 2)
#set up output data rate (ODR) options
self.odrOptionsFrame = LabelFrame(self.optionFrame, text = 'ODR Options (Hz)', fg = fgColour)
self.odrOptionsFrame.grid(row = 1, column = 0, columnspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
odrButton1 = Radiobutton(self.odrOptionsFrame,text = '1',variable = self.odr, value = 1
,command = self.set_ODR, fg = fgColour)
odrButton1.grid(row = 0, column = 0, sticky = W)
odrButton2 = Radiobutton(self.odrOptionsFrame,text = '10',variable = self.odr, value = 10
,command = self.set_ODR, fg = fgColour)
odrButton2.grid(row = 0, column = 1, sticky = W)
odrButton3 = Radiobutton(self.odrOptionsFrame,text = '25',variable = self.odr, value = 25
,command = self.set_ODR, fg = fgColour)
odrButton3.grid(row = 0, column = 2, sticky = W)
odrButton4 = Radiobutton(self.odrOptionsFrame,text = '50' ,variable = self.odr, value = 50
,command = self.set_ODR, fg = fgColour)
odrButton4.grid(row = 0, column = 3)
odrButton5 = Radiobutton(self.odrOptionsFrame,text = '100' ,variable = self.odr, value = 100
,command = self.set_ODR, fg = fgColour)
odrButton5.grid(row = 0, column = 4)
odrButton6 = Radiobutton(self.odrOptionsFrame,text = '200',variable = self.odr, value = 200
,command = self.set_ODR, fg = fgColour)
odrButton6.grid(row = 0, column = 5)
odrButton7 = Radiobutton(self.odrOptionsFrame,text = '400',variable = self.odr, value = 400
,command = self.set_ODR, fg = fgColour)
odrButton7.grid(row = 1, column = 0)
odrButton8 = Radiobutton(self.odrOptionsFrame,text = '1.6k',variable = self.odr, value = 1600
,command = self.set_ODR, fg = fgColour)
odrButton8.grid(row = 1, column = 1)
odrButton9 = Radiobutton(self.odrOptionsFrame,text = '1.25k',variable = self.odr, value = 1250
,command = self.set_ODR, fg = fgColour)
odrButton9.grid(row = 1, column = 2)
odrButton10 = Radiobutton(self.odrOptionsFrame,text = '5k',variable = self.odr, value = 5000
,command = self.set_ODR, fg = fgColour)
odrButton10.grid(row = 1, column = 3)
# set up scale options
self.scaleOptionsFrame = LabelFrame(self.optionFrame, text = 'Scale Options (+/-g)', fg = fgColour)
self.scaleOptionsFrame.grid(row = 0, column = 1, padx= 5, pady= 5, sticky = (N,S,W,E))
scaleButton1 = Radiobutton(self.scaleOptionsFrame,text = '2',variable = self.scale, value = 2
,command = self.set_scale, fg = fgColour)
scaleButton1.grid(row = 0, column = 0, sticky = W)
scaleButton2 = Radiobutton(self.scaleOptionsFrame,text = '4',variable = self.scale, value = 4
,command = self.set_scale, fg = fgColour)
scaleButton2.grid(row = 0, column = 1, sticky = W)
scaleButton3 = Radiobutton(self.scaleOptionsFrame,text = '8',variable = self.scale, value = 8
,command = self.set_scale, fg = fgColour)
scaleButton3.grid(row = 0, column = 2, sticky = W)
scaleButton4 = Radiobutton(self.scaleOptionsFrame,text = '16',variable = self.scale, value = 16
,command = self.set_scale, fg = fgColour)
scaleButton4.grid(row = 0, column = 3, sticky = W)
# set up x, y & z axis enable options
self.axisOptionsFrame = LabelFrame(self.optionFrame, text = 'Axis Enables', fg = fgColour)
self.axisOptionsFrame.grid(row = 2, column = 0, padx= 5, pady= 5, sticky = (N,S,W,E))
xButton = Checkbutton(self.axisOptionsFrame, text = 'x-axis', variable = self.xAxis, onvalue = 'on',
offvalue = 'off', command = self.axis_enable, fg = fgColour)
xButton.grid(row = 0, column = 0)
yButton = Checkbutton(self.axisOptionsFrame, text = 'y-axis', variable = self.yAxis, onvalue = 'on',
offvalue = 'off', command = self.axis_enable, fg = fgColour)
yButton.grid(row = 0, column = 1)
zButton = Checkbutton(self.axisOptionsFrame, text = 'z-axis', variable = self.zAxis, onvalue = 'on',
offvalue = 'off', command = self.axis_enable, fg = fgColour)
zButton.grid(row = 0, column = 2)
# set up resolution option area
self.resolutionOptionsFrame = LabelFrame(self.optionFrame, text = 'Resolution Options', fg = fgColour)
self.resolutionOptionsFrame.grid(row = 2, column = 1, columnspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
resLowButton = Radiobutton(self.resolutionOptionsFrame,text = 'Low',variable = self.resolution, value = 'low'
,command = self.set_resolution, fg = fgColour)
resLowButton.grid(row = 0, column = 0, sticky = W)
resHighButton = Radiobutton(self.resolutionOptionsFrame,text = 'High',variable = self.resolution, value = 'high'
,command = self.set_resolution, fg = fgColour)
resHighButton.grid(row = 0, column = 1, sticky = W)
# set up misc options area - includes BDU, 4D/6D, ADC & Temperature enable
self.miscOptionsFrame = LabelFrame(self.optionFrame, text = 'Miscellaneous Options', fg = fgColour)
self.miscOptionsFrame.grid(row = 3, column = 0, padx= 5, pady= 5, sticky = (N,S,W,E))
bduButton = Checkbutton(self.miscOptionsFrame, text = 'BDU', variable = self.bdu, onvalue = 'on',
offvalue = 'off', command = self.set_BDU, fg = fgColour)
bduButton.grid(row = 0, column = 0)
fourDButton = Radiobutton(self.miscOptionsFrame,text = '4D',variable = self.fourD, value = 'on'
,command = self.set_4D, fg = fgColour)
fourDButton.grid(row = 0, column = 1)
sixDButton = Radiobutton(self.miscOptionsFrame,text = '6D',variable = self.fourD, value = 'off'
,command = self.set_4D, fg = fgColour)
sixDButton.grid(row = 0, column = 2)
adcButton = Checkbutton(self.miscOptionsFrame, text = 'ADC', variable = self.adc, onvalue = 'on',
offvalue = 'off', command = self.set_adc, fg = fgColour)
adcButton.grid(row = 1, column = 0)
tempButton = Checkbutton(self.miscOptionsFrame, text = 'Temperature', variable = self.temperature, onvalue = 'on',
offvalue = 'off', command = self.set_temperature, fg = fgColour)
tempButton.grid(row = 1, column = 1, columnspan = 2)
# set up endian option area
self.endianOptionsFrame = LabelFrame(self.optionFrame, text = 'Endian Options', fg = fgColour)
self.endianOptionsFrame.grid(row = 3, column = 1, columnspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
littleEndButton = Radiobutton(self.endianOptionsFrame,text = 'Little',variable = self.endian, value = 'little'
,command = self.set_endian, fg = fgColour)
littleEndButton.grid(row = 0, column = 0, sticky = W)
bigEndButton = Radiobutton(self.endianOptionsFrame,text = 'Big',variable = self.endian, value = 'big'
,command = self.set_endian, fg = fgColour)
bigEndButton.grid(row = 0, column = 1, sticky = W)
# set up FIFO options area
self.fifoOptionsFrame = LabelFrame(self.optionFrame, text = 'FIFO Options', fg = fgColour)
self.fifoOptionsFrame.grid(row = 4, column = 0, columnspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
fifoEnButton = Checkbutton(self.fifoOptionsFrame, text = 'FIFO Enable', variable = self.fifoEnable, onvalue = 'on',
offvalue = 'off', command = self.set_fifo_mode, fg = fgColour)
fifoEnButton.grid(row = 0, column = 0, columnspan = 2, sticky = W)
fifoBypassButton = Radiobutton(self.fifoOptionsFrame,text = 'Bypass',variable = self.fifoMode, value = 'bypass'
,command = self.set_fifo_mode, fg = fgColour)
fifoBypassButton.grid(row = 1, column = 0, sticky = W)
fifofifoButton = Radiobutton(self.fifoOptionsFrame,text = 'FIFO',variable = self.fifoMode, value = 'fifo'
,command = self.set_fifo_mode, fg = fgColour)
fifofifoButton.grid(row = 1, column = 1)
fifoStreamButton = Radiobutton(self.fifoOptionsFrame,text = 'Stream',variable = self.fifoMode, value = 'stream'
,command = self.set_fifo_mode, fg = fgColour)
fifoStreamButton.grid(row = 1, column = 2)
fifoTriggerButton = Radiobutton(self.fifoOptionsFrame,text = 'Trigger/Stream2FIFO',variable = self.fifoMode, value = 'streamfifo'
,command = self.set_fifo_mode, fg = fgColour)
fifoTriggerButton.grid(row = 1, column = 3)
# set up FIFO threshold text entry
fifoThresholdLabel = Label(self.fifoOptionsFrame, text = 'Threshold (0-31):', fg = fgColour, anchor = W)
fifoThresholdLabel.grid(row = 2, column = 0, columnspan = 2)
fifoThresholdText = Entry(self.fifoOptionsFrame, width = 3, fg = fgColour,textvariable = self.fifoThreshold)
fifoThresholdText.grid(row = 2, column = 2, sticky = W)
fifoThresholdText.bind("<Return>", self.set_fifo_threshold)
fifoThresholdText.bind("<FocusOut>", self.set_fifo_threshold)
# set up High Pass Filter Mode options area
self.HPFModeOptionsFrame = LabelFrame(self.optionFrame, text = 'High Pass Filter Mode Options', fg = fgColour)
self.HPFModeOptionsFrame.grid(row = 5, column = 0, columnspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
hpNormalButton = Radiobutton(self.HPFModeOptionsFrame,text = 'Normal',variable = self.hpfMode, value = 'normal'
,command = self.set_highpass_filter, fg = fgColour)
hpNormalButton.grid(row = 0, column = 0, sticky = W)
hpNormalResetButton = Radiobutton(self.HPFModeOptionsFrame,text = 'Normal Reset',variable = self.hpfMode, value = 'normalreset'
,command = self.set_highpass_filter, fg = fgColour)
hpNormalResetButton.grid(row = 0, column = 1, sticky = W)
hpReferenceButton = Radiobutton(self.HPFModeOptionsFrame,text = 'Reference',variable = self.hpfMode, value = 'reference'
,command = self.set_highpass_filter, fg = fgColour)
hpReferenceButton.grid(row = 0, column = 2, sticky = W)
hpAutoresetButton = Radiobutton(self.HPFModeOptionsFrame,text = 'Autoreset',variable = self.hpfMode, value = 'autoreset'
,command = self.set_highpass_filter, fg = fgColour)
hpAutoresetButton.grid(row = 0, column = 3, sticky = W)
hpFDSButton = Checkbutton(self.HPFModeOptionsFrame, text = 'FDS', variable = self.hpfFDS, onvalue = 'on',
offvalue = 'off', command = self.set_highpass_filter, fg = fgColour)
hpFDSButton.grid(row = 1, column = 0, sticky = W)
hpClickButton = Checkbutton(self.HPFModeOptionsFrame, text = 'HPCLICK', variable = self.hpfClick, onvalue = 'on',
offvalue = 'off', command = self.set_highpass_filter, fg = fgColour)
hpClickButton.grid(row = 1, column = 1, sticky = W)
hpIS2Button = Checkbutton(self.HPFModeOptionsFrame, text = 'HPIS2', variable = self.hpfIS2, onvalue = 'on',
offvalue = 'off', command = self.set_highpass_filter, fg = fgColour)
hpIS2Button.grid(row = 1, column = 2, sticky = W)
hpIS1Button = Checkbutton(self.HPFModeOptionsFrame, text = 'HPIS1', variable = self.hpfIS1, onvalue = 'on',
offvalue = 'off', command = self.set_highpass_filter, fg = fgColour)
hpIS1Button.grid(row = 1, column = 3, sticky = W)
# set up High Pass Filter Cut-off frequency text entry
hpCutOffLabel = Label(self.HPFModeOptionsFrame, text = 'HPC Value (0-3):', fg = fgColour, anchor = W)
hpCutOffLabel.grid(row = 2, column = 0, columnspan = 1, sticky = W)
hpCutOffText = Entry(self.HPFModeOptionsFrame, width = 3, fg = fgColour,textvariable = self.hpfCutOff)
hpCutOffText.grid(row = 2, column = 1, sticky = W)
hpCutOffText.bind("<Return>", self.set_highpass_filter)
hpCutOffText.bind("<FocusOut>", self.set_highpass_filter)
# set up interrupt pin output options - Active High/Low and Latch On/Off
self.interruptOptionsFrame = LabelFrame(self.optionFrame, text = 'Interrupt Options', fg = fgColour)
self.interruptOptionsFrame.grid(row = 6, column = 0, columnspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
latchButton = Checkbutton(self.interruptOptionsFrame, text = 'Latch', variable = self.latch, onvalue = 'on',
offvalue = 'off', command = self.latch_interrupt, fg = fgColour)
latchButton.grid(row = 0, column = 2)
intLowButton = Radiobutton(self.interruptOptionsFrame,text = 'Active Low',variable = self.intLevel, value = 'low'
,command = self.interrupt_high_low, fg = fgColour)
intLowButton.grid(row = 0, column = 0, sticky = W)
intHighButton = Radiobutton(self.interruptOptionsFrame,text = 'Active High',variable = self.intLevel, value = 'high'
,command = self.interrupt_high_low, fg = fgColour)
intHighButton.grid(row = 0, column = 1, sticky = W)
# set up Interrupt 1 output options
self.int1OptionsFrame = LabelFrame(self.optionFrame, text = 'Int1 Output Options - CTRL_REG3', fg = fgColour)
self.int1OptionsFrame.grid(row = 7, column = 0, columnspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
click1Button = Checkbutton(self.int1OptionsFrame, text = 'Click', variable = self.int1_click, onvalue = 1,
offvalue = 0, command = self.set_int1_pin, fg = fgColour)
click1Button.grid(row = 0, column = 0, sticky = W)
aoi1Button = Checkbutton(self.int1OptionsFrame, text = 'AOI1', variable = self.int1_aoi1, onvalue = 1,
offvalue = 0, command = self.set_int1_pin, fg = fgColour)
aoi1Button.grid(row = 0, column = 1, sticky = W)
aoi2Button = Checkbutton(self.int1OptionsFrame, text = 'AOI2', variable = self.int1_aoi2, onvalue = 1,
offvalue = 0, command = self.set_int1_pin, fg = fgColour)
aoi2Button.grid(row = 0, column = 2)
drdy1Button = Checkbutton(self.int1OptionsFrame, text = 'DRDY1', variable = self.int1_drdy1, onvalue = 1,
offvalue = 0, command = self.set_int1_pin, fg = fgColour)
drdy1Button.grid(row = 0, column = 3)
drdy2Button = Checkbutton(self.int1OptionsFrame, text = 'DRDY2', variable = self.int1_drdy2, onvalue = 1,
offvalue = 0, command = self.set_int1_pin, fg = fgColour)
drdy2Button.grid(row = 0, column = 4)
wtm1Button = Checkbutton(self.int1OptionsFrame, text = 'Watermark', variable = self.int1_wtm, onvalue = 1,
offvalue = 0, command = self.set_int1_pin, fg = fgColour)
wtm1Button.grid(row = 1, column = 0, sticky = W)
overrun1Button = Checkbutton(self.int1OptionsFrame, text = 'Overrun', variable = self.int1_overrun, onvalue = 1,
offvalue = 0, command = self.set_int1_pin, fg = fgColour)
overrun1Button.grid(row = 1, column = 1)
# set up Interrupt 1 configuration area
self.int1ConfigFrame = LabelFrame(self.optionFrame, text = 'Int1 Configuration', fg = fgColour)
self.int1ConfigFrame.grid(row = 8, column = 0, columnspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
aoiButton = Checkbutton(self.int1ConfigFrame, text = 'AOI', variable = self.int1_aoi, onvalue = 1,
offvalue = 0, command = self.set_int1_config, fg = fgColour)
aoiButton.grid(row = 0, column = 0, sticky = W)
d6Button = Checkbutton(self.int1ConfigFrame, text = '6D', variable = self.int1_d6, onvalue = 1,
offvalue = 0, command = self.set_int1_config, fg = fgColour)
d6Button.grid(row = 0, column = 1, sticky = W)
zhButton = Checkbutton(self.int1ConfigFrame, text = 'ZH/ZUP', variable = self.int1_zh, onvalue = 1,
offvalue = 0, command = self.set_int1_config, fg = fgColour)
zhButton.grid(row = 0, column = 2, sticky = W)
zlButton = Checkbutton(self.int1ConfigFrame, text = 'ZL/ZDOWN', variable = self.int1_zl, onvalue = 1,
offvalue = 0, command = self.set_int1_config, fg = fgColour)
zlButton.grid(row = 0, column = 3, sticky = W)
yhButton = Checkbutton(self.int1ConfigFrame, text = 'YH/YUP', variable = self.int1_yh, onvalue = 1,
offvalue = 0, command = self.set_int1_config, fg = fgColour)
yhButton.grid(row = 1, column = 0, sticky = W)
ylButton = Checkbutton(self.int1ConfigFrame, text = 'YL/YDOWN', variable = self.int1_yl, onvalue = 1,
offvalue = 0, command = self.set_int1_config, fg = fgColour)
ylButton.grid(row = 1, column = 1, sticky = W)
xhButton = Checkbutton(self.int1ConfigFrame, text = 'XH/XUP', variable = self.int1_xh, onvalue = 1,
offvalue = 0, command = self.set_int1_config, fg = fgColour)
xhButton.grid(row = 1, column = 2, sticky = W)
xlButton = Checkbutton(self.int1ConfigFrame, text = 'XL/XDOWN', variable = self.int1_xl, onvalue = 1,
offvalue = 0, command = self.set_int1_config, fg = fgColour)
xlButton.grid(row = 1, column = 3, sticky = W)
# set up INT1 duration text entry
durationLabel = Label(self.int1ConfigFrame, text = 'Duration (ms):', fg = fgColour, anchor = W)
durationLabel.grid(row = 2, column = 0)
durationText = Entry(self.int1ConfigFrame, width=6, fg = fgColour,textvariable = self.int1_duration)
durationText.grid(row = 2, column = 1)
durationText.bind("<Return>", self.set_int1_duration)
durationText.bind("<FocusOut>", self.set_int1_duration)
# set up INT1 threshold text entry
thresholdLabel = Label(self.int1ConfigFrame, text = 'Threshold (mg):', fg = fgColour, anchor = W)
thresholdLabel.grid(row = 2, column = 2)
thresholdText = Entry(self.int1ConfigFrame, width=6, fg = fgColour,textvariable = self.int1_threshold)
thresholdText.grid(row = 2, column = 3)
thresholdText.bind("<Return>", self.set_int1_threshold)
thresholdText.bind("<FocusOut>", self.set_int1_threshold)
# set up click configuration area
self.clickConfigFrame = LabelFrame(self.optionFrame, text = 'Click Configuration', fg = fgColour)
self.clickConfigFrame.grid(row = 9, column = 0, columnspan = 2, padx= 5, pady= 5, sticky = (N,S,W,E))
zdButton = Checkbutton(self.clickConfigFrame, text = 'ZD', variable = self.click_zd, onvalue = 1,
offvalue = 0, command = self.set_click_config, fg = fgColour)
zdButton.grid(row = 0, column = 0, sticky = W)
zsButton = Checkbutton(self.clickConfigFrame, text = 'ZS', variable = self.click_zs, onvalue = 1,
offvalue = 0, command = self.set_click_config, fg = fgColour)
zsButton.grid(row = 0, column = 1, sticky = W)
ydButton = Checkbutton(self.clickConfigFrame, text = 'YD', variable = self.click_yd, onvalue = 1,
offvalue = 0, command = self.set_click_config, fg = fgColour)
ydButton.grid(row = 0, column = 2, sticky = W)
ysButton = Checkbutton(self.clickConfigFrame, text = 'YS', variable = self.click_ys, onvalue = 1,
offvalue = 0, command = self.set_click_config, fg = fgColour)
ysButton.grid(row = 0, column = 3, sticky = W)
xdButton = Checkbutton(self.clickConfigFrame, text = 'XD', variable = self.click_xd, onvalue = 1,
offvalue = 0, command = self.set_click_config, fg = fgColour)
xdButton.grid(row = 0, column = 4, sticky = W)
xsButton = Checkbutton(self.clickConfigFrame, text = 'XS', variable = self.click_xs, onvalue = 1,
offvalue = 0, command = self.set_click_config, fg = fgColour)
xsButton.grid(row = 0, column = 5, sticky = W)
# set up click threshold text entry
clickThresholdLabel = Label(self.clickConfigFrame, text = 'Threshold (mg):', fg = fgColour, anchor = W)
clickThresholdLabel.grid(row = 1, column = 0, columnspan = 2)
clickThresholdText = Entry(self.clickConfigFrame, width=6, fg = fgColour,textvariable = self.click_threshold)
clickThresholdText.grid(row = 1, column = 2)
clickThresholdText.bind("<Return>", self.set_click_threshold)
clickThresholdText.bind("<FocusOut>", self.set_click_threshold)
# set up click time limit text entry
clickTimeLimitLabel = Label(self.clickConfigFrame, text = 'Time Limit (ms):', fg = fgColour, anchor = W)
clickTimeLimitLabel.grid(row = 1, column = 3, columnspan = 2)
clickTimeLimitText = Entry(self.clickConfigFrame, width=6, fg = fgColour,textvariable = self.click_timelimit)
clickTimeLimitText.grid(row = 1, column = 5)
clickTimeLimitText.bind("<Return>", self.set_click_timelimit)
clickTimeLimitText.bind("<FocusOut>", self.set_click_timelimit)
# set up click time latency text entry
clickTimeLatencyLabel = Label(self.clickConfigFrame, text = 'Time Latency (ms):', fg = fgColour, anchor = W)
clickTimeLatencyLabel.grid(row = 2, column = 0, columnspan = 2)
clickTimeLatencyText = Entry(self.clickConfigFrame, width=6, fg = fgColour,textvariable = self.click_timelatency)
clickTimeLatencyText.grid(row = 2, column = 2)
clickTimeLatencyText.bind("<Return>", self.set_click_timelatency)
clickTimeLatencyText.bind("<FocusOut>", self.set_click_timelatency)
# set up click time window text entry
clickTimeWindowLabel = Label(self.clickConfigFrame, text = 'Time Window (ms):', fg = fgColour, anchor = W)
clickTimeWindowLabel.grid(row = 2, column = 3, columnspan = 2)
clickTimeWindowText = Entry(self.clickConfigFrame, width=6, fg = fgColour,textvariable = self.click_timewindow)
clickTimeWindowText.grid(row = 2, column = 5)
clickTimeWindowText.bind("<Return>", self.set_click_timewindow)
clickTimeWindowText.bind("<FocusOut>", self.set_click_timewindow)
# set up main register info display area
self.regValueFrame = LabelFrame(master, text = 'Register Values', fg = fgColour)
self.regValueFrame.grid(row = 0, column =1, padx=5, pady=5, sticky = (N,S,W,E))
self.regValueTextArea = Label(self.regValueFrame, textvariable=self.regValueText, width = 40, anchor = NW,
justify = LEFT, fg = fgColour )
self.regValueTextArea.grid(row = 0, column = 0)
# set up notes area
self.notesFrame = LabelFrame(master, text = 'Notes', fg = fgColour)
self.notesFrame.grid(row = 1, column =1, padx=5, pady=5, sticky = (N,S,W,E))
self.notesTextArea = Label(self.notesFrame, textvariable=self.notesText, width = 40, height = 20, anchor = NW,
justify = LEFT, wraplength = 320, fg = fgColour )
self.notesTextArea.grid(row = 0, column = 0)
self.print_reg_values() # update the register text screen
return
def print_reg_values(self):
info = "CTRL_REG1: "+str(hex(self.CTRL_REG1))+" "+str(bin(self.CTRL_REG1))+" "+str(self.CTRL_REG1)+"\n"
info = info + "CTRL_REG2: "+str(hex(self.CTRL_REG2))+" "+str(bin(self.CTRL_REG2))+" "+str(self.CTRL_REG2)+"\n"
info = info + "CTRL_REG3: "+str(hex(self.CTRL_REG3))+" "+str(bin(self.CTRL_REG3))+" "+str(self.CTRL_REG3)+"\n"
info = info + "CTRL_REG4: "+str(hex(self.CTRL_REG4))+" "+str(bin(self.CTRL_REG4))+" "+str(self.CTRL_REG4)+"\n"
info = info + "CTRL_REG5: "+str(hex(self.CTRL_REG5))+" "+str(bin(self.CTRL_REG5))+" "+str(self.CTRL_REG5)+"\n"
info = info + "CTRL_REG6: "+str(hex(self.CTRL_REG6))+" "+str(bin(self.CTRL_REG6))+" "+str(self.CTRL_REG6)+"\n\n"
info = info + "TEMP_CFG_REG: "+str(hex(self.TEMP_CFG_REG))+" "+str(bin(self.TEMP_CFG_REG))+" "+str(self.TEMP_CFG_REG)+"\n"
info = info + "FIFO_CTRL_REG: "+str(hex(self.FIFO_CTRL_REG))+" "+str(bin(self.FIFO_CTRL_REG))+" "+str(self.FIFO_CTRL_REG)+"\n\n"
info = info + "INT1_CFG: "+str(hex(self.INT1_CFG))+" "+str(bin(self.INT1_CFG))+" "+str(self.INT1_CFG)+"\n"
info = info + "INT1_THS: "+str(hex(self.INT1_THS))+" "+str(bin(self.INT1_THS))+" "+str(self.INT1_THS)+"\n"
info = info + "INT1_DURATION: "+str(hex(self.INT1_DURATION))+" "+str(bin(self.INT1_DURATION))+" "+str(self.INT1_DURATION)+"\n\n"
info = info + "CLICK_CFG: "+str(hex(self.CLICK_CFG))+" "+str(bin(self.CLICK_CFG))+" "+str(self.CLICK_CFG)+"\n"
info = info + "CLICK_THS: "+str(hex(self.CLICK_THS))+" "+str(bin(self.CLICK_THS))+" "+str(self.CLICK_THS)+"\n"
info = info + "TIME_LIMIT: "+str(hex(self.TIME_LIMIT))+" "+str(bin(self.TIME_LIMIT))+" "+str(self.TIME_LIMIT)+"\n"
info = info + "TIME_LATENCY: "+str(hex(self.TIME_LATENCY))+" "+str(bin(self.TIME_LATENCY))+" "+str(self.TIME_LATENCY)+"\n"
info = info + "TIME_WINDOW: "+str(hex(self.TIME_WINDOW))+" "+str(bin(self.TIME_WINDOW))+" "+str(self.TIME_WINDOW)+"\n"
self.regValueText.set(info)
self.save_data()
return
def axis_enable(self):
"""axis_enable, function to enable/disable the x, y and z axis"""
xBit = 0b1 # default value - 'on'
yBit = 0b1 # default value - 'on'
zBit = 0b1 # default value - 'on'
CTRL_REG1 = self.CTRL_REG1
x = self.xAxis.get()
y = self.yAxis.get()
z = self.zAxis.get()
if x == 'off':
xBit = 0b0
if y == 'off':
yBit = 0b0
if z == 'off':
zBit = 0b0
CTRL_REG1 = CTRL_REG1 & 0b11111000
CTRL_REG1 = CTRL_REG1 | ((zBit<<2) + (yBit<<1) + xBit)
self.CTRL_REG1 = CTRL_REG1
self.print_reg_values() # update the text screen
return
def interrupt_high_low(self):
"""interrupt_high_low, function to set the interrupt pins to either
active high or active low"""
CTRL_REG6 = self.CTRL_REG6
level = self.intLevel.get()
if level == 'low':
highlowBit = 0b1
else:
highlowBit = 0b0
CTRL_REG6 = CTRL_REG6 & 0b11111101
CTRL_REG6 = CTRL_REG6 | (highlowBit<<1)
self.CTRL_REG6 = CTRL_REG6
self.print_reg_values() # update the text screen
return
def latch_interrupt(self):
"""latch_interrupt, function to turn the latch feature on interrupt1
on or off"""
CTRL_REG5 = self.CTRL_REG5
latch = self.latch.get()
if latch == 'off':
latchBit = 0b0
else:
latchBit = 0b1
CTRL_REG5 = CTRL_REG5 & 0b11110111
CTRL_REG5 = CTRL_REG5 | (latchBit<<3)
self.CTRL_REG5 = CTRL_REG5
self.print_reg_values() # update the text screen
return
def set_4D(self):
"""set_4D, function to turn 4D detection on or off. This sets
bit 3 of CTRL_REG5 (0x24)"""
CTRL_REG5 = self.CTRL_REG5
enable = self.fourD.get()
if enable == 'off':
enableBit = 0b0
else:
enableBit = 0b1
CTRL_REG5 = CTRL_REG5 & 0b11111011
CTRL_REG5 = CTRL_REG5 | (enableBit<<2)
self.CTRL_REG5 = CTRL_REG5
self.print_reg_values() # update the text screen
return
def set_adc(self):
"""set_adc, function to enable/disable the aux 10 bit adc
converter feature. This sets bit 7 of TEMP_CFG_REG (0x1F)"""
TEMP_CFG_REG = self.TEMP_CFG_REG
adcOn = self.adc.get()
adcBit = 0b0 # default value
if adcOn == 'on':
adcBit = 0b1
TEMP_CFG_REG = TEMP_CFG_REG & 0b01111111
TEMP_CFG_REG = TEMP_CFG_REG | (adcBit<<7)
self.TEMP_CFG_REG = TEMP_CFG_REG
self.print_reg_values() # update the text screen
return
def set_BDU(self):
"""set_BDU, function to enable/disable the block data update
feature. This sets bit 7 of CTRL_REG4 (0x23)"""
CTRL_REG4 = self.CTRL_REG4
bdu = self.bdu.get()
bduBit = 0b0 # default value
if bdu == 'on':
bduBit = 0b1
CTRL_REG4 = CTRL_REG4 & 0b01111111
CTRL_REG4 = CTRL_REG4 | (bduBit<<7)
self.CTRL_REG4 = CTRL_REG4
self.print_reg_values() # update the text screen
return
def set_click_config(self):
"""set_click_config, function to set the CLICK_CFG regisiter
(0x38) options"""
zd = self.click_zd.get()
zs = self.click_zs.get()
yd = self.click_yd.get()
ys = self.click_ys.get()
xd = self.click_xd.get()
xs = self.click_xs.get()
CLICK_CFG = ((zd<<5) + (zs<<4) +(yd<<3) + (ys<<2) + (xd<<1)
+ xs)
self.CLICK_CFG = CLICK_CFG
self.print_reg_values() # update the text screen
return
def set_click_threshold(self, event):
"""set_click_threshold, function to set the click threshold (mg).
This sets CLICK_THS (0x3A)"""
try:
threshold = abs(self.click_threshold.get())
scale = self.scale.get()
thresholdBits = 0b0
if scale == 2:
scaleOffset = 4
elif scale == 4:
scaleOffset = 5
elif scale == 8:
scaleOffset = 6
else: # scale == 16
scaleOffset = 7
for i in range (6,-1,-1):
if threshold >= 2**(i+scaleOffset):
thresholdBits = thresholdBits | (1<<i)
threshold = threshold - 2**(i+scaleOffset)
except ValueError:
self.click_threshold.set(0)
thresholdBits = 0x00
except:
self.click_threshold.set(0)
thresholdBits = 0x00
self.CLICK_THS = thresholdBits
self.print_reg_values() # update the text screen
return
def set_click_timelimit(self, event):
"""set_click_timelimit, function to set the click time limit
duration (ms). This sets TIME_LIMIT (0x3B)"""
try:
duration = abs(self.click_timelimit.get())
odr = self.odr.get()
if duration > (float(127000)/float(odr)):
durationBits = 0b01111111
else:
durationBits = int((float(duration) / float(1000)) * odr)
durationBits = durationBits & 0b01111111
except ValueError:
self.click_timelimit.set(0)
durationBits = 0x00
except:
self.click_timelimit.set(0)
durationBits = 0x00
self.TIME_LIMIT = durationBits
self.print_reg_values() # update the text screen
return
def set_click_timelatency(self, event):
"""set_click_timelatency, function to set the click time latency
duration (ms). This sets TIME_LATENCY (0x3C)"""
try:
duration = abs(self.click_timelatency.get())
odr = self.odr.get()
if duration > (float(255000)/float(odr)):
durationBits = 0b11111111
else:
durationBits = int((float(duration) / float(1000)) * odr)
durationBits = durationBits & 0b11111111
except ValueError:
self.click_timelatency.set(0)
durationBits = 0x00
except:
self.click_timelatency.set(0)
durationBits = 0x00
self.TIME_LATENCY = durationBits
self.print_reg_values() # update the text screen
return
def set_click_timewindow(self, event):
"""set_click_timewindow, function to set the click time window
duration (ms). This sets TIME_WINDOW (0x3D)"""
try:
duration = abs(self.click_timewindow.get())
odr = self.odr.get()
if duration > (float(255000)/float(odr)):
durationBits = 0b11111111
else:
durationBits = int((float(duration) / float(1000)) * odr)
durationBits = durationBits & 0b11111111
except ValueError:
self.click_timewindow.set(0)
durationBits = 0x00
except:
self.click_timewindow.set(0)
durationBits = 0x00
self.TIME_WINDOW = durationBits
self.print_reg_values() # update the text screen
return
def set_endian(self):
"""set_endian, function to set the endian option to big
or little. This sets bit 6 of CTRL_REG4 (0x23)"""
CTRL_REG4 = self.CTRL_REG4
endian = self.endian.get()
endianBit = 0b0 # default value
if endian == 'big':
endianBit = 0b1
CTRL_REG4 = CTRL_REG4 & 0b10111111
CTRL_REG4 = CTRL_REG4 | (endianBit<<6)
self.CTRL_REG4 = CTRL_REG4
self.print_reg_values() # update the text screen
return
def set_fifo_mode(self):
"""set_fifo_mode, function to set the fifo mode of the accelerometer,
valid value for mode are; off, bypass, fifo, stream and streamfifo.
This sets bit 6 of CTRL_REG5 (0x24) and bits 6 & 7 of FIFO_CTRL_REG
(0x2E)"""
CTRL_REG5 = self.CTRL_REG5
FIFO_CTRL_REG = self.FIFO_CTRL_REG
fifoEnable = self.fifoEnable.get()
mode = self.fifoMode.get()
enableBit = 0b0 # default value: disable
modeBits = 0b00 # default value: bypass
if fifoEnable == 'on':
enableBit = 0b1
if mode == 'fifo':
modeBits = 0b01
elif mode == 'stream':
modeBits = 0b10
elif mode == 'streamfifo':
modeBits = 0b11
CTRL_REG5 = CTRL_REG5 & 0b10111111
CTRL_REG5 = CTRL_REG5 | (enableBit<<6)
self.CTRL_REG5 = CTRL_REG5
FIFO_CTRL_REG = FIFO_CTRL_REG & 0b00111111
FIFO_CTRL_REG = FIFO_CTRL_REG | (modeBits<<6)
self.FIFO_CTRL_REG = FIFO_CTRL_REG
self.print_reg_values() # update the text screen
return
def set_fifo_threshold(self, event):
"""set_fifo_threshold, function to the fifo threshold level.
This sets bits 0-4 of FIFO_CTRL_REG (0x2E)"""
FIFO_CTRL_REG = self.FIFO_CTRL_REG
try:
threshold = int(abs(self.fifoThreshold.get()))
if threshold > 31:
threshold = 31
except ValueError:
threshold = 0
self.fifoThreshold.set(0)
except:
threshold = 0
self.fifoThreshold.set(0)
FIFO_CTRL_REG = FIFO_CTRL_REG & 0b11100000
FIFO_CTRL_REG = FIFO_CTRL_REG | threshold
self.FIFO_CTRL_REG = FIFO_CTRL_REG
self.print_reg_values() # update the text screen
return
def set_highpass_filter(self, event = None):
"""set_highpass_filter, function to set the various high pass filter
options. This sets CTRL_REG2 (0x21)
mode - normal, reference, normalreset, autoreset
freq - see table 8 of the LIS3DH app note
FDS (filtered data selection) bypass - on or off """
mode = self.hpfMode.get()
FDS = self.hpfFDS.get()
hpClick = self.hpfClick.get()
hpIS2 = self.hpfIS2.get()
hpIS1 = self.hpfIS1.get()
fdsBit = 0b0 # default value
hpClickBit = 0b0 # default value
hpIS2Bit = 0b0 # default value
hpIS1Bit = 0b0 # default value
if mode == 'normalreset':
modeBits = 0b0
elif mode == 'reference':
modeBits = 0b1
elif mode == 'autoreset':
modeBits = 0b11
else: # mode = 'normal'
modeBits = 0b10
try:
freq = int(abs(self.hpfCutOff.get()))
except ValueError:
freq = 0
self.hpfCutOff.set(0)
except:
freq = 0
self.hpfCutOff.set(0)
if freq > 0b11:
freqBits = 0b11
else:
freqBits = freq
if FDS == 'on':
fdsBit = 0b1
if hpClick == 'on':
hpClickBit = 0b1
if hpIS2 == 'on':
hpIS2Bit = 0b1
if hpIS1 == 'on':
hpIS1Bit = 0b1
CTRL_REG2 = ((modeBits<<6) + (freqBits<<4) + (fdsBit<<3) + (hpClickBit<<2)
+ (hpIS2Bit<<1) +hpIS1Bit)
self.CTRL_REG2 = CTRL_REG2
self.print_reg_values() # update the text screen
return
def set_int1_config(self):
"""set_int1_config, function to set the INT1_CFG regisiter (0x30) options"""
aoi = self.int1_aoi.get()
d6 = self.int1_d6.get()
zh = self.int1_zh.get()
zl = self.int1_zl.get()
yh = self.int1_yh.get()
yl = self.int1_yl.get()
xh = self.int1_xh.get()