mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-20 05:04:44 +01:00
added code gen for stuff related to icons ids
This commit is contained in:
@@ -199,43 +199,7 @@ The following message can be used to update the content on the cardEntities Page
|
|||||||
|
|
||||||
# Icons IDs
|
# Icons IDs
|
||||||
|
|
||||||
ID | Icon
|
Please see Icon's int the [icons.md file](icons.md)
|
||||||
-- | ----
|
|
||||||
0 | 
|
|
||||||
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 | 
|
|
||||||
|
|
||||||
# Design Guidelines for Nextion HMI Project
|
# Design Guidelines for Nextion HMI Project
|
||||||
|
|
||||||
|
|||||||
25592
HMI/code_gen/icons/icons.json
Normal file
25592
HMI/code_gen/icons/icons.json
Normal file
File diff suppressed because it is too large
Load Diff
93
HMI/code_gen/icons/icons.py
Normal file
93
HMI/code_gen/icons/icons.py
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
icons = [
|
||||||
|
"window-open",
|
||||||
|
"lightbulb",
|
||||||
|
"thermometer",
|
||||||
|
"gesture-tap-button",
|
||||||
|
"flash",
|
||||||
|
"music",
|
||||||
|
"check-circle-outline",
|
||||||
|
"close-circle-outline",
|
||||||
|
"pause",
|
||||||
|
"play",
|
||||||
|
"palette",
|
||||||
|
"alert-circle-outline",
|
||||||
|
"weather-cloudy",
|
||||||
|
"weather-fog",
|
||||||
|
"weather-hail",
|
||||||
|
"weather-lightning",
|
||||||
|
"weather-lightning-rainy",
|
||||||
|
"weather-night",
|
||||||
|
"weather-partly-cloudy",
|
||||||
|
"weather-pouring",
|
||||||
|
"weather-rainy",
|
||||||
|
"weather-snowy",
|
||||||
|
"weather-snowy-rainy",
|
||||||
|
"weather-sunny",
|
||||||
|
"weather-windy",
|
||||||
|
"weather-windy-variant",
|
||||||
|
"water-percent",
|
||||||
|
"power",
|
||||||
|
"fire",
|
||||||
|
"calendar-sync",
|
||||||
|
"fan",
|
||||||
|
"snowflake",
|
||||||
|
"solar-power",
|
||||||
|
"battery-charging-medium",
|
||||||
|
"battery-medium"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
__location__ = os.path.realpath(
|
||||||
|
os.path.join(os.getcwd(), os.path.dirname(__file__)))
|
||||||
|
|
||||||
|
with open(os.path.join(__location__, "icons.json"),'r') as f:
|
||||||
|
icon_metadata = json.load(f)
|
||||||
|
|
||||||
|
icon_nextion_string = ""
|
||||||
|
icon_name_list = []
|
||||||
|
|
||||||
|
for icon_name in icons:
|
||||||
|
#print(icon_name)
|
||||||
|
icon = next((item for item in icon_metadata if item["name"] == icon_name), None)
|
||||||
|
if icon == None:
|
||||||
|
print(f"WARNING ICON NOT FOUND: {icon_name}")
|
||||||
|
else:
|
||||||
|
hex = icon['hex']
|
||||||
|
s = int(hex, 16)
|
||||||
|
#print(chr(s), end = '')
|
||||||
|
icon_nextion_string += chr(s)
|
||||||
|
icon_name_list.append(icon_name)
|
||||||
|
|
||||||
|
# write mapping lib for python
|
||||||
|
with open(os.path.join(__location__, "../../../apps/nspanel-lovelace-ui", "icon_mapper.py"), 'w') as f:
|
||||||
|
f.write("icons = {\n")
|
||||||
|
for idx, val in enumerate(icon_name_list):
|
||||||
|
f.write(f" '{val}': {idx},\n")
|
||||||
|
f.write("}\n")
|
||||||
|
f.write("""
|
||||||
|
def get_icon(ma_name):
|
||||||
|
if ma_name in icons:
|
||||||
|
return icons[ma_name]
|
||||||
|
else:
|
||||||
|
return icons["alert-circle-outline"]
|
||||||
|
""")
|
||||||
|
|
||||||
|
# write documentation file
|
||||||
|
with open(os.path.join(__location__, "../..","icons.md"), 'w') as f:
|
||||||
|
f.write("""
|
||||||
|
# Icons IDs
|
||||||
|
This file contains the Icons IDs included in the display firmware, addressable via serial.
|
||||||
|
|
||||||
|
ID | MD Icon Name | Icon
|
||||||
|
-- | ------------ | ----
|
||||||
|
""")
|
||||||
|
for idx, val in enumerate(icon_name_list):
|
||||||
|
f.write(f"{idx} | {val} | \n")
|
||||||
|
|
||||||
|
|
||||||
|
print("=== STRING for HMI Project ===")
|
||||||
|
print("=== Put the following string into the txt field in nextion ===")
|
||||||
|
print(icon_nextion_string)
|
||||||
41
HMI/icons.md
Normal file
41
HMI/icons.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
# Icons IDs
|
||||||
|
This file contains the Icons IDs included in the display firmware, addressable via serial.
|
||||||
|
|
||||||
|
ID | MD Icon Name | Icon
|
||||||
|
-- | ------------ | ----
|
||||||
|
0 | window-open | 
|
||||||
|
1 | lightbulb | 
|
||||||
|
2 | thermometer | 
|
||||||
|
3 | gesture-tap-button | 
|
||||||
|
4 | flash | 
|
||||||
|
5 | music | 
|
||||||
|
6 | check-circle-outline | 
|
||||||
|
7 | close-circle-outline | 
|
||||||
|
8 | pause | 
|
||||||
|
9 | play | 
|
||||||
|
10 | palette | 
|
||||||
|
11 | alert-circle-outline | 
|
||||||
|
12 | weather-cloudy | 
|
||||||
|
13 | weather-fog | 
|
||||||
|
14 | weather-hail | 
|
||||||
|
15 | weather-lightning | 
|
||||||
|
16 | weather-lightning-rainy | 
|
||||||
|
17 | weather-night | 
|
||||||
|
18 | weather-partly-cloudy | 
|
||||||
|
19 | weather-pouring | 
|
||||||
|
20 | weather-rainy | 
|
||||||
|
21 | weather-snowy | 
|
||||||
|
22 | weather-snowy-rainy | 
|
||||||
|
23 | weather-sunny | 
|
||||||
|
24 | weather-windy | 
|
||||||
|
25 | weather-windy-variant | 
|
||||||
|
26 | water-percent | 
|
||||||
|
27 | power | 
|
||||||
|
28 | fire | 
|
||||||
|
29 | calendar-sync | 
|
||||||
|
30 | fan | 
|
||||||
|
31 | snowflake | 
|
||||||
|
32 | solar-power | 
|
||||||
|
33 | battery-charging-medium | 
|
||||||
|
34 | battery-medium | 
|
||||||
44
apps/nspanel-lovelace-ui/icon_mapper.py
Normal file
44
apps/nspanel-lovelace-ui/icon_mapper.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
icons = {
|
||||||
|
'window-open': 0,
|
||||||
|
'lightbulb': 1,
|
||||||
|
'thermometer': 2,
|
||||||
|
'gesture-tap-button': 3,
|
||||||
|
'flash': 4,
|
||||||
|
'music': 5,
|
||||||
|
'check-circle-outline': 6,
|
||||||
|
'close-circle-outline': 7,
|
||||||
|
'pause': 8,
|
||||||
|
'play': 9,
|
||||||
|
'palette': 10,
|
||||||
|
'alert-circle-outline': 11,
|
||||||
|
'weather-cloudy': 12,
|
||||||
|
'weather-fog': 13,
|
||||||
|
'weather-hail': 14,
|
||||||
|
'weather-lightning': 15,
|
||||||
|
'weather-lightning-rainy': 16,
|
||||||
|
'weather-night': 17,
|
||||||
|
'weather-partly-cloudy': 18,
|
||||||
|
'weather-pouring': 19,
|
||||||
|
'weather-rainy': 20,
|
||||||
|
'weather-snowy': 21,
|
||||||
|
'weather-snowy-rainy': 22,
|
||||||
|
'weather-sunny': 23,
|
||||||
|
'weather-windy': 24,
|
||||||
|
'weather-windy-variant': 25,
|
||||||
|
'water-percent': 26,
|
||||||
|
'power': 27,
|
||||||
|
'fire': 28,
|
||||||
|
'calendar-sync': 29,
|
||||||
|
'fan': 30,
|
||||||
|
'snowflake': 31,
|
||||||
|
'solar-power': 32,
|
||||||
|
'battery-charging-medium': 33,
|
||||||
|
'battery-medium': 34,
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_icon(ma_name):
|
||||||
|
if ma_name in icons:
|
||||||
|
return icons[ma_name]
|
||||||
|
else:
|
||||||
|
return icons["alert-circle-outline"]
|
||||||
|
|
||||||
Reference in New Issue
Block a user