{"id":21223930,"url":"https://github.com/niklauslee/7-segment","last_synced_at":"2025-03-15T01:33:37.310Z","repository":{"id":77037074,"uuid":"460372974","full_name":"niklauslee/7-segment","owner":"niklauslee","description":"Kaluma library for multi-digit 7-segment display (aka. FND - flexible numeric display)","archived":false,"fork":false,"pushed_at":"2023-11-30T22:38:45.000Z","size":58,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-21T17:30:48.452Z","etag":null,"topics":["7-segment","display","kaluma"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niklauslee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-17T09:49:09.000Z","updated_at":"2023-11-30T21:44:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"9989d365-7fc8-4a86-9706-5a36776e1783","html_url":"https://github.com/niklauslee/7-segment","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2F7-segment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2F7-segment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2F7-segment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2F7-segment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niklauslee","download_url":"https://codeload.github.com/niklauslee/7-segment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243671778,"owners_count":20328692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["7-segment","display","kaluma"],"created_at":"2024-11-20T22:54:06.269Z","updated_at":"2025-03-15T01:33:37.300Z","avatar_url":"https://github.com/niklauslee.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 7-segment (FND)\n\nKaluma library for multi-digit 7-segment display (aka. FND - flexible numeric display). This support flexible number of digits, so it can be used for 1-digit, 2-digit, 3-digit, 4-digit and more.\n\nEach segment is labeled as below:\n\n```\n    a\n   ---\nf |   | b\n   -g-\ne |   | c\n   --- . dp\n    d\n```\n\n# Wiring\n\nHere is a wiring example with a 4-digit 7-segment display (common-cathode type).\n\n| Raspberry Pi Pico | Resistor | FND (4-digit)   |\n| ----------------- | -------- | --------------- |\n| GP0               | 220(Ohm) | a               |\n| GP1               | 220(Ohm) | b               |\n| GP2               | 220(Ohm) | c               |\n| GP3               | 220(Ohm) | d               |\n| GP4               | 220(Ohm) | e               |\n| GP5               | 220(Ohm) | f               |\n| GP6               | 220(Ohm) | g               |\n| GP7               | 220(Ohm) | dp              |\n| GP21              |          | COM1            |\n| GP20              |          | COM2            |\n| GP19              |          | COM3            |\n| GP18              |          | COM4            |\n\n![wiring](https://github.com/niklauslee/7-segment/blob/main/images/wiring.jpg?raw=true)\n\n# Install\n\n```sh\nnpm install https://github.com/niklauslee/7-segment\n```\n\n# Usage\n\nHere is an example for a 4-digit FND:\n\n```js\nconst FND = require('7-segment').FND;\nconst segments = [0, 1, 2, 3, 4, 5, 6, 7]; // 'a' to 'dp'\nconst digits = [21, 20, 19, 18]; // digit-0 to digit-3\nconst fnd = new FND(segments, digits);\n\nfnd.display(25.4, 1);\nfnd.on();\n```\n\nIf you are using a common-anode type, create an instance with an option as below:\n\n```js\nconst fnd = new FND(segments, digits, {type: FND.ANODE});\n```\n\nIf you are using 1-digit display and connect the common pin to GND (cathode) or 3V3 (anode), you can omit the digits parameter as below:\n\n```js\n// common cathode\nconst fnd = new FND(segments);\n\n// common anode\nconst fnd = new FND(segments, [], {type: FND.ANODE});\n```\n\nIf you want to display non-numeric characters, you can use `setDigit()` with segment data.\n\n```js\n// display 'E' on digit-0.\nvar seg = FND_SEG_A | FND.SEG_F | FND.SEG_E | FND.SEG_D | FND.SEG_G;\nfnd.setDigit(seg, 0);\n\n// or,\nvar seg = 0b01111001;\nfnd.setDigit(seg, 0);\n```\n\n# API\n\n## Class: FND\n\n### new FND(segments, digits[, options])\n\n- **`segments`** `\u003cnumber[]\u003e` An array of pin numbers for segments (in the order of `a`, `b`, `c`, `d`, `e`, `f`, `g`, and `dp`).\n- **`digits`** `\u003cnumber[]\u003e` An array of pin numbers for common-cathode(or anode) of each digits. The pin number should be in the order of digit-0 (left-most), digit-1, ..., digit-n (right-most).\n- **`options`** `\u003cobject\u003e` Options.\n  - `type` `\u003cnumber\u003e` The type of FND. `FND.CATHODE`(=`0`) for common-cathode type or `FND.ANODE`(=`1`) for common-anode type. Default: `0`. \n  - `fps` `\u003cnumber\u003e` Number of frames per a second. It means how many shows all digits in a second. Greater value is more faster. Default: `60`.\n\nCreate an instance of FND class.\n\n### setDigit(data, digit)\n\n- **`data`** `\u003cnumber\u003e`\n- **`digit`** `\u003cnumber\u003e`\n\nSet the segment data at the digit in the internal buffer.\n\n```js\nconst FND = require('7-segment').FND;\n// ...\n// turn on 'b' and 'c' on digit-0.\nvar seg = FND.SEG_B | FND.SEG_C; \nfnd.setDigit(seg, 0);\n```\n\n### display(value, fixed)\n\n- **`value`** `\u003cnumber\u003e`\n- **`fixed`** `\u003cnumber\u003e` Default: `0`.\n\nDisplay the number on the display with the size of fixed point. The number will not be displayed until you call `on()`.\n\n```js\nfnd.display(25.687, 0); // show `26`.\nfnd.display(25.647, 1); // show `25.6`.\nfnd.display(25.647, 2); // show `25.65`.\n```\n\n### clear()\n\nClear the display. This means that clear the internal buffer.\n\n### on()\n\nTurn on the display.\n\n### off()\n\nTurn off the display.\n\n### FND.CATHODE\n\n- `\u003cnumber\u003e` = `0`\n\n### FND.ANODE\n\n- `\u003cnumber\u003e` = `1`\n\n### FND.SEG_A\n\n- `\u003cnumber\u003e` = `0b00000001`\n\n### FND.SEG_B\n\n- `\u003cnumber\u003e` = `0b00000010`\n\n### FND.SEG_C\n\n- `\u003cnumber\u003e` = `0b00000100`\n\n### FND.SEG_D\n\n- `\u003cnumber\u003e` = `0b00001000`\n\n### FND.SEG_E\n\n- `\u003cnumber\u003e` = `0b00010000`\n\n### FND.SEG_F\n\n- `\u003cnumber\u003e` = `0b00100000`\n\n### FND.SEG_G\n\n- `\u003cnumber\u003e` = `0b01000000`\n\n### FND.SEG_DP\n\n- `\u003cnumber\u003e` = `0b10000000`\n\n### FND.NUM\n\n- `\u003cnumber[]\u003e`\n\nAn array of segment data for numbers from 0 to 9.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklauslee%2F7-segment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniklauslee%2F7-segment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklauslee%2F7-segment/lists"}