# --------------------------------------------------------------------------- #

Display standard {
	driver		'DPF'
	port		'usb0'
	font		'16x34'
	size		'320x240'
	basecolor	'000000'
	foreground	'ffffff'
	background	'00000000'
	backlight	7
}

Display radio {
	driver		'DPF'
	port		'usb0'
	font		'16x34'
	size		'320x240'
	basecolor	'000000'
	foreground	'ffffff'
	background	'00000000'
	backlight	7
}

Display large {
	driver		'DPF'
	port		'usb0'
	font		'20x48'
	size		'320x240'
	basecolor	'000000'
	foreground	'ffffff'
	background	'00000000'
	backlight	7
}

Display small {
	driver		'DPF'
	port		'usb0'
	font		'10x16'
	size		'320x240'
	basecolor	'000000'
	foreground	'ffffff'
	background	'00000000'
	backlight	7
}

Display d-box2 {
	driver		'DPF'
	port		'usb0'
	font		'16x34'
	size		'320x240'
	basecolor	DBOX2COL
	foreground	DBOX2COL
	background	'00000000'
	backlight	7
}

Display standby {
	driver		'DPF'
	port		'usb0'
	font		'16x30'
	size		'320x240'
	basecolor	'000000'
	foreground	'ffffff'
	background	'00000000'
	backlight	3
}

# --------------------------------------------------------------------------- #

# --- general widgets (partly postfixed with _layout) --- #

Widget LOGO {
	class		'Image'
	file		file::exist('/tmp/lcd/menu') == 1 ? ICONS . 'menu.png' : file::readline('/tmp/lcd/logo', 1)
	update		3300
	visible		file::exist('/tmp/lcd/menu') == 1 ? 1 : file::readline('/tmp/lcd/mode_logo', 1)
	reload		1
	center		55
	scale		100
	width		320
	height		55
}

Widget SERVICE {
	class 'Text'
	expression	file::exist('/tmp/lcd/menu') == 1 ? '' : (file::readline('/tmp/lcd/mode_logo', 1) == 1 ? '' : file::readline('/tmp/lcd/service', 1))
	align		'PC'
	width		20
	update		3300
}

Widget SERVICE_large {
	class 'Text'
	expression	file::exist('/tmp/lcd/menu') == 1 ? '' : (file::readline('/tmp/lcd/mode_logo', 1) == 1 ? '' : file::readline('/tmp/lcd/service', 1))
	align		'PC'
	width		16
	update		3300
}

Widget SERVICE_small {
	class 'Text'
	expression	file::exist('/tmp/lcd/menu') == 1 ? '' : (file::readline('/tmp/lcd/mode_logo', 1) == 1 ? '' : file::readline('/tmp/lcd/service', 1))
	align		'PC'
	width		32
	update		3300
}

Widget SERVICE_d-box2 {
	class 'Text'
	#expression	file::readline('/tmp/lcd/service', 1)
	expression	file::exist('/tmp/lcd/menu') == 1 ? '' : (file::readline('/tmp/lcd/mode_logo', 1) == 1 ? '' : file::readline('/tmp/lcd/service', 1))
	align		'PC'
	width		20
	update		3300
}

Widget EVENT {
	class		'Text'
	expression	file::exist('/tmp/lcd/menu') == 1 ? file::readline('/tmp/lcd/menu', 1) : file::readline('/tmp/lcd/event', 1)
	align		'PC'
	width		20
	update		250
	speed		325
	foreground	'fd6d13'
}

Widget EVENT_large {
	class		'Text'
	expression	file::exist('/tmp/lcd/menu') == 1 ? file::readline('/tmp/lcd/menu', 1) : file::readline('/tmp/lcd/event', 1)
	align		'PC'
	width		16
	update		250
	speed		325
	foreground	'fd6d13'
}

Widget EVENT_small {
	class		'Text'
	expression	file::exist('/tmp/lcd/menu') == 1 ? file::readline('/tmp/lcd/menu', 1) : file::readline('/tmp/lcd/event', 1)
	align		'PC'
	width		32
	update		250
	speed		325
	foreground	'fd6d13'
}

Widget EVENT_d-box2 {
	class		'Text'
	expression	file::exist('/tmp/lcd/menu') == 1 ? file::readline('/tmp/lcd/menu', 1) : file::readline('/tmp/lcd/event', 1)
	align		'PC'
	width		20
	update		250
	speed		325
}

