JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div class="container-fluid" ng-app="app">
<div class="row" ng-controller="ControladorPrincipal">
<div class="col-xs-12">
<p>
<strong>Nota: </strong> Esto supone que las salidas del 74hc595 están conectadas al display de la siguiente forma:
<pre>
Q0 --> DP o punto decimal
Q1 --> Letra A
Q2 --> Letra B
Q3 --> Letra C
Q4 --> Letra D
Q5 --> Letra E
Q6 --> Letra F
Q7 --> Letra G
</pre>
</p>
<div class="seven-segment">
<div class="cursor-manita a" ng-class="{'on': pantalla.a === true}" ng-click="intercambiarLetra('a')"></div>
<div class="cursor-manita b" ng-class="{'on': pantalla.b === true}" ng-click="intercambiarLetra('b')"></div>
<div class="cursor-manita c" ng-class="{'on': pantalla.c === true}" ng-click="intercambiarLetra('c')"></div>
<div class="cursor-manita d" ng-class="{'on': pantalla.d === true}" ng-click="intercambiarLetra('d')"></div>
<div class="cursor-manita e" ng-class="{'on': pantalla.e === true}" ng-click="intercambiarLetra('e')"></div>
<div class="cursor-manita f" ng-class="{'on': pantalla.f === true}" ng-click="intercambiarLetra('f')"></div>
<div class="cursor-manita g" ng-class="{'on': pantalla.g === true}" ng-click="intercambiarLetra('g')">
<div class="top"></div>
<div class="bottom"></div>
</div>
</div>
<div class="cursor-manita dp" ng-class="{'on': pantalla.dp === true}" ng-click="intercambiarLetra('dp')"></div>
<br><br>
<label for="anodoComun">
<input ng-model="tipo" value="anodoComun" id="anodoComun" type="radio" name="tipo">Ánodo común
</label>
<label for="catodoComun">
<input ng-model="tipo" value="catodoComun" id="catodoComun" type="radio" name="tipo">Cátodo común
</label>
<br><br>
<label for="lsbfirst">
<input ng-model="orden" value="lsbfirst" id="lsbfirst" type="radio" name="orden">LSBFIRST
</label>
<label for="msbfirst">
<input ng-model="orden" value="msbfirst" id="msbfirst" type="radio" name="orden">MSBFIRST
</label>
<br>
<h2>B{{byte}}</h2>
</div>
<h1>Imágenes de referencia</h1>
<h3>Display siete segmentos</h3>
<img src="https://www.elprocus.com/wp-content/uploads/2014/10/configuration.jpg" alt="">
<br>
<h2>Pinout de 74hc595</h2>
<img src="https://learn.pimoroni.com/static/repos/learn/170pt-projects/pinout-74hc595.jpg" alt="">
</div>
</div>
img{
max-width: 100%;
}
/*
CSS Seven-Segment Display Demo
http://velvetcache.org/2012/04/11/css-seven-segment-display-tutorial
- For Darcy -
Copyright 2012 John M. Hobbs
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
.seven-segment {
position: relative;
height: 350px;
width: 200px;
display: inline-block;
}
.seven-segment .a {
position: absolute;
left: 10px;
height: 0;
width: 100px;
border-top: 30px solid #222;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
}
.seven-segment .a.on {
border-top-color: #0083FF;
}
.seven-segment .b {
position: absolute;
left: 150px;
top: 10px;
height: 100px;
width: 0;
border-right: 30px solid #222;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
}
.seven-segment .b.on {
border-right-color: #0083FF;
}
.seven-segment .c {
position: absolute;
left: 150px;
top: 180px;
height: 100px;
width: 0;
border-right: 30px solid #222;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
}
.seven-segment .c.on {
border-right-color: #0083FF;
}
.seven-segment .d {
position: absolute;
top: 320px;
left: 10px;
height: 0;
width: 100px;
border-bottom: 30px solid #222;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
}
.seven-segment .d.on {
border-bottom-color: #0083FF;
}
.seven-segment .e {
position: absolute;
left: 0;
top: 180px;
height: 100px;
width: 0;
border-left: 30px solid #222;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
}
.seven-segment .e.on {
border-left-color: #0083FF;
}
.seven-segment .f {
position: absolute;
left: 0;
top: 10px;
height: 100px;
width: 0;
border-left: 30px solid #222;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
}
.seven-segment .f.on {
border-left-color: #0083FF;
}
.seven-segment .g {
position: absolute;
top: 162px;
left: 35px;
-webkit-transform: scale(1.4);
-moz-transform: scale(1.4);
-ms-transform: scale(1.4);
-o-transform: scale(1.4);
transform: scale(1.4);
}
.seven-segment .g .top {
height: 0;
width: 80px;
border-bottom: 15px solid #222;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
}
.seven-segment .g .bottom {
height: 0;
width: 80px;
border-top: 15px solid #222;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
}
.seven-segment .g.on .top {
border-bottom-color: #0083FF;
}
.seven-segment .g.on .bottom {
border-top-color: #0083FF;
}
.cursor-manita{
cursor: pointer;
}
.dp{
width: 30px;
height:30px;
border-radius: 100%;
background-color:#222;
margin-left: 160px;
}
.dp.on{
width: 30px;
height:30px;
border-radius: 100%;
background-color:#0083FF;
}
let app = angular.module("app", []);
app.controller("ControladorPrincipal", [
"$scope",
$scope => {
$scope.tipo = 'anodoComun';
$scope.orden = 'lsbfirst';
/*
B11110000,
B10110000,
B10001000,A
B10101011,
B11100010,
B11111111,
*/
$scope.intercambiarLetra = letra => {
$scope.pantalla[letra] = !$scope.pantalla[letra];
};
$scope.pantalla = {
dp: false,
a: false,
b: false,
c: false,
d: false,
e: false,
f: false,
g: false
};
$scope.construirByte = () => {
let s = "";
for (let i in $scope.pantalla) {
if($scope.tipo==='anodoComun'){
if ($scope.pantalla[i] === true) {
s += "0";
} else s += "1";
} else{
if ($scope.pantalla[i] === true) {
s += "1";
} else s += "0";
}
}
if($scope.orden === 'msbfirst'){
s = s.split("").reverse().join("");
}
$scope.byte = s;
};
$scope.$watch('tipo', (nuevo, anterior)=>{
$scope.construirByte();
});
$scope.$watch('orden', (nuevo, anterior)=>{
$scope.construirByte();
});
$scope.$watch(
"pantalla",
(nuevo, anterior) => {
if (anterior && nuevo) {
$scope.construirByte();
}
},
true
);
}
]);
Also see: Tab Triggers