@jibed/segmentdisplay v1.0.5
temperature console printer
My project
temperature console printer is a typescript library to print a given temperature in the console in 7 segment style.
installation
the library can be installed via the npm package manager:
npm install @jibed/segmentdisplay
usage
With this you can print the temperature or a binary code in 7-segment style. when you want to print the temperature: you can write the temperature in the method:
supported chars:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- °
- C
- ,
- (space)
you can also give an optional parameter: if you want a frame around the printed text (default == false). how many times you want the text to be bigger (default == 1).
example input
import { Display } from '@jibed/segmentdisplay/display';
const display = new Display();
console.log(display.printTemp("20,5°C"));
console.log(display.printTemp("20,5°C", true));
console.log(display.printTemp("20,5°C", true, 5));
output
_ _ _ _ _
_|| | |_ |_||
|_ |_| | _| |_
___________________________
| _ _ _ _ _ |
| _|| | |_ |_|| |
| |_ |_| | _| |_ |
|___________________________|
________________________________________________________
| |
| |
| |
| |
| _____ _____ _____ _____ _____ |
| || | | | || |
| || | | | || |
| || | | | || |
| || | | | || |
| _____|| | |_____ |_____|| |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| |_____ |_____| | _____| |_____ |
| |
| |
| |
| |
|________________________________________________________|
Binary input: how to
if you want to use binary code you need to set a "b/" before your input and a "/" between every binary.
in the photo above you see the letters displayed: ABCDEFGH
if you want a line on the place of the letter, you need to write a 1 on the place of the letter. f.e.: 3 is 10110110 and 0 = 11011110 so for example the input for "30 °C" would be: b/10110110/11011110/00000000/11110000/11001100
example input1
import { Display } from '@jibed/segmentdisplay/display';
const display = new Display();
console.log(display.printTempb("b/10110110/11011110/00000000/11110000/11001100"));
console.log(display.printTemp("b/10110110/11011110/00000000/11110000/11001100", true));
output1
_ _ _ _
_|| | |_||
_||_| |_
_____________________
| _ _ _ _ |
| _|| | |_|| |
| _||_| |_ |
|_____________________|
others
when you use binary code, you can also use the supported characters inbetween them.
example input2
import { Display } from '@jibed/segmentdisplay/display';
const display = new Display();
console.log(display.printTempb("b/3/11011110/ /°/11001100"));
console.log(display.printTemp("b/10110110/0/00000000/11110000/C", true));
output2
_ _ _ _
_|| | |_||
_||_| |_
_____________________
| _ _ _ _ |
| _|| | |_|| |
| _||_| |_ |
|_____________________|
extras
with this library it is also possible to give the same frame to every string you want: the parameters are:
- the string you want to frame
- a number of how big you want to be the frame away from your string(default == 1)
example input 3
import { Layout } from '@jibed/segmentdisplay/Layout'
const layout = new Layout()
console.log(layout.addFrame("i want a frame", 1))
console.log(layout.addFrame("i want a bigger frame", 4))
output3
____________________
| i want a frame |
|____________________|
_________________________________
| |
| |
| |
| i want a bigger frame |
| |
| |
| |
|_________________________________|
contributing
its not necessary to document your changes but I highly recommend it. For major changes, I'd prefer you discuss it with me
name: Jibe Defoor email: jibe.defoor@hotmail.com