-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparameters.py
1756 lines (1365 loc) · 87.4 KB
/
parameters.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
# -*- coding: utf-8 -*-
"""
parameters.py for SmartTerminal
this is the configuration file for the smart terminal smart_terminal.py
one instance is created on system startup
"""
import logging
import serial
import sys
import os
import datetime
# --------- local imports
from running_on import RunningOn
from app_global import AppGlobal
class Parameters( object ):
"""
manages parameter values for all of Smart Terminal app and its various data logging
and monitoring applications
generally available all of the application through AppGlobal.parameters
!! icons should usually be set at the beginning of each mode if you want the icon to id the mode
"""
# -------
def choose_mode( self, ):
"""
choose your mode, typically only one line is uncommented, or just pass to stay in default mode
note addition at end for some testing, keep for that purpose
use editor find or outline to go to the method
"""
# =========== add your modes as desired starting here ========
# ---------->> call modes here; I comment out ones I am not using. Makes it really easy to switch modes
# these are modes I use, pretty much one for each micro-controller
# project that I do. You can look at them as examples or delete the subroutines
# pick one by un-commenting it. These are typically synced up with an Arduino app
pass # if everything else is commented out
#self.quick_start_mode()
#self.tutorial_example_mode() # simple setup for documentation and basic terminal
#self.accel_demo_mode() #
#self.controlino_mode() #
#self.ddclock_mode()
#self.ddclock_david()
#self.ddclock_test_mode()
#self.ddclock_demo_1()
#self.ddclock_demo_2()
self.deer_me_dev()
#self.deer_me_pi_deploy()
#self.infra_red_mode() # not working, requires special modules from irtools
#self.green_house_mode()
#self.motor_driver_mode()
#self.root_cellar_mode()
#self.stepper_tester_mode()
#self.serial_cmd_test() # for messing with master SerialCmd and SerialCmdMaster
#self.terminal_mode()
#self.two_axis_mode()
#self.well_monitor_mode()
# ---- additional stuff only for testing in addition to another mode
#self.mode_plus_tests() # used only for testing change freely
# -------
def __init__(self, ):
"""
what it says, placed second as the most common mod to parameters is to choose_mode
"""
self.controller = AppGlobal.controller
AppGlobal.parameters = self
# next is "mandatory" or you need to make up for any/many missing parameters
self.default_terminal_mode() # this is not really a mode that is intended to be used or modified
# but a default state, call before the "real" mode
# do not modify unless your really understand
# but you can run the terminal in this mode
self.running_on_tweaks() # adjustments for different run time environments
self.choose_mode()
self.sanity_check_parms( ) # more of an idea than something of value
# leave this as last -- do not modify, the global app makes some changes
AppGlobal.parameter_tweaks() # including restart
# and we are done
# for next move to prog info ??
# msg = ( f"{self}" )
# AppGlobal.logger.log( 55, msg )
#print( self ) # debug
return
# -------
def running_on_tweaks(self, ):
"""
use running on tweaks as a more sophisticated version of os_tweaks and computer name tweaks,
"""
computer_id = self.running_on.computer_id
self.os_tweaks() # general for os, later for more specific
if computer_id == "smithers":
self.win_geometry = '1450x700+20+20' # width x height position
self.ex_editor = r"D:\apps\Notepad++\notepad++.exe"
self.db_file_name = "smithers_db.db"
elif computer_id == "millhouse":
self.ex_editor = r"C:\apps\Notepad++\notepad++.exe"
#self.win_geometry = '1300x600+20+20'
self.db_file_name = "millhouse_db.db"
elif computer_id == "theprof":
self.ex_editor = r"C:\apps\Notepad++\notepad++.exe"
self.db_file_name = "the_prof_db.db"
elif computer_id == "buster1": # new pi, will become dearme ??
self.ex_editor = r"mousepad"
elif computer_id == "bulldog": # may be gone
self.ex_editor = r"gedit" # ubuntu
self.db_file_name = "bulldog_db.db"
elif computer_id == "bulldog-mint-russ":
self.ex_editor = r"xed"
self.db_file_name = "bulldog_db.db"
else:
print( f"In parameters: no special settings for computer_id {computer_id}" )
if self.running_on.os_is_win:
self.ex_editor = r"C:\apps\Notepad++\notepad++.exe"
else:
self.ex_editor = r"leafpad" # linux raspberry pi maybe
# -------
def os_tweaks( self ):
"""
this is an subroutine to tweak the default settings of "default_terminal_mode"
for a particular operating systems
you may need/want to mess with this based on your os setup
"""
if self.running_on.os_is_win:
self.port = "COM5" #
self.port_list = [ "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "COM10", ]
else: # linux
print( "linux" )
self.ex_editor = r"leafpad" # linux editor, most common ones are already included, but this would be your first choice(s)
self.port = "/dev/ttyUSB0"
self.port_list = [ "/dev/ttyUSB0",
"/dev/ttyACM0", "/dev/ttyACM1", "/dev/ttyACM2",
"/dev/ttyAMC0", "/dev/ttyAMC1",
"/dev/ttyUSB1",
"/dev/AMA0" ,
]
self.icon = None # default gui icon
self.win_max = True # maximize the window on opening
self.pylogging_fn = "smart_terminal_linux.py_log"
self.bot_spacer_height = 10 # on linux tends to go off screen -- may not show if window not maximized
# # -------
# old replaced by running on tweaks
# def computer_name_tweaks( self ):
# """
# this is an subroutine to tweak the default settings of "default_terminal_mode"
# for particular computers. Put in settings for you computer if you wish
# these are for my computers, add what you want ( or nothing ) for your computers
# """
# if self.computername == "smithers":
# self.port = "COM5" #
# self.port = "COM3" #
# self.win_geometry = '1450x700+20+20' # width x height + position + position --
# self.win_max = True # maximize the window on opening
# self.ex_editor = r"D:\apps\Notepad++\notepad++.exe" # russ win 10 smithers
#
# elif self.computername == "millhouse":
# self.port = "COM4" #
# self.port = "COM5"
# self.ex_editor = r"C:\apps\Notepad++\notepad++.exe" # russ win 10 millhouse
# #self.win_geometry = '1300x600+20+20' # width x height position
# self.pylogging_fn = "millhouse_smart_terminal.py_log" # file name for the python logging
#
# elif self.computername == "theprof":
# self.port = "COM4" #
# self.port = "COM5"
# self.port = "COM3"
# self.ex_editor = r"C:\apps\Notepad++\notepad++.exe" # russ win 10 millhouse
# #self.win_geometry = '1300x600+20+20' # width x height position
# self.pylogging_fn = "theprof_smart_terminal.py_log" # file name for the python logging
# -------
def mode_plus_tests( self ):
"""
add change some parameters just for testing -- use after a normal mode method is called.
"""
self.mode += " + tests"
self.logging_level = logging.DEBUG #INFO
# self.ex_editor = "notepad"
# self.ex_editor = [ "write", "notepad" ]
# self.ex_editor = [ "joe", "notepad" ]
# self.comm_logging_fn = "test_comlog.log"
# ------->> Subroutines: one for each mode. alpha order - except quick_start_mode
def quick_start_mode( self, ):
"""
this mode does not do anything useful except illustrate a simple "mode subroutine"
new users should probably start here
the settings in it are the ones your are most likely to use/change from the defaults
"""
self.mode = "QuickStart" # this name will appear in the title of the window
# to help keep track of which mode you are using
self.baudrate = 19200 # changes the baudrate from the default to 19200
self.port = "COM9" # com port
# the send_ctrls is a list of 3 valued tuples
# for each item in the list you will have a "send button", a button that will send the contents of
# the data entry field to the right of it to your comm port.
# the first item of the tuple is a sting whose test will be on the button
# the second is a string with the initial or default value for the data entry field
# the third is a boolean, True make the data entry field editable, otherwise it is protected from edit
self.send_ctrls = [
# text cmd can edit
( "Send", "", True ),
( "Send", "", True ),
( "Different Title", "default", True ),
( "More Different", "yes different", True ),
]
# you may get extra buttons with default values to fill the space
# you have an option for a pane below the title bar of some size and color, if the height is set
# to zero you do not get this pane
# useful if you have 2 instances of the program running and want an easy way to tell them apart
self.id_height = 5 # height of id pane, 0 for no pane
self.id_color = "red" # "blue" "green" and lots of other work
# color for some of the background of the gui, not particularly useful imho
self.bk_color = "blue" # color for the background, you can match the id color or use a neutral color like gray
#self.bk_color = "gray"
# -------
def accel_demo_mode( self, ):
"""
used in conjunction with my arduino demo of the Accel stepper motor library
"""
self.mode = "AccelDemo"
self.baudrate = 19200 # 9600 19200 38400, 57600, 115200, 128000 and 256000
# 4 DOWN
self.send_ctrls = [
# text cmd can edit
( "Version of Arduino", "v", False ),
( "Help", "?", False ),
( "What Where", "w", False ),
( "Send", "", True ),
( "Acc Set", "a60", True ),
( "Acc Set", "a600 ", True ),
( "Set Top or Max Speed", "t5000", True ),
( "Set Top or Max Speed", "t50000", True ),
( "move To Now nn", "m100", True ),
( "move To Now nn", "m0", True ),
( "move To Now nn", "m-100", True ),
( "Zero current pos", "z", False ),
( "moveToNow nn", "m500", True ),
( "moveToNow nn", "m0", True ),
( "moveToNow nn", "m-500", True ),
( "Zero current pos", "z", False ),
( "Accel Examples 1-3", "e1", True ),
( "Accel Examples 1-3", "e2", True ),
( "Accel Examples 1-3", "e3", True ),
( "Send", "", True ),
( "Send", "", True ),
( "line1 line1 line2 line2 line3 line3 line4 line4 line5", "", True ),
( "line1 line1 line2 line2 line3 line3", "", True ),
]
#self.gui_sends = 15 # number of send frames in the gui beware if 0
self.gui_sends = len( self.send_ctrls )
self.max_send_rows = 4 # the send areas are added in columns this many rows long,
# -------
def controlino_mode( self ):
"""
used in conjunction with my the controlino -- but really adds nothing to the application
"""
self.mode = "Controlino"
# not really implemented just an idea
pass
# -------
def ddclock_mode( self ):
"""
used in conjunction with my arduino ddClock stepper motor clock application
"""
self.mode = "ddclock_mode"
self.baudrate = 19200 # 9600
# ----- various auto start implementation questionable
self.auto_start = None # for auto-starting something in 2nd thread ? !! think obsolete see below
# testing this jan 2018 this function must exist in the helper auto_run
# at time of comment this will be run in the helper thread
#to_eval = "self.ext_processing." + self.parameters.start_helper_function
self.start_helper_function = "auto_run" # now using eval, may need to do same with args,
self.start_helper_args = ( ) # () empty ( "x", ) one element
self.start_helper_delay = 5 # in seconds must be > 0 to start -- may not work for clock yet
self.start_helper = True #
# next may be replaced by above or vice versa sure needs clean up
self.clock_start_mode = "run" # "set_hr" , "set_hr", "run", "run_demo", also need auto connect !! not implemented yet
self.clock_mode = "run" # run_demo run
# ---------------- send area:
self.button_height = 2 # for the send buttons -- seem to be roughly the no of lines
self.button_width = 10 # for the send buttons -- 10-20 seems reasonable starts
self.send_width = 15 # for the text to be sent -- 10-20 seems reasonable starts
self.send_ctrls = [
# text cmd can edit
( "Version of arduino", "v", False ),
( "Help", "?", False ),
( "What Where", "w", False ),
("nudgeMin", "n0 8", True ), #
("nudgeMin", "n0 -8", True ), #
("tweakMin", "t0 2", True ), #
("tweakMin", "t0 -2", True ), #
("chimeMin", "c2 0 5", True ), # case 'q' motor position speed acc
("chimeHr", "c1 0 2", True ), #
# ("chimeMin", "c2 0 30", True ), #
("Send", "", True ),
("Send", "", True ),
]
self.gui_sends = len( self.send_ctrls )
self.max_send_rows = 3 # the send areas are added in columns this many rows long,
# ----- processing related:
self.ext_processing_module = "ext_process_ddc"
self.ext_processing_class = "DDCProcessing"
# next for probing for a valid port with arduino.
self.arduino_connect_delay = 10 # may not be implemented yet
self.get_arduino_version = "v" # # send to the port to get a response from the arduino.
self.arduino_version = "DDClock17" # the response from the arduino should contain this as a substring if the comm port is valid.
#self.begin_demo_dt = None # turns off demo mode -- not so sure
# hr:vv vv:minute ..........
self.begin_demo_dt = datetime.datetime( 2008, 11, 10, 11, 1, 59 ) # should be set to something
self.time_multiplier = 10. # only used in demo mode
#self.time_multiplier = 100.
#self.time_multiplier = 1
self.chime_type = "rotate" # "random" "assigned"
# chime dicts only if assigned self.chime_type if used you need to define all 12
# testing 1 2 3 xxxx
self.hour_chime_dict = { 1:"2", 2:"3", 3:"2", 4:"2", 5:"2", 6:"3", 7:"2", 8:"3", 9:"2", 10:"3", 11:"2", 12:"2" }
# testing xxx 4 x 6 7 8 xxx
self.hour_chime_dict = { 1:"4", 2:"6", 3:"7", 4:"8", 5:"4", 6:"6", 7:"7", 8:"8", 9:"4", 10:"6", 11:"7", 12:"8" }
# not assigned default to 0
self.minute_chime_dict = { 10:"2", 15:"3", 20:"2", 30:"2", 40:"2", 45:"3", 50:"2", 60:"3", } # if not assigned default to 0
# above see arduino program to see which is which
# self.effects_on = True # for the chimes does it work use assigned and assign to 0 0
self.hour_chime_rotate_amt = 1
self.hour_chime_rotate_list = [ "1", "2", "3", "4", "5", "6", "7", "8" ]
self.hour_off = False # for ddc_processing
self.minute_off = False # for ddc_processing
self.minute_chime_max = 1 # !! implement me
self.hour_chime_max = 8 # !! implement me see also _chime_dict
# next based on 1.1 as ratio
self.led_chime_values = {-20: 1, -19: 1.1, -18: 1.2100000000000002, -17: 1.3310000000000004,
-16: 1.4641000000000006, -15: 1.6105100000000008, -14: 1.771561000000001,
-13: 1.9487171000000014, -12: 2.1435888100000016, -11: 2.357947691000002,
-10: 2.5937424601000023, -9: 2.853116706110003, -8: 3.1384283767210035,
-7: 3.4522712143931042, -6: 3.797498335832415, -5: 4.177248169415656,
-4: 4.594972986357222, -3: 5.054470284992944, -2: 5.559917313492239,
-1: 6.115909044841463, 0: 6.72749994932561, 1: 6.115909044841463, 2: 5.559917313492239,
3: 5.054470284992944, 4: 4.594972986357222, 5: 4.177248169415656, 6: 3.7974983358324144,
7: 3.452271214393104, 8: 3.138428376721003, 9: 2.8531167061100025, 10: 2.593742460100002,
11: 2.3579476910000015, 12: 2.143588810000001, 13: 1.9487171000000008,
14: 1.7715610000000006, 15: 1.6105100000000003, 16: 1.4641000000000002,
17: 1.331, 18: 1.21, 19: 1.0999999999999999 }
day_lb = 50
eve_lb = 10
self.led_background_values = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0,
6: day_lb, 7: day_lb, 8:day_lb, 9:day_lb, 10:day_lb, 11: day_lb,
12:day_lb, 13:day_lb, 14:day_lb, 15:day_lb, 16: day_lb, 17: day_lb,
18:eve_lb, 19:eve_lb, 20:eve_lb, 21:eve_lb, 22:eve_lb, 23:eve_lb,
24:eve_lb }
# -------
def ddclock_test_mode( self ):
"""
debug mode for my arduino ddClock stepper motor clock application
may not be maintained
"""
self.mode = "ddclock_test_mode"
self.icon = r"./clock_white.ico"
self.baudrate = 19200 # 9600
self.port = "COM4" # com port
# -------------------------- auto run on off ---------------------
# testing this jan 2018 this function must exist in the helper auto_run
# self.start_helper_function = "auto_run" # now using eval, may need to do same with args,
# self.start_helper_args = ( ) # () empty ( "x", ) one element
# self.start_helper_delay = 5 # in seconds must be > 0 to start -- may not work for clock yet
# self.start_helper = True #
# next may be replaced by above or vice versa
# self.clock_start_mode = "run" # "set_hr" , "set_hr", "run", "run_demo", also need auto connect !! not implemented yet
# ---------------- send area:
self.button_height = 3 # for the send buttons -- seem to be roughly the no of lines
self.button_width = 15 # for the send buttons -- 10-20 seems reasonable starts
self.send_width = 15 # for the text to be sent -- 10-20 seems reasonable starts
# next at end of control list
#self.max_send_rows = 3 # the send areas are added in columns this many rows long, then a new
#self.max_send_rows
# see backup for some test button sets
self.send_ctrls = [
# text cmd can edit
( "Version of arduinoxx", "v", False ),
( "Help", "?", False ),
( "What Where", "w", False ),
( "Send", "", True ),
# ("nudgeHr n1 x", "n1 20", True ), #
# ("nudgeHr n1 x", "n1 -20", True ), #
# ("nudgeHr n1 x", "n1 4", True ), #
# ("nudgeHr n1 x", "n1 -4", True ), #
# ("quick", "q1 12 1000 500", True ), # case 'q' motor position speed acc
# ("quick", "q1 3 1000 500", True ), #
# ("quick", "q1 9 1000 500", True ), #
# ("quick", "q1 50 1000 200", True ), #
# ("nudgeMin", "n0 8", True ), #
("nudgeMin", "n0 -8", True ), #
# ("tweakMin", "t0 2", True ), #
("tweakMin", "t0 -2", True ), #
("danceMin", "d0 50 500 10", True ), # case 'q' motor position speed acc
("danceMin", "d0 1000 500 20", True ), #
("chimeMin", "c2 0 5", True ), # case 'q' motor position speed acc
("danceHr", "d1 50 500 100", True ), # case 'q' motor position speed acc
("chimeHr", "c1 0 3", True ), # case 'q' motor position speed acc
#
("Send", "", True ),
("Send", "", True ),
]
#self.send_ctrls = send_ctrls_test_hr
#self.send_ctrls = send_ctrls_test_min
self.gui_sends = len( self.send_ctrls )
self.max_send_rows = 2 # 4 seems good for the pi the send areas are added in columns this many rows long,
# ----- processing related:
self.ext_processing_module = "ext_process_ddc"
self.ext_processing_class = "DDCProcessing"
self.arduino_connect_delay = 10 # may not be implemented yet
self.get_arduino_version = "v"
self.arduino_version = "DDClock17"
# --------- clock configuration related
self.clock_mode = "run" # run_demo run # hr:vv vv:minute ..........
self.begin_demo_dt = datetime.datetime( 2008, 11, 10, 11, 1, 59 ) # should be set to something
self.time_multiplier = 10. # only used in demo mode
#self.time_multiplier = 100.
#self.time_multiplier = 1
self.chime_type = "random" # "random" "assigned" "rotate"
# probably extend to 24 hours, or make auto doubler? -- try on 24 then back off to 12 ?
# need 12 0 1 3 4 5 6 7 8 9 10 11 12
self.assigned_hour_chime = [ "1", "2", "3", "4", "5", "6", "7", "8", "1", "1", "1", "1", "1", "1", ] # make a dict for consistency ??
self.hour_chime_dict = { 1:"2", 2:"3", 3:"2", 4:"2", 5:"2", 6:"3", 7:"2", 8:"3", 9:"2", 10:"3", 11:"2", 12:"2" } # not assigned default to 0
self.hour_chime_rotate_amt = 1
self.hour_chime_rotate_list = [ "1", "2", "3", "4", "5", "6", "7", "8" ]
self.minute_chime_dict = { 10:"2", 15:"3", 20:"2", 30:"2", 40:"2", 45:"3", 50:"2", 60:"3", } # if not assigned default to 0
# ----- led make helper to give exponential growth, and past in here
# next based on 1.1 as ratio
self.led_chime_values = {-20: 1, -19: 1.1, -18: 1.2100000000000002, -17: 1.3310000000000004,
-16: 1.4641000000000006, -15: 1.6105100000000008, -14: 1.771561000000001,
-13: 1.9487171000000014, -12: 2.1435888100000016, -11: 2.357947691000002,
-10: 2.5937424601000023, -9: 2.853116706110003, -8: 3.1384283767210035,
-7: 3.4522712143931042, -6: 3.797498335832415, -5: 4.177248169415656,
-4: 4.594972986357222, -3: 5.054470284992944, -2: 5.559917313492239,
-1: 6.115909044841463, 0: 6.72749994932561, 1: 6.115909044841463, 2: 5.559917313492239,
3: 5.054470284992944, 4: 4.594972986357222, 5: 4.177248169415656, 6: 3.7974983358324144,
7: 3.452271214393104, 8: 3.138428376721003, 9: 2.8531167061100025, 10: 2.593742460100002,
11: 2.3579476910000015, 12: 2.143588810000001, 13: 1.9487171000000008,
14: 1.7715610000000006, 15: 1.6105100000000003, 16: 1.4641000000000002,
17: 1.331, 18: 1.21, 19: 1.0999999999999999 }
day_lb = 50
eve_lb = 10
self.led_background_values = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0,
6: day_lb, 7: day_lb, 8:day_lb, 9:day_lb, 10:day_lb, 11: day_lb,
12:day_lb, 13:day_lb, 14:day_lb, 15:day_lb, 16: day_lb, 17: day_lb,
18:eve_lb, 19:eve_lb, 20:eve_lb, 21:eve_lb, 22:eve_lb, 23:eve_lb,
24:eve_lb }
# self.effects_on = True # for the chimes does it work use assigned and assign to 0 0
self.hour_off = False
self.minute_off = False
# -------
def ddclock_david( self ):
"""
debug mode for my arduino ddClock stepper motor clock application
may not be maintained
"""
self.mode = "ddclock_david"
self.icon = r"./clock_white.ico"
self.baudrate = 19200 # 9600
self.port = "COM4" # com port
self.logging_level = logging.INFO # CRITICAL 50 ERROR 40 WARNING 30 INFO 20 DEBUG 10 NOTSET 0
self.comm_logging_fn = None # None for no logging else file name like "smart_terminal_comm.log"
# -------------------------- auto run on off ---------------------
# testing this jan 2018 this function must exist in the helper auto_run
# self.start_helper_function = "auto_run" # now using eval, may need to do same with args,
# self.start_helper_args = ( ) # () empty ( "x", ) one element
# self.start_helper_delay = 5 # in seconds must be > 0 to start -- may not work for clock yet
# self.start_helper = True #
# next may be replaced by above or vice versa
# self.clock_start_mode = "run" # "set_hr" , "set_hr", "run", "run_demo", also need auto connect !! not implemented yet
self.start_helper_function = "auto_run" # now using eval, may need to do same with args,
self.start_helper_args = ( ) # () empty ( "x", ) one element
self.start_helper_delay = 5 # in seconds must be > 0 to start -- may not work for clock yet
self.start_helper = True #
# ---------------- send area:
self.button_height = 3 # for the send buttons -- seem to be roughly the no of lines
self.button_width = 15 # for the send buttons -- 10-20 seems reasonable starts
self.send_width = 15 # for the text to be sent -- 10-20 seems reasonable starts
# next at end of control list
#self.max_send_rows = 3 # the send areas are added in columns this many rows long, then a new
#self.max_send_rows
# see backup for some test button sets
self.send_ctrls = [
# text cmd can edit
( "Version of arduino", "v", False ),
( "Help", "?", False ),
( "What Where", "w", False ),
( "Send", "", True ),
("danceMin", "d0 50 500 10", True ), # case 'q' motor position speed acc
("danceMin", "d0 1000 500 20", True ), #
("chimeMin", "c2 0 5", True ), # case 'q' motor position speed acc
("danceHr", "d1 50 500 100", True ), # case 'q' motor position speed acc
("chimeHr", "c1 0 3", True ), # case 'q' motor position speed acc
#
("Send", "", True ),
("Send", "", True ),
]
self.gui_sends = len( self.send_ctrls )
self.max_send_rows = 2 # 4 seems good for the pi the send areas are added in columns this many rows long,
# ----- processing related:
self.ext_processing_module = "ext_process_ddc"
self.ext_processing_class = "DDCProcessing"
self.arduino_connect_delay = 10 # may not be implemented yet
self.get_arduino_version = "v"
self.arduino_version = "DDClock17"
self.clock_start_mode = "run" # "set_hr" , "set_hr", "run", "run_demo", also need auto connect !! not implemented yet
# --------- clock configuration related
self.clock_mode = "run" # run_demo run # hr:vv vv:minute ..........
self.begin_demo_dt = datetime.datetime( 2008, 11, 10, 11, 1, 59 ) # should be set to something
self.time_multiplier = 10. # only used in demo mode
#self.time_multiplier = 100.
#self.time_multiplier = 1
self.chime_type = "rotate" # "random" # "random" "assigned" "rotate"
# probably extend to 24 hours, or make auto doubler? -- try on 24 then back off to 12 ?
# need 12 0 1 3 4 5 6 7 8 9 10 11 12
self.assigned_hour_chime = [ "1", "2", "3", "4", "5", "6", "7", "8", "1", "1", "1", "1", "1", "1", ] # make a dict for consistency ??
self.hour_chime_dict = { 1:"2", 2:"3", 3:"2", 4:"2", 5:"2", 6:"3", 7:"2", 8:"3", 9:"2", 10:"3", 11:"2", 12:"2" } # not assigned default to 0
self.hour_chime_rotate_amt = 1
self.hour_chime_rotate_list = [ "1", "2", "3", "4", "5", "6", "7", "8" ]
self.minute_chime_dict = { 10:"2", 15:"3", 20:"2", 30:"2", 40:"2", 45:"3", 50:"2", 60:"3", } # if not assigned default to 0
# ----- led make helper to give exponential growth, and past in here
# next based on 1.1 as ratio
self.led_chime_values = {-20: 1, -19: 1.1, -18: 1.2100000000000002, -17: 1.3310000000000004,
-16: 1.4641000000000006, -15: 1.6105100000000008, -14: 1.771561000000001,
-13: 1.9487171000000014, -12: 2.1435888100000016, -11: 2.357947691000002,
-10: 2.5937424601000023, -9: 2.853116706110003, -8: 3.1384283767210035,
-7: 3.4522712143931042, -6: 3.797498335832415, -5: 4.177248169415656,
-4: 4.594972986357222, -3: 5.054470284992944, -2: 5.559917313492239,
-1: 6.115909044841463, 0: 6.72749994932561, 1: 6.115909044841463, 2: 5.559917313492239,
3: 5.054470284992944, 4: 4.594972986357222, 5: 4.177248169415656, 6: 3.7974983358324144,
7: 3.452271214393104, 8: 3.138428376721003, 9: 2.8531167061100025, 10: 2.593742460100002,
11: 2.3579476910000015, 12: 2.143588810000001, 13: 1.9487171000000008,
14: 1.7715610000000006, 15: 1.6105100000000003, 16: 1.4641000000000002,
17: 1.331, 18: 1.21, 19: 1.0999999999999999 }
day_lb = 50
eve_lb = 10
self.led_background_values = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0,
6: day_lb, 7: day_lb, 8:day_lb, 9:day_lb, 10:day_lb, 11: day_lb,
12:day_lb, 13:day_lb, 14:day_lb, 15:day_lb, 16: day_lb, 17: day_lb,
18:eve_lb, 19:eve_lb, 20:eve_lb, 21:eve_lb, 22:eve_lb, 23:eve_lb,
24:eve_lb }
# self.effects_on = True # for the chimes does it work use assigned and assign to 0 0
self.hour_off = False
self.minute_off = False
# --------------------------
def deer_me_dev( self ):
"""
to scare away the deer
this is for development probably on the professor
"""
self.mode = "deer_me_dev"
self.icon = r"./my_dear_icon_2.ico"
# deer_me counts on this being .1 sec, or else major changes will be required
self.ht_delta_t = 100/1000. # thought this was required timing for deer me but seems not so
self.logging_level = logging.DEBUG # CRITICAL 50 ERROR 40 WARNING 30 INFO 20 DEBUG 10 NOTSET 0
self.baudrate = 38400 # 9600 38400
self.port = "COM5" # com port
self.logging_level = logging.DEBUG # CRITICAL 50 ERROR 40 WARNING 30 INFO 20 DEBUG 10 NOTSET 0
self.comm_logging_fn = None # None for no logging else file name like "smart_terminal_comm.log"
# -------------------------- auto run on off ---------------------
self.start_helper_function = "auto_run" # now using eval, may need to do same with args,
self.start_helper_args = ( ) # () empty ( "x", ) one element
self.start_helper_delay = -5 # in seconds must be > 0 to start
# ---------------- send area:
self.button_height = 3 # for the send buttons -- seem to be roughly the no of lines
self.button_width = 15 # for the send buttons -- 10-20 seems reasonable starts
self.send_width = 15 # for the text to be sent -- 10-20 seems reasonable starts
# next at end of control list
#self.max_send_rows = 3 # the send areas are added in columns this many rows long, then a new
#self.max_send_rows
# see backup for some test button sets
# refresh this list form time to time
#define TIME_ON 0 // this is a time, delta time, for th light to be on
#define ACC_ON 1 // some sort of ( depending on method ) acceleration for the TIME_ON
#define TIME_OFF 2 // analogous to TIME_ON, but for off
#define ACC_OFF 3 //
#define REPEATS 4 // number of time this cycle can repeat, this may not make sense
#define PIN 5 // pin used by this light
#define STATE 6 // current state
#define NEXT_TIME 7 // next time the state changes
self.send_ctrls = [
# text cmd can edit
( "Version of arduino", "v", False ),
( "Help", "h", False ),
( "Set Light Index", "i0", False ),
( "Set Light Index", "i1", False ),
( "Load Light I", "l100 200 130 400", True ),
( "Load Light I", "l105 200 130 400", True ),
( "Print Light I", "p" , False ),
( "Strobe", "s1" , False ),
( "Strobe Not", "s0" , False ),
( "Stop", "!xx" , False ),
( "Send", "", True ),
( "Send", "", True ),
]
self.gui_sends = len( self.send_ctrls )
self.max_send_rows = 2 # 4 seems good for the pi the send areas are added in columns this many rows long,
# ----- processing related:
self.ext_processing_module = "ext_process_dm"
self.ext_processing_class = "DMProcessing"
self.arduino_connect_delay = 10 # may not be implemented yet
self.get_arduino_version = "v"
self.arduino_version = "DeerMe"
# --------------------------
def deer_me_pi_deploy( self ):
"""
to scare away the deer
this is for deployment on the raspberry pi deer_me
"""
self.mode = "deer_me_pi_deploy"
self.icon = r"./my_dear_icon_2.ico"
# deer_me counts on this being .1 sec, or else major changes will be required
self.ht_delta_t = 100/1000. # thought this was required timing for deer me but seems not so
self.logging_level = logging.DEBUG # CRITICAL 50 ERROR 40 WARNING 30 INFO 20 DEBUG 10 NOTSET 0
self.baudrate = 38400 # 9600 38400
self.port = "COM5" # com port
self.logging_level = logging.DEBUG # CRITICAL 50 ERROR 40 WARNING 30 INFO 20 DEBUG 10 NOTSET 0
self.comm_logging_fn = None # None for no logging else file name like "smart_terminal_comm.log"
# -------------------------- auto run on off ---------------------
self.start_helper_function = "auto_run" # now using eval, may need to do same with args,
self.start_helper_args = ( ) # () empty ( "x", ) one element
self.start_helper_delay = -5 # in seconds must be > 0 to start
# ---------------- send area:
self.button_height = 3 # for the send buttons -- seem to be roughly the no of lines
self.button_width = 15 # for the send buttons -- 10-20 seems reasonable starts
self.send_width = 15 # for the text to be sent -- 10-20 seems reasonable starts
# next at end of control list
#self.max_send_rows = 3 # the send areas are added in columns this many rows long, then a new
#self.max_send_rows
# see backup for some test button sets
# refresh this list form time to time
#define TIME_ON 0 // this is a time, delta time, for th light to be on
#define ACC_ON 1 // some sort of ( depending on method ) acceleration for the TIME_ON
#define TIME_OFF 2 // analogous to TIME_ON, but for off
#define ACC_OFF 3 //
#define REPEATS 4 // number of time this cycle can repeat, this may not make sense
#define PIN 5 // pin used by this light
#define STATE 6 // current state
#define NEXT_TIME 7 // next time the state changes
self.send_ctrls = [
# text cmd can edit
( "Version of arduino", "v", False ),
( "Help", "h", False ),
( "Set Light Index", "i0", False ),
( "Set Light Index", "i1", False ),
( "Load Light I", "l100 200 130 400", True ),
( "Load Light I", "l105 200 130 400", True ),
( "Print Light I", "p" , False ),
( "Strobe", "s1" , False ),
( "Strobe Not", "s0" , False ),
( "Stop", "!xx" , False ),
( "Send", "", True ),
( "Send", "", True ),
]
self.gui_sends = len( self.send_ctrls )
self.max_send_rows = 2 # 4 seems good for the pi the send areas are added in columns this many rows long,
# ----- processing related:
self.ext_processing_module = "ext_process_dm"
self.ext_processing_class = "DMProcessing"
self.arduino_connect_delay = 10 # may not be implemented yet
self.get_arduino_version = "v"
self.arduino_version = "DeerMe"
# -------
def infra_red_mode( self ):
"""
not currently runnable, some details need fixing to get from 2.7 to 3.6
support for my arduino infra red analysis application application
"""
self.mode = "InfraRed"
self.ext_processing_module = "ext_process_ir"
self.ext_processing_class = "IRProcessing"
# -------
def green_house_mode( self ):
"""
used in conjunction with my arduino green house monitor application
"""
self.mode = "GreenHouse"
self.icon = r"./green_house.ico" # greenhouse this has issues on rasPi
self.baudrate = 38400 #
self.ext_processing_module = "ext_process_env_monitor"
self.ext_processing_class = "ProcessingForEnv"
self.logging_level = logging.ERROR # CRITICAL 50 ERROR 40 WARNING 30 INFO 20 DEBUG 10 NOTSET 0
if self.running_on.our_os == "win32":
self.dbRtoPi188()
#self.dbLPi()
else:
self.dbLtoPi191()
self.send_ctrls = [
("Version", "v", False ),
#("Report", "r", False ),
("Help", "w", False ),
("Aquire", "a", False ),
("Temp.", "t", False ),
("Humid.", "h", False ),
("Light", "l", False ),
("Send", "", True ),("Send", "", True ),("Send", "", True ),
#("Send", "", True ),("Send", "", True ),("Send", "", True ),("Send", "", True ),("Send", "", True ),("Send", "", True ),
]
self.gui_sends = 15 # number of send frames in the gui beware if 0
self.gui_sends = len( self.send_ctrls ) # number of send frames in the gui beware if 0
self.max_send_rows = 3 # the send areas are added in columns this many rows long, then a new
self.arduino_connect_delay = 10 # may not be implemented yet
self.get_arduino_version = "v"
self.arduino_version = "GreenHouse"
# ----- data valid and db update rules -------------------
self.db_max_delta_time = 15. # max time between postings
self.db_max_delta_time = 100. # max time between postings
self.db_min_delta_time = 50. # min time between postings
self.get_cpu_temp = True
self.db_delat_temp = 2. # max temperature change between postings
self.db_delat_temp = 0.5 # max temperature change between postings
self.db_temp_len = 20 # number of value to average -- is this working ??
# !! more
self.db_humid_delta = 2.
self.db_humid_len = 16
self.db_light_len = 16
self.db_light_delta = 2.
self.db_press_len = 0 # no pressure measurements
# for door not clear what meaning these might have look at processing
self.db_door_len = 1
self.db_door_delta = 1.
# for pressure will be replaced
self.run_ave_len = 6 # length of the pressure running average name seems wrong
self.db_press_delta = 2. # max pressure change between postings
self.monitor_loop_delay = 10
# -------
def motor_driver_mode( self ):
"""
used in conjunction with my arduino multiphase motor application
"""
self.mode = "MotorDriver"
self.ext_processing_module = "ext_process_motor"
self.ext_processing_class = "MotorProcessing"
self.send_ctrls = [
"v", "z", "g200", "n",
( "Forward", "d+", False ),
( "Back", "d-", False ),
"l", "r", "h",
"p0", "n", "g40",
"m5", "u5", "w50", "w150",
"r"
]
self.gui_sends = len( self.send_ctrls )
# -------
def root_cellar_mode( self ):
"""
used in conjunction with my arduino green house monitor application
"""
self.green_house_mode( ) # default these then tweak
self.mode = "RootCellar"
self.ext_processing_module = "ext_process_env_monitor"
self.ext_processing_class = "ProcessingForEnv"
self.arduino_version = "RootCellar"
self.no_temps = 3
self.no_humids = 1
self.no_lights = 1
self.no_doors = 4
self.logging_level = logging.DEBUG # CRITICAL 50 ERROR 40 WARNING 30 INFO 20 DEBUG 10 NOTSET 0
# copied from dd clock mar 2018 should work
# at time of comment this will be run in the helper thread
#to_eval = "self.ext_processing." + self.parameters.start_helper_function
self.start_helper_function = "find_and_monitor_arduino" # now using eval, may need to do same with args,
self.start_helper_args = ( ) # () empty ( "x", ) one element
self.start_helper_delay = 5 # in seconds must be > 0 to start -- may not work for clock yet
self.start_helper = False # this may be obsolete
if self.running_on.our_os == "win32":
self.dbRtoPi191() # this probably will not work as system now stands
else:
self.dbLtoPi191()
# -------
def serial_cmd_test( self ):
"""
to test the arduino serial cmd interface
used in conjunction with my arduino serial command application
"""
self.mode = "serial_cmd_test"
# add icon here
self.baudrate = 115200 # 9600 38400 19200 115200
self.send_ctrls = [
# button title send_what can_edit
("Version", "v", False ),
("Help", "h", False ),
("Report All", "r", False ),
("Print Alphabet", "a", False ),
("Convert (not in lib)", "c22", True ),
("Echo nn (in lib)", "e123456", True ),
("Echo nn (in lib)", "e 654321", True ),
("Echo nn (in lib)", "e -654321", True ),
("Get Args qn n", "q5 6 7", True ),
("Get Args qn n", "q5 654321 7", True ),
("Get Args qn n", "q5 -70 99 -3", True ),
("Get Args qn n", "q5 6 7", True ),
("set Micro Sec nn", "u22", True ),
("set Mili Sec nn", "m 65", True ),
("Blink nn times", "b33", True ),
("Pulse N Times", "p99", True ),
("XBlink nn", "x2", True ),
("Spew", "s", False ), # self.gt_delta_t may outrun terminal look at its polling speeds