Widget PROGRESS {
	class		'Bar'
	expression	0
	expression2	file::exist('/tmp/lcd/menu') == 1 ? 0 : file::readline('/tmp/lcd/progress', 1)
	min		0
	max		100
	length		18
	update		2600
	foreground	'fd6d13aa'
	barcolor0	'00000000'
}

Widget PROGRESS_large {
	class		'Bar'
	expression	file::exist('/tmp/lcd/menu') == 1 ? 0 : file::readline('/tmp/lcd/progress', 1)
	min		0
	max		100
	length		14
	update		2600
	foreground	'000000aa'
}

Widget PROGRESS_small {
	class		'Bar'
	expression	file::exist('/tmp/lcd/menu') == 1 ? 0 : file::readline('/tmp/lcd/progress', 1)
	min		0
	max		100
	length		30
	update		2600
	foreground	'fd6d13aa'
}

Widget PROGRESS_d-box2 {
	class		'Bar'
	expression	0
	expression2	file::exist('/tmp/lcd/menu') == 1 ? 0 : file::readline('/tmp/lcd/progress', 1)
	min		0
	max		100
	length		10
	update		2600
	barcolor0	'00000000'
}

Widget DURATION {
	class 'Text'
	expression	file::exist('/tmp/lcd/menu') == 1 ? '' : file::readline('/tmp/lcd/duration', 1)
	align		'R'
	width		13
	update		500
	foreground	'fd6d13'
}

Widget VOLUME_d-box2 {
	class		'Bar'
	expression	file::readline('/tmp/lcd/volume', 1)
	expression2	0
	min		0
	max		100
	length		10
	update		1000
	barcolor1	'00000000'
}

Widget TIME {
	class		'Text'
	expression	strftime('%H:%M', time())
	align		'L'
	width		5
	update		5000
	foreground	'9E9E9E'
}

Widget TIME_d-box2 {
	class		'Text'
	expression	strftime('%H:%M', time())
	align		'L'
	width		5
	update		5000
}

# --- system-info --- #

Widget CPU {
	class		'Text'
	prefix		'CPU: '
	expression	proc_stat::cpu('busy', 500)
	postfix		'%'
	precision	1
	align		'R'
	width		11
	update		1000
	foreground	'9E9E9E'
}

Widget CPU_BAR {
	class		'Bar'
	expression	proc_stat::cpu('busy', 500)
	min		0
	max		100
	length		17
	style		'H'
	update		500
	foreground	'9E9E9E'
}

Widget RAM {
	class		'Text'
	prefix		'RAM: '
	expression	100 - ((meminfo('MemFree') * 100) / meminfo('MemTotal'))
	postfix		'%'
	precision	1
	align		'R'
	width		11
	update		1000
	foreground	'9E9E9E'
}

Widget MTD {
	class		'Text'
	prefix		'MTD: '
	expression	100 - (statfs('/', 'bfree') * 100) / statfs('/', 'blocks')
	postfix		'%'
	precision	1
	align		'R'
	width		11
	update		1000
	foreground	'9E9E9E'
}

# --- general mode-icons --- #

Widget ICON_ECM {
	class		'Image'
	file		ICONS . 'mode/ecm_' . file::readline('/tmp/lcd/mode_ecm', 1) . '.png'
	update		10000
	reload		1
}

Widget ICON_TIMER {
	class		'Image'
	file		ICONS . 'mode/timer_' . file::readline('/tmp/lcd/mode_timer', 1) . '.png'
	update		10000
	reload		1
}

Widget ICON_REC {
	class		'Image'
	file		ICONS . 'mode/rec_' . file::readline('/tmp/lcd/mode_rec', 1) . '.png'
	update		10000
	reload		1
}

Widget ICON_TS {
	class		'Image'
	file		ICONS . 'mode/ts_' . file::readline('/tmp/lcd/mode_tshift', 1) . '.png'
	update		10000
	reload		1
}

# --- d-box2 mode-icons --- #

Widget ICON_ECM_d-box2 {
	class		'Image'
	file		ICONS . 'mode/d-box2/ecm_' . file::readline('/tmp/lcd/mode_ecm', 1) . '.png'
	update		10000
	reload		1
}

Widget ICON_TIMER_d-box2 {
	class		'Image'
	file		ICONS . 'mode/d-box2/timer_' . file::readline('/tmp/lcd/mode_timer', 1) . '.png'
	update		10000
	reload		1
}

Widget ICON_REC_d-box2 {
	class		'Image'
	file		ICONS . 'mode/d-box2/rec_' . file::readline('/tmp/lcd/mode_rec', 1) . '.png'
	update		10000
	reload		1
}

Widget ICON_TS_d-box2 {
	class		'Image'
	file		ICONS . 'mode/d-box2/ts_' . file::readline('/tmp/lcd/mode_tshift', 1) . '.png'
	update		10000
	reload		1
}

# --- the background --- #

Widget BACKGROUND {
	class		'Image'
	file		ICONS . 'background/' . file::readline('/tmp/lcd/layout', 1) . '.png'
	update		0
}

# --- the clocks for standby-mode --- #

# --- the digital clock --- #

Widget HOUR1_ {
	class		'image'
	file		file::exist(FCLOCK) == 1 ? ICONS . 'blank.png' : ICONS . 'clock/digital/' . substr(strftime('%H', time()), 0, 1) . '.png'
	update		10000
	reload		1
}

Widget HOUR_1 {
	class		'image'
	file		file::exist(FCLOCK) == 1 ? ICONS . 'blank.png' : ICONS . 'clock/digital/' . substr(strftime('%H', time()), 1) . '.png'
	update		10000
	reload		1
}

Widget DP {
	class		'Image'
	file		file::exist(FCLOCK) == 1 ? ICONS . 'blank.png' : ICONS . 'clock/digital/dp.png'
	update		0
}

Widget MIN1_ {
	class		'image'
	file		file::exist(FCLOCK) == 1 ? ICONS . 'blank.png' : ICONS . 'clock/digital/' . substr(strftime('%M', time()), 0, 1) . '.png'
	update		10000
	reload		1
}

Widget MIN_1 {
	class		'image'
	file		file::exist(FCLOCK) == 1 ? ICONS . 'blank.png' : ICONS . 'clock/digital/' . substr(strftime('%M', time()), 1) . '.png'
	update		10000
	reload		1
}

# --- the analog clock --- #

Widget DIAL_A {
	class		'image'
	file		file::exist(FCLOCK) == 0 ? ICONS . 'blank.png' : ICONS . 'clock/analog/dial.png'
	update		0
}

Widget HOUR_A {
	class		'image'
	file		file::exist(FCLOCK) == 0 ? ICONS . 'blank.png' : ICONS . 'clock/analog/h' . ( ( (strftime('%I', time()) == 12 ? 0 : strftime('%I', time())) *5) + substr((strftime('%M', time()) / 12), 0, 1) ). '.png'
	update		10000
	reload		1
}

Widget MIN_A {
	class		'image'
	file		file::exist(FCLOCK) == 0 ? ICONS . 'blank.png' : ICONS . 'clock/analog/m' . strftime('%M', time()) . '.png'
	update		10000
	reload		1
}

# --- the weather --- #

Widget EXEC_WEATHER-SCRIPT {
	class		'Text'
	expression	exec('/share/lcd/scripts/weather', 900000) # 15 minutes
	width		0
}

Widget ICON_WEATHER {
	class		'Image'
	file		file::exist(FWEATHER) == 0 ? ICONS . 'weather/weather_off.png' : ICONS . 'weather/weather_on.png'
	update		10000
	reload		1
}

Widget WEATHERICON_CURRENT {
	class		'image'
	file		file::exist(FWEATHER) == 0 ? ICONS . 'weather/0000.png' : ICONS . 'weather/' . file::readline('/tmp/lcd/weathericons', 1)
	update		10000
	reload		1
}

Widget WEATHERICON_LATER {
	class		'image'
	file		file::exist(FWEATHER) == 0 ? ICONS . 'weather/0000.png' : ICONS . 'weather/' . file::readline('/tmp/lcd/weathericons', strftime('%H', time()) < 16 ? 2 : 3)
	update		10000
	reload		1
}

Widget TEMPERATURE_CURRENT {
	class		'Text'
	expression	file::exist(FWEATHER) == 0 ? '' : file::readline('/tmp/lcd/temperatures', 1)
	align		'L'
	width		3
	update		10000
}

Widget TEMPERATURE_LATER {
	class		'Text'
	expression	file::exist(FWEATHER) == 0 ? '' : file::readline('/tmp/lcd/temperatures', strftime('%H', time()) < 16 ? 2 : 3)
	align		'R'
	width		3
	update		10000
}

# --------------------------------------------------------------------------- #

