1.0.0 • Published 4 years ago

@maximva/examenopdracht-maximva v1.0.0

Weekly downloads
-
License
The Unlicense
Repository
github
Last release
4 years ago

7-Segment temperature display

npm badge ESLint Markdown Linter Tests

About this npm package

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'.

How to install the package

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.

Documentation

All documentation can be found here (GitHub Pages).

Some code examples with output

Regular size with frame

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)
 _______________________________
|         _     _        _  _   |
|   _   | _|   |_|  |   |_||    |
|       ||_  / |_|  |      |_   |
|_______________________________|

Now with some different settings

const displaySettings = {
    frame : false,
    size : DisplaySize.regular
}
       _     _        _  _
 _   | _|   |_|  |   |_||
     ||_  / |_|  |      |_
const displaySettings = {
    frame : false,
    size : DisplaySize.large
}
           ___       ___            ___  ___
         |    |     |   |    |     |   ||
         |    |     |   |    |     |   ||
 ___       ___       ___            ___
         ||         |   |    |          |
         ||         |   |    |          |
           ___   /   ___                 ___
const displaySettings = {
    frame : true,
    size : DisplaySize.large
}
 _________________________________________________
|             ___       ___            ___  ___   |
|           |    |     |   |    |     |   ||      |
|           |    |     |   |    |     |   ||      |
|   ___       ___       ___            ___        |
|           ||         |   |    |          |      |
|           ||         |   |    |          |      |
|             ___   /   ___                 ___   |
|_________________________________________________|

Sources

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

License

Have a look here for more information about the license: The Unlicense

About the creator

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.

1.0.0

4 years ago

0.9.2

4 years ago

0.9.0

4 years ago

0.9.1

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago