temperature-segmenter-michieldecoster v1.0.0
Segmenter
Description
This is a repository for printing Temperatures in LCD Display format.
Its developed in typescript and uses npm package manager to install.
7-Segment Display
The 7-Segment display is built with the segments A through G.
I used these with a boolean function to either show them on or off (true or false).
Example:
case 0 : {this.a=true; this.b=true; this.c=true; this.d=true; this.e=true; this.f=true; this.g=false; break}
This would return a 0 on the display.
Installation instructions
NPM Install
Usage instructions
Different values
These are the different values you can give to the DrawSegment
and DrawBigSegment
Classes.
case 0 : draws the number '0'
case 1 : draws the number '1'
case 2 : draws the number '2'
case 3 : draws the number '3'
case 4 : draws the number '4'
case 5 : draws the number '5'
case 6 : draws the number '6'
case 7 : draws the number '7'
case 8 : draws the number '8'
case 9 : draws the number '9'
case 10 : draws Degrees sign
case 11 : draws Celsius sign
case 12 : draws Minus sign
I got the idea to use a switch statement by finding the repository from SK-SpeedBit
Using the DrawSegments Class
This class draws the segments for the numbers depending on the number you enter into the constructor. It utilizes the cases above.
import DrawSegment from './DrawSegment'
const segment = new DrawSegment(0); // We give a 0 to the constructor to let it know we want a 0 printed
segment.print(); // Using the .print() function we tell the segment to print to the console.
Using the DrawBigSegments Class
This class is using the same functionality as the DrawSegment Class.
The Class also prints the number you request but with double the segments. Also uses the same switch case.
import DrawBigSegment from './DrawBigSegment'
const segment = new DrawBigSegment(0);
segment.print();
Using the DrawTemperature Class
import DrawTemperature from './DrawTemperature'
const temperature = new DrawTemperature(8.2);
temperature.printToConsole();
temperature.return();
The temperature.printToConsole();
Prints the temperature to the console in your web-browser.
temperature.return();
Returns the temperature as a string so it can be used in other methods.
Using the DrawBigTemperature Class
Same functionality of the DrawTemperature Class with the exception of the numbers being double size.
import DrawBigTemperature from 'DrawBigTemperature'
const bigTemperature = new DrawBigTemperature(-5.3);
bigtemperature.printToConsole(); // To print to console
bitemperature.return(); // To return as a string.
Running the coded tests
npm run test
Runs the coded tetst that have been programmed using Jest.
Jest is a JavaScript Testing Framework that also supports the tests for TypeScript.
Licence
MIT
Github Pages
Through TypeDoc we setup Github Pages. This is automatically generated documentation for your Typescript Project.
The link for the Github Pages
for this repository: Github Pages
Author information
Author: Michiel Decoster
Student at Vives Hogeschool Brugge
4 years ago