This package makes it possible for anybody to transform a simple temperature to an 7-segment representation of it (in string format) to print to a webpage or to the console, or anywhere for that matter.
For example, given a temperature of 5.1
the result would be this:
______________________
| _ _ _ |
| |_ | |_|| |
| _| / | |_ |
|______________________|
This is the assignment for my 4th semester exam 'Software Engineering'.
It's available as an package on npmjs.com.
You can only use packages if your project itself is a 'package', if that's not yet the case, do this:
npm init
Just run through the question and at the end it will create your package.json
file.
Then you just install this package like so:
npm install @maximva/examenopdracht-maximva
The example code below expects you to have typescript (npm install typescript) installed.
All documentation can be found here (GitHub Pages).
import { Display } from '@maximva/examenopdracht-maximva'
import { Temperature } from '@maximva/examenopdracht-maximva'
import { DisplaySize } from '@maximva/examenopdracht-maximva'
const displaySettings = {
frame : true,
size : DisplaySize.regular
}
const temperature: Temperature = new Temperature(12.81)
const display: Display = new Display(displaySettings)
const displayOutput = display.write(temperature.toString())
console.log(displayOutput)
_______________________________
| _ _ _ _ |
| _ | _| |_| | |_|| |
| ||_ / |_| | |_ |
|_______________________________|
const displaySettings = {
frame : false,
size : DisplaySize.regular
}
_ _ _ _
_ | _| |_| | |_||
||_ / |_| | |_
const displaySettings = {
frame : false,
size : DisplaySize.large
}
___ ___ ___ ___
| | | | | | ||
| | | | | | ||
___ ___ ___ ___
|| | | | |
|| | | | |
___ / ___ ___
const displaySettings = {
frame : true,
size : DisplaySize.large
}
_________________________________________________
| ___ ___ ___ ___ |
| | | | | | | || |
| | | | | | | || |
| ___ ___ ___ ___ |
| || | | | | |
| || | | | | |
| ___ / ___ ___ |
|_________________________________________________|
In the digits class each supported character is represented by a series of binary values. I had some problems using a string (with the character in question) as a key and ended up implementing this solution
Have a look here for more information about the license: The Unlicense
The creator of this package is me, Maxim Vanden Abeele. I'm a student at University College Vives in Bruges. You can find me on LinkedIn.
Generated using TypeDoc