Skip to content

Commit e93f9c2

Browse files
committed
Generate Settings data from py
1 parent 3d331aa commit e93f9c2

File tree

5 files changed

+414
-0
lines changed

5 files changed

+414
-0
lines changed

source/Settings/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# IronOS Settings management
2+
3+
To make working with settings easier, this folder contains a easier to read definitions file for the settings in the firmware.
4+
Utility scripts are provided to work with this file.
5+
6+
## Reading the existing settings from a device
7+
8+
This is only supported with devices that allow reading the device memory back out over USB. This **DOES NOT** work if your device shows up as a USB storage device when in programming mode.
9+
10+
## Writing settings in one go to a device

source/Settings/edit_settings.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#! python3
2+
import yaml
3+
from typing import List
4+
import os
5+
6+
7+
class SettingsEntry:
8+
def __init__(self, min, max, increment, default):
9+
self.min = min
10+
self.max = max
11+
self.increment = increment
12+
self.default = default
13+
14+
15+
class Settings:
16+
settings:List[SettingsEntry] = []
17+
18+
19+
def load_settings(file_path):
20+
with open(file_path, 'r') as f:
21+
data = yaml.safe_load(f)
22+
settings_obj = Settings()
23+
settings_obj.settings = data['settings']
24+
return settings_obj
25+
26+
27+
settings_data = load_settings( 'settings.yaml')
28+
29+
"""
30+
If the user has provided a settings binary dump, we load it and update the settings data
31+
If the user has requested to edit the settings, we provide a menu to edit each setting
32+
"""

source/Settings/generate_settings.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#! python3
2+
import yaml
3+
from typing import List
4+
import os
5+
6+
SETTINGS_OUTPUT_PATH = os.path.join(os.path.dirname(__file__), '../Core/Gen/settings_gen.cpp')
7+
8+
class SettingsEntry:
9+
def __init__(self, min, max, increment, default):
10+
self.min = min
11+
self.max = max
12+
self.increment = increment
13+
self.default = default
14+
15+
16+
class Settings:
17+
settings:List[SettingsEntry] = []
18+
19+
20+
def load_settings(file_path):
21+
with open(file_path, 'r') as f:
22+
data = yaml.safe_load(f)
23+
settings_obj = Settings()
24+
settings_obj.settings = data['settings']
25+
return settings_obj
26+
27+
def save_settings(settings_obj, file_path):
28+
with open(file_path, 'w') as f:
29+
yaml.dump(settings_obj.__dict__, f, indent=2)
30+
31+
32+
def convert_settings_to_cpp(settings_obj):
33+
cpp_code = ""
34+
for setting in settings_obj.settings:
35+
36+
cpp_code += f" {{ {setting['min']:>22}, {setting['max']:>70}, {setting['increment']:>18}, {setting['default']:>29}}}, // {setting['name']}\r\n"
37+
return cpp_code
38+
39+
40+
"""
41+
Load the settings definitions yaml file, this is used to then generate the settings_gen.cpp file.
42+
"""
43+
44+
settings_data = load_settings( 'settings.yaml')
45+
cpp_code = convert_settings_to_cpp(settings_data)
46+
with open("settings_gen.cpp.template", 'r') as f:
47+
template_content = f.read()
48+
with open(SETTINGS_OUTPUT_PATH, 'w') as f:
49+
f.write(template_content.replace("$SETTINGSTABLE", cpp_code))