Layout standard {
	layer 0 {
		row02.col01	'SERVICE'
		row04.col01	'EVENT'
		row05.col02	'PROGRESS'
		row07 {
			col07	'DURATION'
			col02	'TIME'
		}
	}

	layer 1 {
		x008.y073	'ICON_ECM'
		x008.y217	'ICON_TIMER'
		x008.y258	'ICON_REC'
		x008.y289	'ICON_TS'

		x021.y001	'LOGO'
	}

	layer 2 {
		x001.y001	'BACKGROUND'
	}
}

Layout radio {
	layer 0 {
		row02.col01	'SERVICE'
		row04.col01	'EVENT'
		row05.col02	'PROGRESS'
		row07 {
			col07	'DURATION'
			col02	'TIME'
		}
	}

	layer 1 {
		x008.y073	'ICON_ECM'
		x008.y217	'ICON_TIMER'
		x008.y258	'ICON_REC'
		x008.y289	'ICON_TS'

		x021.y001	'LOGO'
	}

	layer 2 {
		x001.y001	'BACKGROUND'
	}
}

Layout large {
	layer 0 {
		row02.col01	'SERVICE_large'
		row04.col01	'EVENT_large'
		row05.col02	'PROGRESS_large'
	}

	layer 1 {
		x008.y073	'ICON_ECM'
		x008.y217	'ICON_TIMER'
		x008.y258	'ICON_REC'
		x008.y289	'ICON_TS'

		x044.y001	'LOGO'
	}

	layer 2 {
		x001.y001	'BACKGROUND'
	}
}

Layout small {
	layer 0 {
		row04.col01	'SERVICE_small'
		row06.col01	'EVENT_small'
		row08.col02	'PROGRESS_small'
		row12 {
			col02	'CPU'
			col15	'CPU_BAR'
		}
		row13.col02	'RAM'
		row14 {
			col02	'MTD'
			col27	'TIME'
		}
	}

	layer 1 {
		x008.y073	'ICON_ECM'
		x008.y217	'ICON_TIMER'
		x008.y258	'ICON_REC'
		x008.y289	'ICON_TS'

		x021.y001	'LOGO'
	}

	layer 2 {
		x001.y001	'BACKGROUND'
	}
}

Layout d-box2 {
	layer 0 {
		row01.col04	'PROGRESS_d-box2'
		row03.col01	'SERVICE_d-box2'
		row05.col01	'EVENT_d-box2'
		row07 {
			col04	'VOLUME_d-box2'
			col15	'TIME_d-box2'
		}
	}

	layer 1 {
		x045.y073	'ICON_ECM_d-box2'
		x045.y217	'ICON_TIMER_d-box2'
		x045.y258	'ICON_REC_d-box2'
		x045.y289	'ICON_TS_d-box2'

		x060.y001	'LOGO'
	}

	layer 2 {
		x001.y001	'BACKGROUND'
	}
}

Layout standby {
	layer 0 {
		x020.y085	'MIN_A'

		X034.Y025	'HOUR1_'
		X034.Y085	'HOUR_1'
		X034.Y145	'DP'
		X034.Y175	'MIN1_'
		X034.Y235	'MIN_1'

		row01.col1	'EXEC_WEATHER-SCRIPT'
		x225.y132	'ICON_WEATHER'
		X168.Y017	'WEATHERICON_CURRENT'
		X168.Y241	'WEATHERICON_LATER'
		row07.col07	'TEMPERATURE_CURRENT'
		row07.col12	'TEMPERATURE_LATER'
	}

	layer 1 {
		x020.y085	'HOUR_A'

		x008.y073	'ICON_ECM'
		x008.y217	'ICON_TIMER'
		x008.y258	'ICON_REC'
		x008.y289	'ICON_TS'
	}

	layer 2 {
		x020.y000	'DIAL_A'

		x001.y001	'BACKGROUND'
	}
}

# --------------------------------------------------------------------------- #

Variables {
	ICONS		'/share/lcd/icons/'
	FWEATHER	'/var/etc/.lcd-weather'
	FCLOCK		'/var/etc/.lcd-clock_a'

	# color for layout "d-box2" {
		#DBOX2COL	'F44336'	# red
		#DBOX2COL	'4CAF50'	# green
		#DBOX2COL	'3F51B5'	# blue
		DBOX2COL	'F5F5F5'	# white
		#DBOX2COL	'FFEB3B'	# yellow
		#DBOX2COL	'E91E63'	# pink
	# }
}

# --------------------------------------------------------------------------- #

Display	file::readline('/tmp/lcd/layout', 1)

Layout	file::readline('/tmp/lcd/layout', 1)

# --------------------------------------------------------------------------- #