28
28
29
29
30
30
@property
31
- def throttle_effect (self ):
32
- """The furtherest the throttle effect can randomly set the widget value relative
31
+ def fluctuation_amplitude (self ):
32
+ """The furtherest the fluctuation effect can randomly set the widget value relative
33
33
to its true position, in either direction.
34
34
"""
35
- return self ._throttle_setting
35
+ return self ._fluctuation_amplitude
36
36
37
37
38
- @throttle_effect .setter
39
- def throttle_effect (self , setting ):
38
+ @fluctuation_amplitude .setter
39
+ def fluctuation_amplitude (self , setting ):
40
40
if setting < 0 :
41
- raise ValueError ("Throttle effect setting must be larger than 0" )
41
+ raise ValueError ("Fluctuation effect setting must be larger than 0" )
42
42
if setting :
43
- self ._throttle_hold_value = getattr (self , self ._value_name )
44
- self ._throttle_setting = setting
43
+ self ._fluctuation_hold_value = getattr (self , self ._value_name )
44
+ self ._fluctuation_amplitude = setting
45
45
46
46
47
47
@property
48
- def throttle_effect_move_rate (self ):
49
- """The speed at which the throttle effect moves the widget vaalue
48
+ def fluctuation_move_rate (self ):
49
+ """The speed at which the fluctuation effect moves the widget vaalue
50
50
per update"""
51
51
52
- return self ._throttle_move_rate
52
+ return self ._fluctuation_move_rate
53
53
54
54
55
- @throttle_effect_move_rate .setter
56
- def throttle_effect_move_rate (self , rate ):
57
- self ._throttle_move_rate = rate
55
+ @fluctuation_move_rate .setter
56
+ def fluctuation_move_rate (self , rate ):
57
+ self ._fluctuation_move_rate = rate
58
58
59
59
60
- def throttle_update (self ):
61
- """Updates the widget value and propagates the throttle effect refresh"""
60
+ def update_fluctuation (self ):
61
+ """Updates the widget value and propagates the fluctuation effect refresh"""
62
62
63
- if self ._throttle_setting == 0 :
64
- self ._throttle_destination = None
63
+ if self ._fluctuation_amplitude == 0 :
64
+ self ._fluctuation_destination = None
65
65
return
66
66
67
- if self ._throttle_destination in (None , self ._throttle_hold_value ):
68
- limit_bound = self ._throttle_setting * 10
69
- self ._throttle_destination = (
70
- random .uniform (- limit_bound , limit_bound ) / 10 + self ._throttle_hold_value
67
+ if self ._fluctuation_destination in (None , self ._fluctuation_hold_value ):
68
+ limit_bound = self ._fluctuation_amplitude * 10
69
+ self ._fluctuation_destination = (
70
+ random .uniform (- limit_bound , limit_bound ) / 10 + self ._fluctuation_hold_value
71
71
)
72
72
73
73
value = getattr (self , self ._value_name )
74
74
value = (
75
- value + self ._throttle_move_rate
76
- if self ._throttle_destination > value
77
- else value - self ._throttle_move_rate
75
+ value + self ._fluctuation_move_rate
76
+ if self ._fluctuation_destination > value
77
+ else value - self ._fluctuation_move_rate
78
78
)
79
79
setattr (self , self ._value_name , value )
80
80
81
81
threshold_check = (
82
- value >= self ._throttle_destination
83
- if self ._throttle_destination >= self ._throttle_hold_value
84
- else value <= self ._throttle_destination
82
+ value >= self ._fluctuation_destination
83
+ if self ._fluctuation_destination >= self ._fluctuation_hold_value
84
+ else value <= self ._fluctuation_destination
85
85
)
86
86
if threshold_check :
87
- self ._throttle_destination = self ._throttle_hold_value
87
+ self ._fluctuation_destination = self ._fluctuation_hold_value
88
88
89
89
90
- def hook_throttle_effect (widget_class , value_name ):
90
+ def hook_fluctuation_effect (widget_class , value_name ):
91
91
"""Adds the throttle effect for the given classes
92
92
93
93
:param widget_classes: The widgets that should have this effect hooked
@@ -103,18 +103,18 @@ def hook_throttle_effect(widget_class, value_name):
103
103
from displayio_dial import Dial
104
104
from displayio_effects import throttle_effect
105
105
106
- throttle_effect.hook_throttle_effect (Dial, "value")
106
+ fluctuation_effect.hook_fluctuation_effect (Dial, "value")
107
107
108
108
"""
109
109
110
110
setattr (widget_class , "_value_name" , value_name )
111
111
112
- setattr (widget_class , "_throttle_destination " , None )
113
- setattr (widget_class , "_throttle_value " , 0 )
112
+ setattr (widget_class , "_fluctuation_destination " , None )
113
+ setattr (widget_class , "_fluctuation_hold_value " , 0 )
114
114
115
- setattr (widget_class , "throttle_effect " , throttle_effect )
116
- setattr (widget_class , "_throttle_effect " , 0 )
117
- setattr (widget_class , "throttle_effect_move_rate " , throttle_effect_move_rate )
118
- setattr (widget_class , "_throttle_move_rate " , 0.1 )
115
+ setattr (widget_class , "fluctuation_amplitude " , fluctuation_amplitude )
116
+ setattr (widget_class , "_fluctuation_amplitude " , 0 )
117
+ setattr (widget_class , "fluctuation_move_rate " , fluctuation_move_rate )
118
+ setattr (widget_class , "_fluctuation_move_rate " , 0.1 )
119
119
120
- setattr (widget_class , "throttle_update " , throttle_update )
120
+ setattr (widget_class , "update_fluctuation " , update_fluctuation )
0 commit comments