<li data-row="1" data-col="4" data-sizex="4" data-sizey="1"> <header>STERNE</header> <?php light('S_SWITCH_C2_Sterne', array("5m", "15m", "30m", "1h", "2h")); ?> </li> <li data-row="2" data-col="4" data-sizex="4" data-sizey="1"> <header>LESELAMPE</header> <?php light('S_SWITCH_B2_Leselampe', array("5m", "15m", "30m", "1h", "2h")); ?> </li> <li data-row="3" data-col="4" data-sizex="4" data-sizey="1"> <header>TV</header> <?php light('S_SWITCH_A2_TV', array("30m", "1h", "2h", "4h", 0)); ?> </li> <li data-row="4" data-col="4" data-sizex="2" data-sizey="1"> <header>ALLE</header> <div class="centered container"> <div class="left"> <div data-type="push" data-device="S_LICHT" data-set="on" ></div> <div data-type="label">Ein</div> </div> <div class="left"> <div data-type="push" data-device="S_LICHT"
<header>MILIGHT 4</header> <?php milight('MILIGHT_Zone4_Wohnzimmer'); ?> </li> <li data-row="1" data-col="6" data-sizex="2" data-sizey="1"> <header>STEHLAMPE</header> <?php light('W_LICHT_A1_Stehlampe'); ?> </li> <li data-row="2" data-col="6" data-sizex="2" data-sizey="1"> <header>TV-BACK</header> <?php light('W_LICHT_C1_BacklightTV'); ?> </li> <li data-row="3" data-col="6" data-sizex="2" data-sizey="1"> <header>ALLE</header> <div class="centered container"> <div class="left"> <div data-type="push" data-device="W_LICHT" data-set="on" ></div> <div data-type="label">Ein</div> </div> <div class="left"> <div data-type="push" data-device="W_LICHT"
?> </li> <li data-row="3" data-col="1" data-sizex="3" data-sizey="2"> <header>MILIGHT 4</header> <?php milight('MILIGHT_Zone4_Wohnzimmer', 1); ?> </li> <li data-row="5" data-col="1" data-sizex="2" data-sizey="3"> <header>LEUCHTEN</header> <?php light('W_LICHT_A1_Stehlampe', array("1h", "2h"), 'Stehlampe'); ?> <?php light('W_LICHT_C1_BacklightTV', array("1h", "2h"), 'TV'); ?> </li> <li data-row="5" data-col="3" data-sizex="1" data-sizey="3"> <header>ALLE</header> <div class="centered container"> <div data-type="push" data-device="W_LICHT" data-set="on" class="cell"></div> <div data-type="label" class="cell">Ein</div> <div data-type="push" data-device="W_LICHT" data-set="off"
function light($num) { if (is_array($num)) { return array(light($num[0]), light($num[1]), light($num[2])); } else { $diff = 255 - $num; $inc = round($diff * 0.85); return $num + $inc; } }
return $maps; } // Initialize the two maps $map1 = \array_fill(0, MAP_SIZE, \array_fill(0, MAP_SIZE, false)); $map2 = \array_fill(0, MAP_SIZE, \array_fill(0, MAP_SIZE, 0)); // sscanf is a lot faster then preg_match or other regex matchers foreach ($instructions as $instruction) { if (\sscanf($instruction, \MODE_ON . " " . \DIGITS_FORMAT, $fromX, $fromY, $toX, $toY)) { $mode = \MODE_ON; } elseif (\sscanf($instruction, \MODE_OFF . " " . \DIGITS_FORMAT, $fromX, $fromY, $toX, $toY)) { $mode = \MODE_OFF; } elseif (\sscanf($instruction, \MODE_TOGGLE . " " . \DIGITS_FORMAT, $fromX, $fromY, $toX, $toY)) { $mode = \MODE_TOGGLE; } else { throw new \DomainException("Unknown instruction `{$instruction}`."); } list($map1, $map2) = light([$map1, $map2], $mode, $fromX, $fromY, $toX, $toY); } $lightsCount = 0; $brightnessCount = 0; foreach ($map1 as $rows) { foreach ($rows as $col) { $lightsCount += (int) $col; } } foreach ($map2 as $rows) { foreach ($rows as $col) { $brightnessCount += $col; } } echo "Total {$lightsCount} lights are on and total brightness is {$brightnessCount}.";
</li> <li data-row="2" data-col="6" data-sizex="2" data-sizey="1"> <header>TV-BACK (Wohnzimmer)</header> <?php light('W_LICHT_C1_BacklightTV'); ?> </li> <li data-row="3" data-col="6" data-sizex="2" data-sizey="1"> <header>STERNE (Schlafzimmer)</header> <?php light('S_SWITCH_C2_Sterne', array("30m", "1h")); ?> </li> <li data-row="4" data-col="6" data-sizex="2" data-sizey="1"> <header>LESELAMPE (Schlafzimmer)</header> <?php light('S_SWITCH_B2_Leselampe', array("30m", "1h")); ?> </li> <li data-row="4" data-col="2" data-sizex="4" data-sizey="1"> <header>MILIGHT 3 (Küche)</header> <div class="left"> <?php milight("MILIGHT_Zone3_Kueche", 1); ?> </div> </li> </ul>
<div class="gridster"> <ul> <li data-row="1" data-col="1" data-sizex="3" data-sizey="2"> <header>SCHLAFZIMMER BELEUCHTUNG</header> <?php milight('MILIGHT_Zone2_Schlafzimmer', 1); ?> </li> <li data-row="3" data-col="1" data-sizex="3" data-sizey="5"> <header>LEUCHTEN</header> <?php light('MILIGHT_Zone2_Schlafzimmer', array("15m", "30m", "1h", "2h"), 'Milight'); ?> <?php light('S_SWITCH_C2_Sterne', array("15m", "30m", "1h", "2h"), 'Sterne'); ?> <?php light('S_SWITCH_B2_Leselampe', array("15m", "30m", "1h", "2h"), 'Lese'); ?> <?php light('S_SWITCH_A2_TV', array("15m", "30m", "1h", "2h"), 'TV'); ?> </li> <li data-row="8" data-col="1" data-sizex="3" data-sizey="1" data-template="menu-schlafzimmer.php"></li> <li data-row="9" data-col="1" data-sizex="3" data-sizey="1" data-template="menu.php"></li> </ul> </div> </body> </html>