npm package: @maximva/examenopdracht-maximva
Description: examn assignment for software engineering
Author: Maxim Vanden Abeele
Latest version: 1.0.0

# 7-Segment temperature display

![npm badge](https://img.shields.io/npm/v/@maximva/examenopdracht-maximva?color=green)
![ESLint](../../workflows/ESLint/badge.svg?branch=master)
![Markdown Linter](../../workflows/Markdown%20Linter/badge.svg?branch=master)
![Tests](../../workflows/Tests/badge.svg?branch=master)

## 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:

```bash
 ______________________
|   _           _  _   |
|  |_      |   |_||    |
|   _| /   |      |_   |
|______________________|
```

This is the assignment for my 4th semester exam 'Software Engineering'.

## How to install the package

It's available as an [package](https://www.npmjs.com/package/@maximva/examenopdracht-maximva) on [npmjs.com](https://www.npmjs.com/).

You can only use packages if your project itself is a 'package', if that's not yet the case, do this:

```bash
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:

```bash
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](https://vives-software-engineering-2020.github.io/examenopdracht-maximva/index.html) (GitHub Pages).

## Some code examples with output

### Regular size with frame

```ts
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)
```

```bash
 _______________________________
|         _     _        _  _   |
|   _   | _|   |_|  |   |_||    |
|       ||_  / |_|  |      |_   |
|_______________________________|
```

### Now with some different settings

```ts
const displaySettings = {
    frame : false,
    size : DisplaySize.regular
}
```

```bash
       _     _        _  _
 _   | _|   |_|  |   |_||
     ||_  / |_|  |      |_
```

```ts
const displaySettings = {
    frame : false,
    size : DisplaySize.large
}
```

```bash
           ___       ___            ___  ___
         |    |     |   |    |     |   ||
         |    |     |   |    |     |   ||
 ___       ___       ___            ___
         ||         |   |    |          |
         ||         |   |    |          |
           ___   /   ___                 ___
```

```ts
const displaySettings = {
    frame : true,
    size : DisplaySize.large
}
```

```bash
 _________________________________________________
|             ___       ___            ___  ___   |
|           |    |     |   |    |     |   ||      |
|           |    |     |   |    |     |   ||      |
|   ___       ___       ___            ___        |
|           ||         |   |    |          |      |
|           ||         |   |    |          |      |
|             ___   /   ___                 ___   |
|_________________________________________________|
```

## 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](https://stackoverflow.com/questions/13315131/enforcing-the-type-of-the-indexed-members-of-a-typescript-object)

## License

Have a look here for more information about the license:
[The Unlicense](https://github.com/vives-software-engineering-2020/home-automation-maximva/blob/master/LICENSE.md)

## 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](https://www.linkedin.com/in/maxim-vanden-abeele-56707813/).