0.0.1 • Published 4 years ago

@niels-vanhove/examenopdracht-nielsvanhove v0.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

Temperature LCD Display Library

badge

ESLint

Markdown Linter

Tests

Description

This is a Typescript library that puts the values of the temperature in the console in LCD style. You can add number from 0 until 9, you can give negative numbers just add the - character before the numbers. There is also a letter C and ° included so you can give in degrees celsius. You can also give in a comma number.

Features

I added some features in the library so you can choose between normal digits or big digits.

      _  _     _  _  _  _  _   _          _    _
 _  | _| _||_||_ |_   ||_||_| | |        |_|  |
    ||_  _|  | _||_|  ||_| _| |_|  /          |_
 __      __  __      __  __  __  __  __      __  __      __  __
|  |   |   |   ||  ||   |      ||  ||  |       |   |    |  ||
|  |   | __| __||__||__ |__    ||__||__|     __| __|    |__||
|  |   ||      |   |   ||  |   ||  |   |  /    |   |        |
|__|   ||__  __|   | __||__|   ||__| __| /   __| __|        |__

Choosing between normal and big letters is one feature i added another feature so that you can wrap the digits into an framework.

 ________________________________________________
| _     _  _     _  _  _  _  _     _  _     _  _ |
|| |  | _| _||_||_ |_   ||_||_|    _| _|   |_||  |
||_|  ||_  _|  | _||_|  ||_| _| /  _| _|      |_ |
|________________________________________________|
 ________________________________________________________________
| __      __  __      __  __  __  __  __      __  __      __  __ |
||  |   |   |   ||  ||   |      ||  ||  |       |   |    |  ||   |
||  |   | __| __||__||__ |__    ||__||__|     __| __|    |__||   |
||  |   ||      |   |   ||  |   ||  |   |  /    |   |        |   |
||__|   ||__  __|   | __||__|   ||__| __| /   __| __|        |__ |
|________________________________________________________________|

How to use the library

If you want to use the library you have to delete the index.ts file. This file is still in the code so that you can test if my library works. You can just type this command in the console:

ts-node ./index.ts

If you have done testing the library you can change the value of the temperature, you can choose between big letters and normal. Or you can choose te get a framework around the digits. In the class app you can change this 3 lines of code:

const temperature = "26,33 °C"
const bigLetters = true
const framework = true

So if you want 20 °C just change the temperature variable. If you want big letters put the variable bigLetters on true if it is false you will get normal letters. If you want a framework just put the variable framework on true, if it is false you will get no framework.

Unit tests

If you don't want to use the index.ts to test the code you can also use the unit testers i made. If you want to test the unit testers just type these commando's:

npm install --save-dev @types/jest jest ts-jest
npm run test

Here is an example of an test, this test converts the binary presentation of number of 0 into digital characters.

test('converting binary small 0 code to digit', () => {
    const binaryDigit = new BinaryToDigit("11111100")
    expect(binaryDigit.letter).toStrictEqual([" _ ", "| |", "|_|"]);
})

I was not able get the output from the test in a visable digit, so i it remains in the array. But you can see that if you write all the elements of the array beneeth each other you can see the digit 0.

 _
| |
|_|

I did this for all my tests. If you test the framework you will just see a big underscore before and after the array but in the console it will be on the full lenth of te digits.

License

I added a license with the license that i use. This license is open source, oes not state that changes to the code must be documented. Derived work must not published under the same license (any licence can be used). So i have chosen for the MIT license.

  1. MIT
    • Permissions
      • Commercial use
      • Distribution
      • Modification
      • Patent use
      • Private use
    • Conditions
      • License and copyright notice
    • Limitations
      • Liability
      • Warranty

Using NPM Package

You can find my library also on npmjs.org so that you can integrate my library in projects.

Link to webiste

linkWebsite

Links that i used to build my library

These are the links that helped me build the library, i build the code by myself but i got inspiration of these links.

Author information

Author: Niels Vanhove E-mail: niels.vanhove@student.vives.be School: VIVES Brugge