source/Settings/settings.yaml

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
settings:
2+
- default: SOLDERING_TEMP
3+
increment: 5
4+
max: MAX_TEMP_F
5+
min: MIN_TEMP_C
6+
name: SolderingTemp
7+
- default: 150
8+
increment: 5
9+
max: MAX_TEMP_F
10+
min: MIN_TEMP_C
11+
name: SleepTemp
12+
- default: SLEEP_TIME
13+
increment: 1
14+
max: 15
15+
min: 0
16+
name: SleepTime
17+
- default: CUT_OUT_SETTING
18+
increment: 1
19+
max: 4
20+
min: 0
21+
name: MinDCVoltageCells
22+
- default: RECOM_VOL_CELL
23+
increment: 1
24+
max: 38
25+
min: 24
26+
name: MinVoltageCells
27+
- default: 90
28+
increment: 2
29+
max: QC_VOLTAGE_MAX
30+
min: 90
31+
name: QCIdealVoltage
32+
- default: ORIENTATION_MODE
33+
increment: 1
34+
max: MAX_ORIENTATION_MODE
35+
min: 0
36+
name: OrientationMode
37+
- default: SENSITIVITY
38+
increment: 1
39+
max: 9
40+
min: 0
41+
name: Sensitivity
42+
- default: ANIMATION_LOOP
43+
increment: 1
44+
max: 1
45+
min: 0
46+
name: AnimationLoop
47+
- default: ANIMATION_SPEED
48+
increment: 1
49+
max: settingOffSpeed_t::MAX_VALUE - 1
50+
min: 0
51+
name: AnimationSpeed
52+
- default: AUTO_START_MODE
53+
increment: 1
54+
max: 3
55+
min: 0
56+
name: AutoStartMode
57+
- default: SHUTDOWN_TIME
58+
increment: 1
59+
max: 60
60+
min: 0
61+
name: ShutdownTime
62+
- default: COOLING_TEMP_BLINK
63+
increment: 1
64+
max: 1
65+
min: 0
66+
name: CoolingTempBlink
67+
- default: DETAILED_IDLE
68+
increment: 1
69+
max: 1
70+
min: 0
71+
name: DetailedIDLE
72+
- default: DETAILED_SOLDERING
73+
increment: 1
74+
max: 1
75+
min: 0
76+
name: DetailedSoldering
77+
- default: TEMPERATURE_INF
78+
increment: 1
79+
max: "(uint16_t)(HasFahrenheit ? 1 : 0)"
80+
min: 0
81+
name: TemperatureInF
82+
- default: DESCRIPTION_SCROLL_SPEED
83+
increment: 1
84+
max: 1
85+
min: 0
86+
name: DescriptionScrollSpeed
87+
- default: LOCKING_MODE
88+
increment: 1
89+
max: 2
90+
min: 0
91+
name: LockingMode
92+
- default: POWER_PULSE_DEFAULT
93+
increment: 1
94+
max: 99
95+
min: 0
96+
name: KeepAwakePulse
97+
- default: POWER_PULSE_WAIT_DEFAULT
98+
increment: 1
99+
max: POWER_PULSE_WAIT_MAX
100+
min: 1
101+
name: KeepAwakePulseWait
102+
- default: POWER_PULSE_DURATION_DEFAULT
103+
increment: 1
104+
max: POWER_PULSE_DURATION_MAX
105+
min: 1
106+
name: KeepAwakePulseDuration
107+
- default: VOLTAGE_DIV
108+
increment: 1
109+
max: 900
110+
min: 360
111+
name: VoltageDiv
112+
- default: BOOST_TEMP
113+
increment: 10
114+
max: MAX_TEMP_F
115+
min: 0
116+
name: BoostTemp
117+
- default: CALIBRATION_OFFSET
118+
increment: 1
119+
max: 2500
120+
min: MIN_CALIBRATION_OFFSET
121+
name: CalibrationOffset
122+
- default: POWER_LIMIT
123+
increment: POWER_LIMIT_STEPS
124+
max: MAX_POWER_LIMIT
125+
min: 0
126+
name: PowerLimit
127+
- default: REVERSE_BUTTON_TEMP_CHANGE
128+
increment: 1
129+
max: 1
130+
min: 0
131+
name: ReverseButtonTempChangeEnabled
132+
- default: TEMP_CHANGE_LONG_STEP
133+
increment: 5
134+
max: TEMP_CHANGE_LONG_STEP_MAX
135+
min: 5
136+
name: TempChangeLongStep
137+
- default: TEMP_CHANGE_SHORT_STEP
138+
increment: 1
139+
max: TEMP_CHANGE_SHORT_STEP_MAX
140+
min: 1
141+
name: TempChangeShortStep
142+
- default: 7
143+
increment: 1
144+
max: 9
145+
min: 0
146+
name: HallEffectSensitivity
147+
- default: 0
148+
increment: 1
149+
max: 9
150+
min: 0
151+
name: AccelMissingWarningCounter
152+
- default: 0
153+
increment: 1
154+
max: 9
155+
min: 0
156+
name: PDMissingWarningCounter
157+
- default: 41431 /*EN*/
158+
increment: 0
159+
max: 0xFFFF
160+
min: 0
161+
name: UILanguage
162+
- default: 20
163+
increment: 1
164+
max: 50
165+
min: 0
166+
name: PDNegTimeout
167+
- default: 0
168+
increment: 1
169+
max: 1
170+
min: 0
171+
name: OLEDInversion
172+
- default: DEFAULT_BRIGHTNESS
173+
increment: BRIGHTNESS_STEP
174+
max: MAX_BRIGHTNESS
175+
min: MIN_BRIGHTNESS
176+
name: OLEDBrightness
177+
- default: 1
178+
increment: 1
179+
max: 6
180+
min: 0
181+
name: LOGOTime
182+
- default: 0
183+
increment: 1
184+
max: 1
185+
min: 0
186+
name: CalibrateCJC
187+
- default: 0
188+
increment: 1
189+
max: 1
190+
min: 0
191+
name: BluetoothLE
192+
- default: 0
193+
increment: 1
194+
max: 2
195+
min: 0
196+
name: USBPDMode
197+
- default: 4
198+
increment: 1
199+
max: 5
200+
min: 1
201+
name: ProfilePhases
202+
- default: 90
203+
increment: 5
204+
max: MAX_TEMP_F
205+
min: MIN_TEMP_C
206+
name: ProfilePreheatTemp
207+
- default: 1
208+
increment: 1
209+
max: 10
210+
min: 1
211+
name: ProfilePreheatSpeed
212+
- default: 130
213+
increment: 5
214+
max: MAX_TEMP_F
215+
min: MIN_TEMP_C
216+
name: ProfilePhase1Temp
217+
- default: 90
218+
increment: 5
219+
max: 180
220+
min: 10
221+
name: ProfilePhase1Duration
222+
- default: 140
223+
increment: 5
224+
max: MAX_TEMP_F
225+
min: MIN_TEMP_C
226+
name: ProfilePhase2Temp
227+
- default: 30
228+
increment: 5
229+
max: 180
230+
min: 10
231+
name: ProfilePhase2Duration
232+
- default: 165
233+
increment: 5
234+
max: MAX_TEMP_F
235+
min: MIN_TEMP_C
236+
name: ProfilePhase3Temp
237+
- default: 30
238+
increment: 5
239+
max: 180
240+
min: 10
241+
name: ProfilePhase3Duration
242+
- default: 140
243+
increment: 5
244+
max: MAX_TEMP_F
245+
min: MIN_TEMP_C
246+
name: ProfilePhase4Temp
247+
- default: 30
248+
increment: 5
249+
max: 180
250+
min: 10
251+
name: ProfilePhase4Duration
252+
- default: 90
253+
increment: 5
254+
max: MAX_TEMP_F
255+
min: MIN_TEMP_C
256+
name: ProfilePhase5Temp
257+
- default: 30
258+
increment: 5
259+
max: 180
260+
min: 10
261+
name: ProfilePhase5Duration
262+
- default: 2
263+
increment: 1
264+
max: 10
265+
min: 1
266+
name: ProfileCooldownSpeed
267+
- default: 0
268+
increment: 1
269+
max: 12
270+
min: 0
271+
name: HallEffectSleepTime
272+
- default: 0
273+
increment: 1
274+
max: "(tipType_t::TIP_TYPE_MAX - 1) > 0 ? (tipType_t::TIP_TYPE_MAX - 1) : 0"
275+
min: 0
276+
name: SolderingTipType
277+
- default: 0
278+
increment: 1
279+
max: 1
280+
min: 0
281+
name: ReverseButtonSettings

0 commit comments

Comments
 (0)